SCCS-vsn: sys/ufs/ffs/ffs_vfsops.c 8.11
*
* %sccs.include.redist.c%
*
*
* %sccs.include.redist.c%
*
- * @(#)ffs_vfsops.c 8.10 (Berkeley) %G%
+ * @(#)ffs_vfsops.c 8.11 (Berkeley) %G%
*/
#include <sys/param.h>
*/
#include <sys/param.h>
register struct fs *fs;
u_int size;
int error, flags;
register struct fs *fs;
u_int size;
int error, flags;
if (error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args)))
return (error);
if (error = copyin(data, (caddr_t)&args, sizeof (struct ufs_args)))
return (error);
error = ffs_reload(mp, ndp->ni_cnd.cn_cred, p);
if (error)
return (error);
error = ffs_reload(mp, ndp->ni_cnd.cn_cred, p);
if (error)
return (error);
- if (fs->fs_ronly && (mp->mnt_flag & MNT_WANTRDWR))
+ if (fs->fs_ronly && (mp->mnt_flag & MNT_WANTRDWR)) {
+ /*
+ * If upgrade to read-write by non-root, then verify
+ * that user has necessary permissions on the device.
+ */
+ if (p->p_ucred->cr_uid != 0) {
+ devvp = ump->um_devvp;
+ VOP_LOCK(devvp);
+ if (error = VOP_ACCESS(devvp, VREAD | VWRITE,
+ p->p_ucred, p)) {
+ VOP_UNLOCK(devvp);
+ return (error);
+ }
+ VOP_UNLOCK(devvp);
+ }
if (args.fspec == 0) {
/*
* Process export requests.
if (args.fspec == 0) {
/*
* Process export requests.
vrele(devvp);
return (ENXIO);
}
vrele(devvp);
return (ENXIO);
}
+ /*
+ * If mount by non-root, then verify that user has necessary
+ * permissions on the device.
+ */
+ if (p->p_ucred->cr_uid != 0) {
+ accessmode = VREAD;
+ if ((mp->mnt_flag & MNT_RDONLY) == 0)
+ accessmode |= VWRITE;
+ VOP_LOCK(devvp);
+ if (error = VOP_ACCESS(devvp, accessmode, p->p_ucred, p)) {
+ vput(devvp);
+ return (error);
+ }
+ VOP_UNLOCK(devvp);
+ }
if ((mp->mnt_flag & MNT_UPDATE) == 0)
error = ffs_mountfs(devvp, mp, p);
else {
if ((mp->mnt_flag & MNT_UPDATE) == 0)
error = ffs_mountfs(devvp, mp, p);
else {