diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-07-30 18:27:48 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1999-07-30 18:27:48 +0000 |
commit | 07a76d397127d99de107e15557be6170a89ade50 (patch) | |
tree | e81a43856785de0716c35ebc3102e8f26a2737cf /sys/kern/vfs_syscalls.c | |
parent | d572dac69bd76a454d4eb43536df41e6992ea8cd (diff) |
do not permit regular users to chflags/fchflags on chr or blk devices --
even if they happen to own them at the moment.
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r-- | sys/kern/vfs_syscalls.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 55ee96e9a02..ff4864b0345 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.58 1999/07/13 15:17:51 provos Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.59 1999/07/30 18:27:47 deraadt Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -1530,10 +1530,19 @@ sys_chflags(p, v, retval) else if (SCARG(uap, flags) == VNOVAL) error = EINVAL; else { + if (suser(p->p_ucred, &p->p_acflag)) { + if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) != 0) + goto out; + if (vattr.va_type == VCHR || vattr.va_type == VBLK) { + error = EINVAL; + goto out; + } + } VATTR_NULL(&vattr); vattr.va_flags = SCARG(uap, flags); error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); } +out: vput(vp); return (error); } @@ -1567,10 +1576,20 @@ sys_fchflags(p, v, retval) else if (SCARG(uap, flags) == VNOVAL) error = EINVAL; else { + if (suser(p->p_ucred, &p->p_acflag)) { + if ((error = VOP_GETATTR(vp, &vattr, p->p_ucred, p)) + != 0) + goto out; + if (vattr.va_type == VCHR || vattr.va_type == VBLK) { + error = EINVAL; + goto out; + } + } VATTR_NULL(&vattr); vattr.va_flags = SCARG(uap, flags); error = VOP_SETATTR(vp, &vattr, p->p_ucred, p); } +out: VOP_UNLOCK(vp, 0, p); return (error); } |