diff options
author | alfred <alfred@FreeBSD.org> | 2004-07-06 09:37:43 +0000 |
---|---|---|
committer | alfred <alfred@FreeBSD.org> | 2004-07-06 09:37:43 +0000 |
commit | e0a5f530c25100eec4a2a3dfa0ac270bdff214b7 (patch) | |
tree | e93dde14927121ca1d0c3f76398b80469bde2cfd /sys | |
parent | 8fd8b8c57fb214d5cdc0aeaed49ca85a702f1507 (diff) | |
download | FreeBSD-src-e0a5f530c25100eec4a2a3dfa0ac270bdff214b7.zip FreeBSD-src-e0a5f530c25100eec4a2a3dfa0ac270bdff214b7.tar.gz |
Introduce vfs_suser(), used to test if a user should have special privs
for a mount.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/vfs_subr.c | 16 | ||||
-rw-r--r-- | sys/sys/mount.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 1c7a7fb..40b564c 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -358,6 +358,22 @@ vfs_getvfs(fsid) } /* + * Check if a user can access priveledged mount options. + */ +int +vfs_suser(struct mount *mp, struct thread *td) +{ + int error; + + if ((mp->mnt_flag & MNT_USER) == 0 || + mp->mnt_cred->cr_uid != td->td_ucred->cr_uid) { + if ((error = suser(td)) != 0) + return (error); + } + return (0); +} + +/* * Get a new unique fsid. Try to make its val[0] unique, since this value * will be used to create fake device numbers for stat(). Also try (but * not so hard) make its val[0] unique mod 2^16, since some emulators only diff --git a/sys/sys/mount.h b/sys/sys/mount.h index 9e3afe6..3f8f098 100644 --- a/sys/sys/mount.h +++ b/sys/sys/mount.h @@ -578,6 +578,7 @@ int vfs_mountedon(struct vnode *); /* is a vfs mounted on vp */ void vfs_mountroot(void); /* mount our root filesystem */ int vfs_rootmountalloc(char *, char *, struct mount **); void vfs_mount_destroy(struct mount *, struct thread *); +int vfs_suser(struct mount *, struct thread *); void vfs_unbusy(struct mount *, struct thread *); void vfs_unmountall(void); int vfs_register(struct vfsconf *); |