Merge pull request #80 from Nauxuron/master
authorFelix Morgner <felix.morgner@gmail.com>
Thu, 26 Jan 2017 12:12:25 +0000 (13:12 +0100)
committerFelix Morgner <felix.morgner@gmail.com>
Thu, 26 Jan 2017 12:12:25 +0000 (13:12 +0100)
src/main.c

index bc913395f8b56e784709aac25ed9839ca1820f73..c74d9646bd71f168ee29627019a76da272ca61ba 100644 (file)
@@ -322,7 +322,6 @@ int main(int argc, char **argv)
                        Log_init(false);
                        if (pidfile != NULL)
                                lockfile(pidfile);
-
 #ifdef POSIX_PRIORITY_SCHEDULING
                        /* Set the scheduling policy, has to be called after daemonizing
                         * but before we drop privileges */
@@ -330,12 +329,6 @@ int main(int argc, char **argv)
                                setscheduler();
 #endif
 
-                       switch_user();
-
-                       /* Reopen log file. If user switch results in access denied, we catch
-                        * it early.
-                        */
-                       Log_reset();
                }
                else Log_init(true);
 
@@ -376,6 +369,16 @@ int main(int argc, char **argv)
     Sharedmemory_init( bindport, bindport6 );
 #endif
 
+               if(!nodaemon) {
+                       /* SSL and scheduling is setup, we can drop privileges now */
+                       switch_user();
+
+                       /* Reopen log file. If user switch results in access denied, we catch
+                        * it early.
+                        */
+                       Log_reset();
+               }
+
                Server_run();
 
 #ifdef USE_SHAREDMEMORY_API