summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2004-03-14 19:17:06 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2004-03-14 19:17:06 +0000
commit89d99c0284f993829fecf7c794a4e503c08ee5c5 (patch)
treedcb5c7a99e1f49c1bd52284f9d3b003a5652a300
parentdc6eb02a705bb48a5ff401ae332781dec60bba96 (diff)
Check return code of chdir() after chroot(); noted by Joris Vink, slight mod
from avsm@. ok avsm@ hshoexer@ henning@
-rw-r--r--sbin/pflogd/privsep.c5
-rw-r--r--usr.sbin/syslogd/privsep.c5
-rw-r--r--usr.sbin/tcpdump/privsep.c5
3 files changed, 9 insertions, 6 deletions
diff --git a/sbin/pflogd/privsep.c b/sbin/pflogd/privsep.c
index bcb242e0ff0..50807ada4e4 100644
--- a/sbin/pflogd/privsep.c
+++ b/sbin/pflogd/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.7 2004/02/13 19:01:57 otto Exp $ */
+/* $OpenBSD: privsep.c,v 1.8 2004/03/14 19:17:05 otto Exp $ */
/*
* Copyright (c) 2003 Can Erkin Acar
@@ -92,7 +92,8 @@ priv_init(void)
/* Child - drop privileges and return */
if (chroot(pw->pw_dir) != 0)
err(1, "unable to chroot");
- chdir("/");
+ if (chdir("/") != 0)
+ err(1, "unable to chdir");
gidset[0] = pw->pw_gid;
if (setgroups(1, gidset) == -1)
diff --git a/usr.sbin/syslogd/privsep.c b/usr.sbin/syslogd/privsep.c
index a3e241b2b3d..0910101fb7b 100644
--- a/usr.sbin/syslogd/privsep.c
+++ b/usr.sbin/syslogd/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.15 2004/03/06 19:42:38 otto Exp $ */
+/* $OpenBSD: privsep.c,v 1.16 2004/03/14 19:17:05 otto Exp $ */
/*
* Copyright (c) 2003 Anil Madhavapeddy <anil@recoil.org>
@@ -126,7 +126,8 @@ priv_init(char *conf, int numeric, int lockfd, int nullfd, char *argv[])
/* Child - drop privileges and return */
if (chroot(pw->pw_dir) != 0)
err(1, "unable to chroot");
- chdir("/");
+ if (chdir("/") != 0)
+ err(1, "unable to chdir");
gidset[0] = pw->pw_gid;
if (setgroups(1, gidset) == -1)
diff --git a/usr.sbin/tcpdump/privsep.c b/usr.sbin/tcpdump/privsep.c
index fc0c6cdfc59..feed7d69d5f 100644
--- a/usr.sbin/tcpdump/privsep.c
+++ b/usr.sbin/tcpdump/privsep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: privsep.c,v 1.4 2004/02/05 22:12:06 otto Exp $ */
+/* $OpenBSD: privsep.c,v 1.5 2004/03/14 19:17:05 otto Exp $ */
/*
* Copyright (c) 2003 Can Erkin Acar
@@ -128,7 +128,8 @@ priv_init(int argc, char **argv)
/* chroot, drop privs and return */
if (chroot(pw->pw_dir) != 0)
err(1, "unable to chroot");
- chdir("/");
+ if (chdir("/") != 0)
+ err(1, "unable to chdir");
/* drop to _tcpdump */
if (setgroups(1, &pw->pw_gid) == -1)