diff options
author | semarie <semarie@openbsd.org> | 2015-12-14 16:34:55 +0000 |
---|---|---|
committer | semarie <semarie@openbsd.org> | 2015-12-14 16:34:55 +0000 |
commit | a9864a2d97a4e93a968033d955374db2313c82f1 (patch) | |
tree | e30a23e59e424b75148a22f3cd170e3184ada295 /usr.sbin/tftpd | |
parent | Move system headers from sh.h to those files that actually need them. (diff) | |
download | wireguard-openbsd-a9864a2d97a4e93a968033d955374db2313c82f1.tar.xz wireguard-openbsd-a9864a2d97a4e93a968033d955374db2313c82f1.zip |
move daemon(3) call before chroot(2) in tftpd.
so daemon(3) will be able to redirect standard input, standard output and
standard error to /dev/null.
ok jca@
Diffstat (limited to 'usr.sbin/tftpd')
-rw-r--r-- | usr.sbin/tftpd/tftpd.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/usr.sbin/tftpd/tftpd.c b/usr.sbin/tftpd/tftpd.c index 3749d17d5ed..d3d4ecbade6 100644 --- a/usr.sbin/tftpd/tftpd.c +++ b/usr.sbin/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.33 2015/12/11 20:11:10 mmcc Exp $ */ +/* $OpenBSD: tftpd.c,v 1.34 2015/12/14 16:34:55 semarie Exp $ */ /* * Copyright (c) 2012 David Gwynne <dlg@uq.edu.au> @@ -344,6 +344,9 @@ main(int argc, char *argv[]) tftpd_listen(addr, port, family); + if (!debug && daemon(1, 0) == -1) + err(1, "unable to daemonize"); + if (chroot(dir)) err(1, "chroot %s", dir); if (chdir("/")) @@ -355,9 +358,6 @@ main(int argc, char *argv[]) setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid)) errx(1, "can't drop privileges"); - if (!debug && daemon(1, 0) == -1) - err(1, "unable to daemonize"); - if (pledge("stdio rpath wpath cpath fattr dns inet", NULL) == -1) err(1, "pledge"); |