nfsd: allow exports of symlinks
[safe/jmp/linux-2.6] / fs / nfsd / auth.c
index 0184fe9..71209d4 100644 (file)
@@ -4,12 +4,8 @@
  * 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>
-#include <linux/nfsd/export.h>
+#include "nfsd.h"
 #include "auth.h"
 
 int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
@@ -34,6 +30,8 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
        int flags = nfsexp_flags(rqstp, exp);
        int ret;
 
+       validate_process_creds();
+
        /* discard any old override before preparing the new set */
        revert_creds(get_cred(current->real_cred));
        new = prepare_creds();
@@ -49,6 +47,8 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
                new->fsuid = exp->ex_anon_uid;
                new->fsgid = exp->ex_anon_gid;
                gi = groups_alloc(0);
+               if (!gi)
+                       goto oom;
        } else if (flags & NFSEXP_ROOTSQUASH) {
                if (!new->fsuid)
                        new->fsuid = exp->ex_anon_uid;
@@ -76,15 +76,18 @@ int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
 
        ret = set_groups(new, gi);
        put_group_info(gi);
-       if (!ret)
+       if (ret < 0)
                goto error;
 
-       if (new->uid)
+       if (new->fsuid)
                new->cap_effective = cap_drop_nfsd_set(new->cap_effective);
        else
                new->cap_effective = cap_raise_nfsd_set(new->cap_effective,
                                                        new->cap_permitted);
+       validate_process_creds();
        put_cred(override_creds(new));
+       put_cred(new);
+       validate_process_creds();
        return 0;
 
 oom: