When running in secure mode (-s), we must not chdir while daemonizing

When running in secure mode (-s), we must not chdir while daemonizing.
Thanks to Adrian Urquhart for spotting this bug.
This commit is contained in:
H. Peter Anvin 2007-01-30 15:38:04 -08:00
parent 077eac1fd6
commit c7ecc59f86

View file

@ -502,7 +502,9 @@ main(int argc, char **argv)
}
/* Daemonize this process */
if (!nodaemon && daemon(0, 0) < 0) {
/* Note: when running in secure mode (-s), we must not chroot, since
we are already in the proper directory. */
if (!nodaemon && daemon(secure, 0) < 0) {
syslog(LOG_ERR, "cannot daemonize: %m");
exit(EX_OSERR);
}