diff options
-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 *); |