diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-10-25 10:52:49 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-10-25 10:52:49 +0000 |
commit | 38f2c7db063b8692449987572feea6fe7b2870c4 (patch) | |
tree | 8cd1c83d84df0cbff81fb8d2eba098a018bc28d1 /usr.sbin/ntpd | |
parent | 6b1fa2ae79b59b62098c8d6f065ed5214010e84e (diff) |
the DNS process was not discarding & redirecting stdin/out/err to
/dev/null. copy the code from the ntp engine.
Diffstat (limited to 'usr.sbin/ntpd')
-rw-r--r-- | usr.sbin/ntpd/ntp_dns.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/usr.sbin/ntpd/ntp_dns.c b/usr.sbin/ntpd/ntp_dns.c index f00ef1d2e14..72cf19be23c 100644 --- a/usr.sbin/ntpd/ntp_dns.c +++ b/usr.sbin/ntpd/ntp_dns.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp_dns.c,v 1.13 2015/10/10 20:10:14 deraadt Exp $ */ +/* $OpenBSD: ntp_dns.c,v 1.14 2015/10/25 10:52:48 deraadt Exp $ */ /* * Copyright (c) 2003-2008 Henning Brauer <henning@openbsd.org> @@ -23,6 +23,7 @@ #include <err.h> #include <errno.h> #include <poll.h> +#include <fcntl.h> #include <signal.h> #include <stdlib.h> #include <string.h> @@ -52,7 +53,7 @@ ntp_dns(int pipe_ntp[2], struct ntpd_conf *nconf, struct passwd *pw) { pid_t pid; struct pollfd pfd[1]; - int nfds; + int nfds, nullfd; switch (pid = fork()) { case -1: @@ -74,6 +75,16 @@ ntp_dns(int pipe_ntp[2], struct ntpd_conf *nconf, struct passwd *pw) fatal("setsid"); } + if ((nullfd = open("/dev/null", O_RDWR, 0)) == -1) + fatal(NULL); + + if (!nconf->debug) { + dup2(nullfd, STDIN_FILENO); + dup2(nullfd, STDOUT_FILENO); + dup2(nullfd, STDERR_FILENO); + } + close(nullfd); + setproctitle("dns engine"); close(pipe_ntp[0]); |