diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-24 02:38:32 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-09-24 02:38:32 +0000 |
commit | 6d121436d4d1b3a9a9425ebdb4937fe247679627 (patch) | |
tree | 1097996815904aae7938e9e9fa448d1085478bcf /sys/kern | |
parent | c6f91b18056ab0ffe674a1aee43ef4bf4c3e276e (diff) |
unescapeable chroot; thanks to nirva and asriel for helping
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_syscalls.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 36e7dddcd48..518dd912abf 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.12 1996/08/08 06:36:47 tholo Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.13 1996/09/24 02:38:30 deraadt Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -701,8 +701,16 @@ sys_chroot(p, v, retval) SCARG(uap, path), p); if ((error = change_dir(&nd, p)) != 0) return (error); - if (fdp->fd_rdir != NULL) + if (fdp->fd_rdir != NULL) { + /* + * A chroot() done inside a changed root environment does + * an automatic chdir to avoid the out-of-tree experience. + */ vrele(fdp->fd_rdir); + vrele(fdp->fd_cdir); + VREF(nd.ni_vp); + fdp->fd_cdir = nd.ni_vp; + } fdp->fd_rdir = nd.ni_vp; return (0); } |