1
0
mirror of https://github.com/openbsd/src.git synced 2024-12-22 16:42:56 -08:00

Check return code of chdir() after chroot(); noted by Joris Vink, slight mod

from avsm@.
ok avsm@ hshoexer@ henning@
This commit is contained in:
otto 2004-03-14 19:17:05 +00:00
parent 84063c3130
commit 769143de32
3 changed files with 9 additions and 6 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)