From: Dan Langille Date: Thu, 16 Aug 2007 18:46:16 +0000 (+0000) Subject: Don't set our PID after we drop privs. Do it before. This fixes bug #923 X-Git-Tag: Release-7.0.0~5831 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9e1f96b1eb7a5b6d61f9dc409dab1c1bc5408477;p=bacula%2Fbacula Don't set our PID after we drop privs. Do it before. This fixes bug #923 git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@5362 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 8f596ca735..d34acd8efb 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -228,6 +228,15 @@ int main (int argc, char *argv[]) Jmsg((JCR *)NULL, M_ERROR_TERM, 0, _("Please correct configuration file: %s\n"), configfile); } + if (background) { + daemon_start(); + init_stack_dump(); /* grab new pid */ + } + + /* Create pid must come after we are a daemon -- so we have our final pid */ + create_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); + read_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); + drop(uid, gid); /* reduce privileges if requested */ if (!check_catalog()) { @@ -247,15 +256,6 @@ int main (int argc, char *argv[]) FDConnectTimeout = (int)director->FDConnectTimeout; SDConnectTimeout = (int)director->SDConnectTimeout; - if (background) { - daemon_start(); - init_stack_dump(); /* grab new pid */ - } - - /* Create pid must come after we are a daemon -- so we have our final pid */ - create_pid_file(director->pid_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); - read_state_file(director->working_directory, "bacula-dir", get_first_port_host_order(director->DIRaddrs)); - #if !defined(HAVE_WIN32) signal(SIGHUP, reload_config);