src/server/daemon/webserver.c

changeset 426
6a2e7a464991
parent 415
d938228c382e
child 427
a327cb6cc868
--- a/src/server/daemon/webserver.c	Sat Nov 12 12:09:37 2022 +0100
+++ b/src/server/daemon/webserver.c	Sat Nov 12 16:52:32 2022 +0100
@@ -92,7 +92,8 @@
     }
     
     // load init.conf
-    if(load_init_conf("config/init.conf")) {
+    InitConfig *init_config = load_init_conf("config/init.conf");
+    if(!init_config) {
         return -1;
     }
 
@@ -108,12 +109,6 @@
     log_ereport(LOG_VERBOSE, "cfgmgr_load_config stage 1 successful");
     ServerConfiguration *cfg = mgr.cfg;
     
-    // init caches
-    auth_cache_init();
-    
-    // init SAFs
-    common_saf_init();
-    
     // set global vars
     conf_global_vars_s *vars = conf_getglobals();
     
@@ -178,6 +173,21 @@
                     "server must be started as root to change uid");
     }
     
+    // run Init directives
+    // this must be done after setuid
+    int err = apply_init_conf(init_config);
+    free_init_conf(init_config);
+    if(err) {
+        log_ereport(LOG_FAILURE, "server init failed");
+        return 1;
+    }
+    
+    // init caches
+    auth_cache_init();
+    
+    // init SAFs
+    common_saf_init();
+    
     
     // now that the process is running as the correct user, we can load
     // the remaining config

mercurial