patch-2.1.127 linux/fs/nfsd/auth.c

Next file: linux/fs/nfsd/export.c
Previous file: linux/fs/nfs/inode.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.126/linux/fs/nfsd/auth.c linux/fs/nfsd/auth.c
@@ -41,7 +41,21 @@
 		current->fsgid = cred->cr_gid;
 	else
 		current->fsgid = exp->ex_anon_gid;
-	for (i = 0; i < NGROUPS; i++)
-		current->groups[i] = cred->cr_groups[i];
+	for (i = 0; i < NGROUPS; i++) {
+		gid_t group = cred->cr_groups[i];
+		if (group == (gid_t) NOGROUP)
+			break;
+		current->groups[i] = group;
+	}
+	current->ngroups = i;
+
+	if ((cred->cr_uid)) {
+		cap_lower(current->cap_effective, CAP_DAC_OVERRIDE);
+		cap_lower(current->cap_effective, CAP_DAC_READ_SEARCH);
+	} else {
+		cap_raise(current->cap_effective, CAP_DAC_OVERRIDE);
+		cap_raise(current->cap_effective, CAP_DAC_READ_SEARCH);
+	}
+
 	rqstp->rq_userset = 1;
 }

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov