summaryrefslogtreecommitdiffstats
path: root/sys/kern/vfs_mount.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2002-08-19 06:52:21 +0000
committerphk <phk@FreeBSD.org>2002-08-19 06:52:21 +0000
commit8346c2fde3e084def3fc0de74bf98c5b2f0f0198 (patch)
tree385a22aeef0039426b0158c0ccad32609b9687a7 /sys/kern/vfs_mount.c
parent7a01faeb986e02cda904c1b3b06dd18b9a262bb4 (diff)
downloadFreeBSD-src-8346c2fde3e084def3fc0de74bf98c5b2f0f0198.zip
FreeBSD-src-8346c2fde3e084def3fc0de74bf98c5b2f0f0198.tar.gz
Keep a copy of the credential used to mount filesystems around so
we can check and use it later on. Change the pieces of code which relied on mount->mnt_stat.f_owner to check which user mounted the filesystem. This became needed as the EA code needs to be able to allocate blocks for "system" EA users like ACLs. There seems to be some half-baked (probably only quarter- actually) notion that the superuser for a given filesystem is the user who mounted it, but this has far from been carried through. It is unclear if it should be. Sponsored by: DARPA & NAI Labs.
Diffstat (limited to 'sys/kern/vfs_mount.c')
-rw-r--r--sys/kern/vfs_mount.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index ee77f0b..38b9acd 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -527,7 +527,7 @@ vfs_nmount(td, fsflags, fsoptions)
* Only root, or the user that did the original mount is
* permitted to update it.
*/
- if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
+ if (mp->mnt_cred->cr_uid != td->td_ucred->cr_uid) {
error = suser(td);
if (error) {
vput(vp);
@@ -643,6 +643,7 @@ vfs_nmount(td, fsflags, fsoptions)
mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;
strncpy(mp->mnt_stat.f_fstypename, fstype, MFSNAMELEN);
mp->mnt_vnodecovered = vp;
+ mp->mnt_cred = crdup(td->td_ucred);
mp->mnt_stat.f_owner = td->td_ucred->cr_uid;
strncpy(mp->mnt_stat.f_mntonname, fspath, MNAMELEN);
mp->mnt_iosize_max = DFLTPHYS;
@@ -901,7 +902,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
* Only root, or the user that did the original mount is
* permitted to update it.
*/
- if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
+ if (mp->mnt_cred->cr_uid != td->td_ucred->cr_uid) {
error = suser(td);
if (error) {
vput(vp);
@@ -1010,6 +1011,7 @@ vfs_mount(td, fstype, fspath, fsflags, fsdata)
mp->mnt_flag |= vfsp->vfc_flags & MNT_VISFLAGMASK;
strncpy(mp->mnt_stat.f_fstypename, fstype, MFSNAMELEN);
mp->mnt_vnodecovered = vp;
+ mp->mnt_cred = crdup(td->td_ucred);
mp->mnt_stat.f_owner = td->td_ucred->cr_uid;
strncpy(mp->mnt_stat.f_mntonname, fspath, MNAMELEN);
mp->mnt_iosize_max = DFLTPHYS;
@@ -1210,7 +1212,7 @@ unmount(td, uap)
* Only root, or the user that did the original mount is
* permitted to unmount this filesystem.
*/
- if (mp->mnt_stat.f_owner != td->td_ucred->cr_uid) {
+ if (mp->mnt_cred->cr_uid != td->td_ucred->cr_uid) {
error = suser(td);
if (error) {
vput(vp);
@@ -1316,6 +1318,7 @@ dounmount(mp, flags, td)
wakeup(mp);
return (error);
}
+ crfree(mp->mnt_cred);
mtx_lock(&mountlist_mtx);
TAILQ_REMOVE(&mountlist, mp, mnt_list);
if ((coveredvp = mp->mnt_vnodecovered) != NULL)
@@ -1370,6 +1373,7 @@ vfs_rootmountalloc(fstypename, devname, mpp)
mp->mnt_op = vfsp->vfc_vfsops;
mp->mnt_flag = MNT_RDONLY;
mp->mnt_vnodecovered = NULLVP;
+ mp->mnt_cred = crdup(td->td_ucred);
vfsp->vfc_refcount++;
mp->mnt_iosize_max = DFLTPHYS;
mp->mnt_stat.f_type = vfsp->vfc_typenum;
OpenPOWER on IntegriCloud