1 Depends-On-Patch: acls.diff
3 After applying the above patch and this one, run these commands for a
7 ./configure --enable-acl-support
11 > Attached is a small patch which is meant to be applied to a copy of
12 > rsync which has already been patched with acl support (the acls.diff
13 > file in the patches folder). It allows the preservation of the delete,
14 > chmod, and chown bits which Adaptec has added to XFS on their SnapOS NAS
15 > units. This is nice for backing up files between different NAS units
16 > and preserving all of the Samba ACLs.
18 > I'm not sure how useful this patch will be because I'm not sure if any
19 > other NAS vendors have standardized on their extensions to POSIX ACLs to
20 > support Samba in the same manner that Adaptec has. FWIW, though, this
21 > will allow you to preserve acls when copying between different Adaptec
22 > based NAS units running SnapOS.
24 I (Wayne) tweaked the patch for style and to avoid using SMB_* constants
25 with literal values were needed.
29 @@ -30,9 +30,11 @@ extern int am_root;
31 extern int orig_umask;
33 +typedef unsigned short abits;
42 @@ -41,15 +43,15 @@ typedef struct {
46 -#define NO_ENTRY ((uchar)0x80)
47 +#define NO_ENTRY ((abits)0x8000)
51 /* These will be NO_ENTRY if there's no such entry. */
62 static const rsync_acl rsync_acl_initializer =
63 @@ -148,7 +150,7 @@ static BOOL unpack_smb_acl(rsync_acl *ra
64 rc = sys_acl_get_entry(sacl, SMB_ACL_NEXT_ENTRY, &entry)) {
65 SMB_ACL_TAG_T tag_type;
66 SMB_ACL_PERMSET_T permset;
72 @@ -162,6 +164,9 @@ static BOOL unpack_smb_acl(rsync_acl *ra
74 access = (sys_acl_get_perm(permset, SMB_ACL_READ) ? 4 : 0)
75 | (sys_acl_get_perm(permset, SMB_ACL_WRITE) ? 2 : 0)
76 + | (sys_acl_get_perm(permset, SMB_ACL_DELETE) ? 8 : 0)
77 + | (sys_acl_get_perm(permset, SMB_ACL_CHMOD) ? 16 : 0)
78 + | (sys_acl_get_perm(permset, SMB_ACL_CHOWN) ? 32 : 0)
79 | (sys_acl_get_perm(permset, SMB_ACL_EXECUTE) ? 1 : 0);
80 /* continue == done with entry; break == store in given idal */
82 @@ -559,13 +564,19 @@ static void expand_smb_acl_list(smb_acl_
83 #define COE(func,args) CALL_OR_ERROR(func,args,#func)
84 #define COE2(func,args) CALL_OR_ERROR(func,args,NULL)
86 -static int store_access_in_entry(uchar access, SMB_ACL_ENTRY_T entry)
87 +static int store_access_in_entry(abits access, SMB_ACL_ENTRY_T entry)
89 const char *errfun = NULL;
90 SMB_ACL_PERMSET_T permset;
92 COE( sys_acl_get_permset,(entry, &permset) );
93 COE( sys_acl_clear_perms,(permset) );
95 + COE( sys_acl_add_perm(permset, SMB_ACL_CHOWN) );
97 + COE( sys_acl_add_perm(permset, SMB_ACL_CHMOD) );
99 + COE( sys_acl_add_perm(permset, SMB_ACL_DELETE) );
101 COE( sys_acl_add_perm,(permset, SMB_ACL_READ) );
103 @@ -645,7 +656,7 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_
107 -static mode_t change_sacl_perms(SMB_ACL_T sacl, uchar mask, mode_t old_mode, mode_t mode)
108 +static mode_t change_sacl_perms(SMB_ACL_T sacl, abits mask, mode_t old_mode, mode_t mode)
110 SMB_ACL_ENTRY_T entry;
111 int group_id = mask != NO_ENTRY ? SMB_ACL_MASK : SMB_ACL_GROUP_OBJ;
112 @@ -696,7 +707,7 @@ static mode_t change_sacl_perms(SMB_ACL_
114 static void receive_rsync_acl(rsync_acl *racl, int f)
116 - uchar computed_mask_bits = 0;
117 + abits computed_mask_bits = 0;
118 ida_list *idal = NULL;
121 @@ -708,8 +719,8 @@ static void receive_rsync_acl(rsync_acl
124 char tag = read_byte(f);
125 - uchar access = read_byte(f);
126 - if (access & ~ (4 | 2 | 1)) {
127 + abits access = read_byte(f);
128 + if (access & ~(32 | 16 | 8 | 4 | 2 | 1)) {
129 rprintf(FERROR, "receive_rsync_acl: bogus permset %o\n",
131 exit_cleanup(RERR_STREAMIO);
135 #define SMB_ACL_READ ACL_READ
136 #define SMB_ACL_WRITE ACL_WRITE
137 #define SMB_ACL_EXECUTE ACL_EXECUTE
138 +/* These are custom ACL bits used by Adaptec's modifications
139 + * to XFS on their SnapOS units. */
140 +#define SMB_ACL_DELETE 0x08
141 +#define SMB_ACL_CHMOD 0x10
142 +#define SMB_ACL_CHOWN 0x20
145 #define SMB_ACL_USER ACL_USER