priv: Sync ext2_quotactl() with ufs_quotactl() implementation
authorMichael Neumann <mneumann@ntecs.de>
Sun, 12 Jul 2009 20:59:09 +0000 (22:59 +0200)
committerMichael Neumann <mneumann@ntecs.de>
Sun, 12 Jul 2009 20:59:09 +0000 (22:59 +0200)
sys/vfs/gnu/ext2fs/ext2_vfsops.c

index 436736c..e440780 100644 (file)
@@ -161,20 +161,48 @@ ext2_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
                                return (EINVAL);
                }
        }
-                                       
+
+       /*
+        * Check permissions.
+        */
        switch (cmd) {
-       case Q_SYNC:
+
+       case Q_QUOTAON:
+               error = priv_check_cred(cred, PRIV_UFS_QUOTAON, 0);
+               break;
+
+       case Q_QUOTAOFF:
+               error = priv_check_cred(cred, PRIV_UFS_QUOTAOFF, 0);
+               break;
+
+       case Q_SETQUOTA:
+               error = priv_check_cred(cred, PRIV_VFS_SETQUOTA, 0);
                break;
+
+       case Q_SETUSE:
+               error = priv_check_cred(cred, PRIV_UFS_SETUSE, 0);
+               break;
+
        case Q_GETQUOTA:
                if (uid == cred->cr_ruid)
-                       break;
-               /* fall through */
+                       error = 0;
+               else
+                       error = priv_check_cred(cred, PRIV_VFS_GETQUOTA, 0);
+               break;
+
+       case Q_SYNC:
+               error = 0;
+               break;
+
        default:
-               if ((error = priv_check_cred(cred, PRIV_ROOT, PRISON_ROOT)) != 0)
-                       return (error);
+               error = EINVAL;
+               break;
        }
 
-       type = cmds & SUBCMDMASK;
+       if (error)
+               return (error);
+
+
        if ((uint)type >= MAXQUOTAS)
                return (EINVAL);
        if (vfs_busy(mp, LK_NOWAIT))