From d38328008c1e3e2445c89d9a9a6af2c1333377a3 Mon Sep 17 00:00:00 2001 From: Wayne Davison Date: Mon, 20 Mar 2006 18:01:57 +0000 Subject: [PATCH] This is a better version for the updated acls.diff patch than what I had created before. --- adaptec_acl_mods.diff | 125 +++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 70 deletions(-) diff --git a/adaptec_acl_mods.diff b/adaptec_acl_mods.diff index f9988e7..cfc0c28 100644 --- a/adaptec_acl_mods.diff +++ b/adaptec_acl_mods.diff @@ -24,52 +24,29 @@ Philip Lowman wrote: I (Wayne) tweaked the patch for style and to avoid using SMB_* constants with literal values were needed. +I've also updated it to apply to the updated version of the acls.diff, +though I don't know if there might be some bits lost in the current +algorithm when using the file's mode bits to reconstruct a stripped ACL +entry. + --- old/acls.c +++ new/acls.c -@@ -30,9 +30,11 @@ extern int am_root; - extern int dry_run; - extern int orig_umask; - -+typedef unsigned short abits; -+ - typedef struct { - id_t id; -- uchar access; -+ abits access; - } id_access; +@@ -84,10 +84,10 @@ static int calc_sacl_entries(const rsync - typedef struct { -@@ -41,15 +43,15 @@ typedef struct { - id_access *idas; - } ida_list; - --#define NO_ENTRY ((uchar)0x80) -+#define NO_ENTRY ((abits)0x8000) - typedef struct { - ida_list users; - ida_list groups; - /* These will be NO_ENTRY if there's no such entry. */ -- uchar user_obj; -- uchar group_obj; -- uchar mask; -- uchar other; -+ abits user_obj; -+ abits group_obj; -+ abits mask; -+ abits other; - } rsync_acl; + static int rsync_acl_get_perms(const rsync_acl *racl) + { +- /* Note that (ACL_NO_ENTRY & 7) is 0. */ +- return ((racl->user_obj & 7) << 6) +- + (((racl->mask != ACL_NO_ENTRY ? racl->mask : racl->group_obj) & 7) << 3) +- + (racl->other & 7); ++ /* Note that (ACL_NO_ENTRY & 077) is 0. */ ++ return ((racl->user_obj & 077) << 6) ++ + (((racl->mask != ACL_NO_ENTRY ? racl->mask : racl->group_obj) & 077) << 3) ++ + (racl->other & 077); + } - static const rsync_acl rsync_acl_initializer = -@@ -148,7 +150,7 @@ static BOOL unpack_smb_acl(rsync_acl *ra - rc = sys_acl_get_entry(sacl, SMB_ACL_NEXT_ENTRY, &entry)) { - SMB_ACL_TAG_T tag_type; - SMB_ACL_PERMSET_T permset; -- uchar access; -+ abits access; - void *qualifier; - id_access *ida; - ida_list *idal; -@@ -162,6 +164,9 @@ static BOOL unpack_smb_acl(rsync_acl *ra + static void rsync_acl_strip_perms(rsync_acl *racl) +@@ -178,6 +178,9 @@ static BOOL unpack_smb_acl(rsync_acl *ra } access = (sys_acl_get_perm(permset, SMB_ACL_READ) ? 4 : 0) | (sys_acl_get_perm(permset, SMB_ACL_WRITE) ? 2 : 0) @@ -79,15 +56,7 @@ with literal values were needed. | (sys_acl_get_perm(permset, SMB_ACL_EXECUTE) ? 1 : 0); /* continue == done with entry; break == store in given idal */ switch (tag_type) { -@@ -559,13 +564,19 @@ static void expand_smb_acl_list(smb_acl_ - #define COE(func,args) CALL_OR_ERROR(func,args,#func) - #define COE2(func,args) CALL_OR_ERROR(func,args,NULL) - --static int store_access_in_entry(uchar access, SMB_ACL_ENTRY_T entry) -+static int store_access_in_entry(abits access, SMB_ACL_ENTRY_T entry) - { - const char *errfun = NULL; - SMB_ACL_PERMSET_T permset; +@@ -588,6 +591,12 @@ static int store_access_in_entry(uchar a COE( sys_acl_get_permset,(entry, &permset) ); COE( sys_acl_clear_perms,(permset) ); @@ -100,35 +69,51 @@ with literal values were needed. if (access & 4) COE( sys_acl_add_perm,(permset, SMB_ACL_READ) ); if (access & 2) -@@ -645,7 +656,7 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_ - return False; - } +@@ -620,7 +629,7 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_ --static mode_t change_sacl_perms(SMB_ACL_T sacl, uchar mask, mode_t old_mode, mode_t mode) -+static mode_t change_sacl_perms(SMB_ACL_T sacl, abits mask, mode_t old_mode, mode_t mode) - { - SMB_ACL_ENTRY_T entry; - int group_id = mask != NO_ENTRY ? SMB_ACL_MASK : SMB_ACL_GROUP_OBJ; -@@ -696,7 +707,7 @@ static mode_t change_sacl_perms(SMB_ACL_ + COE( sys_acl_create_entry,(smb_acl, &entry) ); + COE( sys_acl_set_tag_type,(entry, SMB_ACL_USER_OBJ) ); +- COE2( store_access_in_entry,(racl->user_obj & 7, entry) ); ++ COE2( store_access_in_entry,(racl->user_obj & 077, entry) ); - static void receive_rsync_acl(rsync_acl *racl, int f) - { -- uchar computed_mask_bits = 0; -+ abits computed_mask_bits = 0; - ida_list *idal = NULL; - id_access *ida; - size_t count; -@@ -708,8 +719,8 @@ static void receive_rsync_acl(rsync_acl + for (ida = racl->users.idas, count = racl->users.count; + count--; ida++) { +@@ -632,7 +641,7 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_ + + COE( sys_acl_create_entry,(smb_acl, &entry) ); + COE( sys_acl_set_tag_type,(entry, SMB_ACL_GROUP_OBJ) ); +- COE2( store_access_in_entry,(racl->group_obj & 7, entry) ); ++ COE2( store_access_in_entry,(racl->group_obj & 077, entry) ); + + for (ida = racl->groups.idas, count = racl->groups.count; + count--; ida++) { +@@ -653,7 +662,7 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_ + COE( sys_acl_create_entry,(smb_acl, &entry) ); + COE( sys_acl_set_tag_type,(entry, SMB_ACL_OTHER) ); +- COE2( store_access_in_entry,(racl->other & 7, entry) ); ++ COE2( store_access_in_entry,(racl->other & 077, entry) ); + + #ifdef DEBUG + if (sys_acl_valid(*smb_acl) < 0) +@@ -762,7 +771,7 @@ static void receive_rsync_acl(rsync_acl while (count--) { char tag = read_byte(f); -- uchar access = read_byte(f); + uchar access = read_byte(f); - if (access & ~ (4 | 2 | 1)) { -+ abits access = read_byte(f); + if (access & ~(32 | 16 | 8 | 4 | 2 | 1)) { rprintf(FERROR, "receive_rsync_acl: bogus permset %o\n", access); exit_cleanup(RERR_STREAMIO); +@@ -835,7 +844,7 @@ static void receive_rsync_acl(rsync_acl + } else + #endif + if (racl->mask == ACL_NO_ENTRY) /* always made non-empty when needed */ +- racl->mask = computed_mask_bits | (racl->group_obj & 7); ++ racl->mask = computed_mask_bits | (racl->group_obj & 077); + } + + /* receive and build the rsync_acl_lists */ --- old/smb_acls.h +++ new/smb_acls.h @@ -33,6 +33,11 @@ -- 2.34.1