aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2007-01-30 15:38:04 -0800
committerH. Peter Anvin <hpa@zytor.com>2007-01-30 15:38:04 -0800
commitc7ecc59f86767b07498d770d4953b37fa205415d (patch)
tree2c007b42e38245169c775934d3eebf97fca25908
parent077eac1fd62a6c9ca087278efb10cc6a6802d4bb (diff)
downloadtftp-hpa-c7ecc59f86767b07498d770d4953b37fa205415d.tar.gz
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.
-rw-r--r--tftpd/tftpd.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tftpd/tftpd.c b/tftpd/tftpd.c
index a1f30f6..92a6889 100644
--- a/tftpd/tftpd.c
+++ b/tftpd/tftpd.c
@@ -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);
}