From c7ecc59f86767b07498d770d4953b37fa205415d Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Tue, 30 Jan 2007 15:38:04 -0800 Subject: [PATCH] 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. --- tftpd/tftpd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); }