From 81bbb3f0f078d20c4ea24a40effde6cbb3a5f138 Mon Sep 17 00:00:00 2001 From: Ryan O'Hara Date: Fri, 10 Aug 2012 11:00:25 -0500 Subject: [PATCH] Call daemonize before chroot. This patch causes stud to daemonize prior to calling chroot. If chroot is done prior to daemonize, the daemonize call will fail to open /dev/null. --- stud.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/stud.c b/stud.c index b623e83..18529e5 100644 --- a/stud.c +++ b/stud.c @@ -1642,12 +1642,6 @@ int main(int argc, char **argv) { /* load certificate, pass to handle_connections */ ssl_ctx = init_openssl(); - if (CONFIG->CHROOT && CONFIG->CHROOT[0]) - change_root(); - - if (CONFIG->UID || CONFIG->GID) - drop_privileges(); - /* should we daemonize ?*/ if (CONFIG->DAEMONIZE) { /* disable logging to stderr */ @@ -1658,6 +1652,12 @@ int main(int argc, char **argv) { daemonize(); } + if (CONFIG->CHROOT && CONFIG->CHROOT[0]) + change_root(); + + if (CONFIG->UID || CONFIG->GID) + drop_privileges(); + master_pid = getpid(); start_children(0, CONFIG->NCORES);