Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=1269bc69b6649282091bb7007372acf4ab8357fd
Commit:     1269bc69b6649282091bb7007372acf4ab8357fd
Parent:     9091224f3cff4721f295df29e8a99705a63bc4c7
Author:     J. Bruce Fields <[EMAIL PROTECTED]>
AuthorDate: Tue Jul 17 04:04:52 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Tue Jul 17 10:23:08 2007 -0700

    knfsd: nfsd: enforce per-flavor id squashing
    
    Allow root squashing to vary per-pseudoflavor, so that you can (for example)
    allow root access only when sufficiently strong security is in use.
    
    Signed-off-by: "J. Bruce Fields" <[EMAIL PROTECTED]>
    Signed-off-by: Neil Brown <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 fs/nfsd/auth.c              |   18 ++++++++++++++++--
 include/linux/nfsd/export.h |    3 ++-
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c
index 6e92b0f..cf61dc8 100644
--- a/fs/nfsd/auth.c
+++ b/fs/nfsd/auth.c
@@ -12,17 +12,31 @@
 
 #define        CAP_NFSD_MASK (CAP_FS_MASK|CAP_TO_MASK(CAP_SYS_RESOURCE))
 
+static int nfsexp_flags(struct svc_rqst *rqstp, struct svc_export *exp)
+{
+       struct exp_flavor_info *f;
+       struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors;
+
+       for (f = exp->ex_flavors; f < end; f++) {
+               if (f->pseudoflavor == rqstp->rq_flavor)
+                       return f->flags;
+       }
+       return exp->ex_flags;
+
+}
+
 int nfsd_setuser(struct svc_rqst *rqstp, struct svc_export *exp)
 {
        struct svc_cred cred = rqstp->rq_cred;
        int i;
+       int flags = nfsexp_flags(rqstp, exp);
        int ret;
 
-       if (exp->ex_flags & NFSEXP_ALLSQUASH) {
+       if (flags & NFSEXP_ALLSQUASH) {
                cred.cr_uid = exp->ex_anon_uid;
                cred.cr_gid = exp->ex_anon_gid;
                cred.cr_group_info = groups_alloc(0);
-       } else if (exp->ex_flags & NFSEXP_ROOTSQUASH) {
+       } else if (flags & NFSEXP_ROOTSQUASH) {
                struct group_info *gi;
                if (!cred.cr_uid)
                        cred.cr_uid = exp->ex_anon_uid;
diff --git a/include/linux/nfsd/export.h b/include/linux/nfsd/export.h
index a01f775..78feb7b 100644
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -43,7 +43,8 @@
 #define NFSEXP_ALLFLAGS                0xFE3F
 
 /* The flags that may vary depending on security flavor: */
-#define NFSEXP_SECINFO_FLAGS   0
+#define NFSEXP_SECINFO_FLAGS   (NFSEXP_READONLY | NFSEXP_ROOTSQUASH \
+                                       | NFSEXP_ALLSQUASH)
 
 #ifdef __KERNEL__
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to