From af7d91375c21d5055af5fd0467d1d5b5dbd3300f Mon Sep 17 00:00:00 2001 From: Hiten Pandya Date: Thu, 3 Jun 2004 15:40:22 +0000 Subject: [PATCH] Quotactl(2) should set the uid correctly, based on the QUOTA type supplied. Previously, it would set the uid to p->p_ucred->cr_ruid unconditionally without checking if the QUOTA type is GRPQUOTA or USRQUOTA; thus allowing a user with UID X to access the groupquota of gid X. Inspired-by: PR# 33940 (by Vladimir B. Grebenschikov) [FreeBSD GNATS] --- sys/vfs/ufs/ufs_vfsops.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/sys/vfs/ufs/ufs_vfsops.c b/sys/vfs/ufs/ufs_vfsops.c index 92e222b8fc..52231c81e0 100644 --- a/sys/vfs/ufs/ufs_vfsops.c +++ b/sys/vfs/ufs/ufs_vfsops.c @@ -37,7 +37,7 @@ * * @(#)ufs_vfsops.c 8.8 (Berkeley) 5/20/95 * $FreeBSD: src/sys/ufs/ufs/ufs_vfsops.c,v 1.17.2.3 2001/10/14 19:08:16 iedowse Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_vfsops.c,v 1.7 2004/05/18 00:16:46 cpressey Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_vfsops.c,v 1.8 2004/06/03 15:40:22 hmp Exp $ */ #include "opt_quota.h" @@ -98,10 +98,22 @@ ufs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg, if (p == NULL) return (EOPNOTSUPP); - if (uid == -1) - uid = p->p_ucred->cr_ruid; + type = cmds & SUBCMDMASK; cmd = cmds >> SUBCMDSHIFT; + if (uid == -1) { + switch(type) { + case USRQUOTA: + uid = p->p_ucred->cr_ruid; + break; + case GRPQUOTA: + uid = p->p_ucred->cr_rgid; + break; + default: + return (EINVAL); + } + } + switch (cmd) { case Q_SYNC: break; -- 2.32.0