src/server/daemon/webserver.c

changeset 388
30d29ef5b79a
parent 386
b91f8efadb63
child 391
80ee93a7d257
--- a/src/server/daemon/webserver.c	Sun Sep 25 09:33:39 2022 +0200
+++ b/src/server/daemon/webserver.c	Sun Sep 25 10:36:28 2022 +0200
@@ -91,11 +91,15 @@
     }
 
     // load server.conf
+    // Only the runtime infos are stored in the ServerConfiguration at
+    // this stage. The remaining configuration is loaded after the uid
+    // is changed (if needed).
     init_configuration_manager();
-    ServerConfiguration *cfg;
-    if(cfgmgr_load_config(&cfg) != 0) {
+    CfgManager mgr;
+    if(cfgmgr_load_config(&mgr) != 0) {
         return -1;
     }
+    ServerConfiguration *cfg = mgr.cfg;
     
     // init caches
     auth_cache_init();
@@ -163,6 +167,14 @@
                     "server must be started as root to change uid");
     }
     
+    
+    // now that the process is running as the correct user, we can load
+    // the remaining config
+    if(cfgmgr_apply_config(&mgr)) {
+        return -1;
+    }
+    
+    
     // create tmp dir and pid file
     char *mkdir_cmd = NULL;
     asprintf(&mkdir_cmd, "mkdir -p %s", cfg->tmp.ptr);

mercurial