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

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

diff -u --recursive --new-file v2.1.31/linux/fs/nfsd/auth.c linux/fs/nfsd/auth.c
@@ -0,0 +1,47 @@
+/*
+ * linux/fs/nfsd/auth.c
+ *
+ * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
+ */
+
+#include <linux/types.h>
+#include <linux/sched.h>
+#include <linux/sunrpc/svc.h>
+#include <linux/sunrpc/svcauth.h>
+#include <linux/nfsd/nfsd.h>
+
+void
+nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
+{
+	struct svc_cred	*cred = &rqstp->rq_cred;
+	int		i;
+
+	if (rqstp->rq_userset)
+		return;
+
+	if (exp->ex_flags & NFSEXP_ALLSQUASH) {
+		cred->cr_uid = exp->ex_anon_uid;
+		cred->cr_gid = exp->ex_anon_gid;
+		cred->cr_groups[0] = NOGROUP;
+	} else if (exp->ex_flags & NFSEXP_ROOTSQUASH) {
+		if (!cred->cr_uid)
+			cred->cr_uid = exp->ex_anon_uid;
+		if (!cred->cr_gid)
+			cred->cr_gid = exp->ex_anon_gid;
+		for (i = 0; i < NGROUPS; i++)
+			if (!cred->cr_groups[i])
+				cred->cr_groups[i] = exp->ex_anon_gid;
+	}
+
+	if (cred->cr_uid != (uid_t) -1)
+		current->fsuid = cred->cr_uid;
+	else
+		current->fsuid = exp->ex_anon_uid;
+	if (cred->cr_gid != (gid_t) -1)
+		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];
+	rqstp->rq_userset = 1;
+}

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