summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_syscalls.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1999-01-30 12:27:00 +0000
committerphk <phk@FreeBSD.org>1999-01-30 12:27:00 +0000
commitc43b148bf4e862387fd253642a9d4a839b6c7636 (patch)
tree0d0e254c9d3b352374fd9efa783f8d7d0933f098 /sys/kern/vfs_syscalls.c
parent7aa70998d2cba5b47ef4967e0dec7fdd23fb3007 (diff)
downloadFreeBSD-src-c43b148bf4e862387fd253642a9d4a839b6c7636.zip
FreeBSD-src-c43b148bf4e862387fd253642a9d4a839b6c7636.tar.gz
Use suser() to determine super-user-ness.
Collapse some duplicated checks. Reviewed by: bde
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r--sys/kern/vfs_syscalls.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index b14c802..c36313c 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)vfs_syscalls.c 8.13 (Berkeley) 4/15/94
- * $Id: vfs_syscalls.c,v 1.114 1999/01/27 21:49:58 dillon Exp $
+ * $Id: vfs_syscalls.c,v 1.115 1999/01/28 17:32:00 dillon Exp $
*/
/* For 4.3 integer FS ID compatibility */
@@ -119,7 +119,19 @@ mount(p, uap)
if (usermount == 0 && (error = suser(p->p_ucred, &p->p_acflag)))
return (error);
-
+ /*
+ * Do not allow NFS export by non-root users.
+ */
+ if (SCARG(uap, flags) & MNT_EXPORTED) {
+ error = suser(p->p_ucred, &p->p_acflag);
+ if (error)
+ return (error);
+ }
+ /*
+ * Silently enforce MNT_NOSUID and MNT_NODEV for non-root users
+ */
+ if (suser(p->p_ucred, (u_short *)NULL))
+ SCARG(uap, flags) |= MNT_NOSUID | MNT_NODEV;
/*
* Get vnode to be covered
*/
@@ -156,17 +168,6 @@ mount(p, uap)
vput(vp);
return (error);
}
- /*
- * Do not allow NFS export by non-root users. Silently
- * enforce MNT_NOSUID and MNT_NODEV for non-root users.
- */
- if (p->p_ucred->cr_uid != 0) {
- if (SCARG(uap, flags) & MNT_EXPORTED) {
- vput(vp);
- return (EPERM);
- }
- SCARG(uap, flags) |= MNT_NOSUID | MNT_NODEV;
- }
if (vfs_busy(mp, LK_NOWAIT, 0, p)) {
vput(vp);
return (EBUSY);
@@ -184,17 +185,6 @@ mount(p, uap)
vput(vp);
return (error);
}
- /*
- * Do not allow NFS export by non-root users. Silently
- * enforce MNT_NOSUID and MNT_NODEV for non-root users.
- */
- if (p->p_ucred->cr_uid != 0) {
- if (SCARG(uap, flags) & MNT_EXPORTED) {
- vput(vp);
- return (EPERM);
- }
- SCARG(uap, flags) |= MNT_NOSUID | MNT_NODEV;
- }
if ((error = vinvalbuf(vp, V_SAVE, p->p_ucred, p, 0, 0)) != 0)
return (error);
if (vp->v_type != VDIR) {
@@ -639,7 +629,7 @@ statfs(p, uap)
if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- if (p->p_ucred->cr_uid != 0) {
+ if (suser(p->p_ucred, (u_short *)NULL)) {
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
sp = &sb;
@@ -679,7 +669,7 @@ fstatfs(p, uap)
if (error)
return (error);
sp->f_flags = mp->mnt_flag & MNT_VISFLAGMASK;
- if (p->p_ucred->cr_uid != 0) {
+ if (suser(p->p_ucred, (u_short *)NULL)) {
bcopy((caddr_t)sp, (caddr_t)&sb, sizeof(sb));
sb.f_fsid.val[0] = sb.f_fsid.val[1] = 0;
sp = &sb;
OpenPOWER on IntegriCloud