Skip to content
Permalink
Browse files Browse the repository at this point in the history
halfway revert hack/configure changes - switch order of daemon_init/d…
…rop_privileges
  • Loading branch information
hedenface committed Jul 30, 2017
1 parent 60638cf commit 1b19734
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Changelog
Expand Up @@ -8,6 +8,8 @@ Nagios Core 4 Change Log
* On-demand host check always use cached host state (John Frickson)
* 'á' causes Serivce Status Information to not be displayed (John Frickson)
* New Macro(s) to generate URL for host / service object (John Frickson)
* Fix minor map issues (Troy Lea)
* Fix lockfile issues (Bryan Heden)


4.3.2 - 2017-05-09
Expand Down
1 change: 1 addition & 0 deletions THANKS
Expand Up @@ -320,6 +320,7 @@ wrong, please let me know.
* Tomer Okavi
* Ton Voon
* Torsten Huebler
* Troy Lea
* Tyler Lund
* Uwe Knop
* Uwe Knop
Expand Down
31 changes: 16 additions & 15 deletions base/nagios.c
Expand Up @@ -592,6 +592,22 @@ int main(int argc, char **argv) {
program_start = time(NULL);
my_free(mac->x[MACRO_PROCESSSTARTTIME]);
asprintf(&mac->x[MACRO_PROCESSSTARTTIME], "%llu", (unsigned long long)program_start);

/* enter daemon mode (unless we're restarting...) */
if(daemon_mode == TRUE && sigrestart == FALSE) {

result = daemon_init();

/* we had an error daemonizing, so bail... */
if(result == ERROR) {
logit(NSLOG_PROCESS_INFO | NSLOG_RUNTIME_ERROR, TRUE, "Bailing out due to failure to daemonize. (PID=%d)", (int)getpid());
cleanup();
exit(EXIT_FAILURE);
}

/* get new PID */
nagios_pid = (int)getpid();
}

/* drop privileges */
if(drop_privileges(nagios_user, nagios_group) == ERROR) {
Expand All @@ -612,21 +628,6 @@ int main(int argc, char **argv) {
/* error has already been logged */
exit(EXIT_FAILURE);
}
/* enter daemon mode (unless we're restarting...) */
if(daemon_mode == TRUE && sigrestart == FALSE) {

result = daemon_init();

/* we had an error daemonizing, so bail... */
if(result == ERROR) {
logit(NSLOG_PROCESS_INFO | NSLOG_RUNTIME_ERROR, TRUE, "Bailing out due to failure to daemonize. (PID=%d)", (int)getpid());
cleanup();
exit(EXIT_FAILURE);
}

/* get new PID */
nagios_pid = (int)getpid();
}

/* this must be logged after we read config data, as user may have changed location of main log file */
logit(NSLOG_PROCESS_INFO, TRUE, "Nagios %s starting... (PID=%d)\n", PROGRAM_VERSION, (int)getpid());
Expand Down
10 changes: 2 additions & 8 deletions configure.ac
Expand Up @@ -227,6 +227,7 @@ AC_ARG_WITH(checkresult-dir,
if test x$CHECKRESULTDIR = xno; then
CHECKRESULTDIR="$localstatedir/spool/checkresults"
fi
AC_SUBST(CHECKRESULTDIR)

dnl Location of check result path
TMPDIR=no
Expand Down Expand Up @@ -270,7 +271,7 @@ AC_ARG_WITH(lockfile,
lockfile=$withval,
lockfile=$localstatedir/nagios.lock
)

AC_SUBST(lockfile)

dnl Determine the library to be used by the iobroker

Expand Down Expand Up @@ -819,13 +820,6 @@ perl subst sample-config/template-object/printer.cfg
perl subst sample-config/template-object/switch.cfg



eval localstatedir=$localstatedir
eval lockfile=$lockfile
eval CHECKRESULTDIR=$CHECKRESULTDIR
AC_SUBST(CHECKRESULTDIR)
AC_SUBST(lockfile)

dnl Review options
echo ""
echo ""
Expand Down

0 comments on commit 1b19734

Please sign in to comment.