X-Git-Url: http://git.code-monkey.de/?p=umurmur.git;a=blobdiff_plain;f=src%2Fmain.c;h=c74d9646bd71f168ee29627019a76da272ca61ba;hp=d98fb6aca3a89b42fa3d4fbe2d21d51cd74208ec;hb=ec643e91b6f4e22c56d8ab7c89a681f84931af91;hpb=571e132795d595c7c4ce39b5b1bc9aae6a72f4cd diff --git a/src/main.c b/src/main.c index d98fb6a..c74d964 100644 --- a/src/main.c +++ b/src/main.c @@ -322,9 +322,25 @@ 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 */ + if (realtime) + setscheduler(); +#endif + } else Log_init(true); +#ifdef POSIX_PRIORITY_SCHEDULING + /* We still want to set scheduling policy if nodaemon is specified, + * but if we are daemonizing setscheduler() will be called above */ + if (nodaemon) { + if (realtime) + setscheduler(); + } +#endif + signal(SIGCHLD, SIG_IGN); /* ignore child */ signal(SIGTSTP, SIG_IGN); /* ignore tty signals */ signal(SIGTTOU, SIG_IGN); @@ -353,16 +369,15 @@ int main(int argc, char **argv) Sharedmemory_init( bindport, bindport6 ); #endif -#ifdef POSIX_PRIORITY_SCHEDULING - if (realtime) - setscheduler(); -#endif + if(!nodaemon) { + /* SSL and scheduling is setup, we can drop privileges now */ + switch_user(); - switch_user(); - /* Reopen log file. If user switch results in access denied, we catch - * it early. - */ - Log_reset(); + /* Reopen log file. If user switch results in access denied, we catch + * it early. + */ + Log_reset(); + } Server_run();