ACL related changes
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 17 Dec 2010 23:21:18 +0000 (15:21 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 10 Feb 2011 17:26:26 +0000 (09:26 -0800)
A small collection of ACL related changes related to not
supporting fuid mapping.  This whole are will need to be
closely investigated.

include/sys/zfs_fuid.h
module/zfs/zfs_acl.c
module/zfs/zfs_fuid.c

index d2989c8..91650a2 100644 (file)
@@ -99,7 +99,6 @@ typedef struct zfs_fuid_info {
 } zfs_fuid_info_t;
 
 #ifdef _KERNEL
-#ifdef HAVE_ZPL
 struct znode;
 extern uid_t zfs_fuid_map_id(zfsvfs_t *, uint64_t, cred_t *, zfs_fuid_type_t);
 extern void zfs_fuid_node_add(zfs_fuid_info_t **, const char *, uint32_t,
@@ -119,7 +118,6 @@ extern int zfs_fuid_find_by_domain(zfsvfs_t *, const char *domain,
     char **retdomain, boolean_t addok);
 extern const char *zfs_fuid_find_by_idx(zfsvfs_t *zfsvfs, uint32_t idx);
 extern void zfs_fuid_txhold(zfsvfs_t *zfsvfs, dmu_tx_t *tx);
-#endif /* HAVE_ZPL */
 #endif
 
 char *zfs_fuid_idx_domain(avl_tree_t *, uint32_t);
index ea209ba..45ec206 100644 (file)
@@ -22,7 +22,6 @@
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  */
 
-#ifdef HAVE_ZPL
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -1726,7 +1725,9 @@ zfs_acl_ids_create(znode_t *dzp, int flag, vattr_t *vap, cred_t *cr,
        int             error;
        zfsvfs_t        *zfsvfs = dzp->z_zfsvfs;
        zfs_acl_t       *paclp;
+#ifdef HAVE_KSID
        gid_t           gid;
+#endif /* HAVE_KSID */
        boolean_t       need_chmod = B_TRUE;
        boolean_t       inherited = B_FALSE;
 
@@ -1737,6 +1738,10 @@ zfs_acl_ids_create(znode_t *dzp, int flag, vattr_t *vap, cred_t *cr,
                if ((error = zfs_vsec_2_aclp(zfsvfs, vap->va_type, vsecp, cr,
                    &acl_ids->z_fuidp, &acl_ids->z_aclp)) != 0)
                        return (error);
+
+       acl_ids->z_fuid = vap->va_uid;
+       acl_ids->z_fgid = vap->va_gid;
+#ifdef HAVE_KSID
        /*
         * Determine uid and gid.
         */
@@ -1790,6 +1795,7 @@ zfs_acl_ids_create(znode_t *dzp, int flag, vattr_t *vap, cred_t *cr,
                        }
                }
        }
+#endif /* HAVE_KSID */
 
        /*
         * If we're creating a directory, and the parent directory has the
@@ -2793,5 +2799,3 @@ zfs_zaccess_rename(znode_t *sdzp, znode_t *szp, znode_t *tdzp,
 
        return (error);
 }
-
-#endif /* HAVE_ZPL */
index 97fceea..a574118 100644 (file)
@@ -192,7 +192,6 @@ zfs_fuid_idx_domain(avl_tree_t *idx_tree, uint32_t idx)
 }
 
 #ifdef _KERNEL
-#ifdef HAVE_ZPL
 /*
  * Load the fuid table(s) into memory.
  */
@@ -397,6 +396,7 @@ uid_t
 zfs_fuid_map_id(zfsvfs_t *zfsvfs, uint64_t fuid,
     cred_t *cr, zfs_fuid_type_t type)
 {
+#ifdef HAVE_KSID
        uint32_t index = FUID_INDEX(fuid);
        const char *domain;
        uid_t id;
@@ -415,6 +415,12 @@ zfs_fuid_map_id(zfsvfs_t *zfsvfs, uint64_t fuid,
                    FUID_RID(fuid), &id);
        }
        return (id);
+#else
+       if(type == ZFS_OWNER || type == ZFS_ACE_USER)
+               return (crgetuid(cr));
+       else
+               return (crgetgid(cr));
+#endif /* HAVE_KSID */
 }
 
 /*
@@ -483,6 +489,7 @@ zfs_fuid_node_add(zfs_fuid_info_t **fuidpp, const char *domain, uint32_t rid,
        }
 }
 
+#ifdef HAVE_KSID
 /*
  * Create a file system FUID, based on information in the users cred
  *
@@ -535,6 +542,7 @@ zfs_fuid_create_cred(zfsvfs_t *zfsvfs, zfs_fuid_type_t type,
 
        return (FUID_ENCODE(idx, rid));
 }
+#endif /* HAVE_KSID */
 
 /*
  * Create a file system FUID for an ACL ace
@@ -552,6 +560,7 @@ uint64_t
 zfs_fuid_create(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr,
     zfs_fuid_type_t type, zfs_fuid_info_t **fuidpp)
 {
+#ifdef HAVE_KSID
        const char *domain;
        char *kdomain;
        uint32_t fuid_idx = FUID_INDEX(id);
@@ -630,6 +639,12 @@ zfs_fuid_create(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr,
                kmem_free(zfuid, sizeof (zfs_fuid_t));
        }
        return (FUID_ENCODE(idx, rid));
+#else
+       if (type == ZFS_OWNER)
+               return crgetuid(cr);
+       else
+               return crgetgid(cr);
+#endif
 }
 
 void
@@ -697,6 +712,7 @@ zfs_fuid_info_free(zfs_fuid_info_t *fuidp)
 boolean_t
 zfs_groupmember(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr)
 {
+#ifdef HAVE_KSID
        ksid_t          *ksid = crgetsid(cr, KSID_GROUP);
        ksidlist_t      *ksidlist = crgetsidlist(cr);
        uid_t           gid;
@@ -738,6 +754,9 @@ zfs_groupmember(zfsvfs_t *zfsvfs, uint64_t id, cred_t *cr)
         */
        gid = zfs_fuid_map_id(zfsvfs, id, cr, ZFS_GROUP);
        return (groupmember(gid, cr));
+#else
+       return (B_TRUE);
+#endif
 }
 
 void
@@ -754,5 +773,4 @@ zfs_fuid_txhold(zfsvfs_t *zfsvfs, dmu_tx_t *tx)
                    FUID_SIZE_ESTIMATE(zfsvfs));
        }
 }
-#endif /* HAVE_ZPL */
 #endif