Commit | Line | Data |
---|---|---|
af7ee4d8 WD |
1 | Depends-On-Patch: acls.diff |
2 | ||
3 | Philip Lowman wrote: | |
4 | > Attached is a small patch which is meant to be applied to a copy of | |
5 | > rsync which has already been patched with acl support (the acls.diff | |
6 | > file in the patches folder). It allows the preservation of the delete, | |
7 | > chmod, and chown bits which Adaptec has added to XFS on their SnapOS NAS | |
8 | > units. This is nice for backing up files between different NAS units | |
9 | > and preserving all of the Samba ACLs. | |
10 | > | |
11 | > I'm not sure how useful this patch will be because I'm not sure if any | |
12 | > other NAS vendors have standardized on their extensions to POSIX ACLs to | |
13 | > support Samba in the same manner that Adaptec has. FWIW, though, this | |
14 | > will allow you to preserve acls when copying between different Adaptec | |
15 | > based NAS units running SnapOS. | |
16 | ||
17 | I (Wayne) tweaked the patch for style and to avoid using SMB_* constants | |
18 | with literal values were needed. | |
19 | ||
20 | --- old/acls.c | |
21 | +++ new/acls.c | |
22 | @@ -146,6 +146,9 @@ static BOOL unpack_smb_acl(rsync_acl *ra | |
23 | } | |
24 | race->access = (sys_acl_get_perm(permset, SMB_ACL_READ) ? 4 : 0) | |
25 | | (sys_acl_get_perm(permset, SMB_ACL_WRITE) ? 2 : 0) | |
26 | + | (sys_acl_get_perm(permset, SMB_ACL_DELETE) ? 8 : 0) | |
27 | + | (sys_acl_get_perm(permset, SMB_ACL_CHMOD) ? 16 : 0) | |
28 | + | (sys_acl_get_perm(permset, SMB_ACL_CHOWN) ? 32 : 0) | |
29 | | (sys_acl_get_perm(permset, SMB_ACL_EXECUTE) ? 1 : 0); | |
30 | switch (race->tag_type) { | |
31 | case SMB_ACL_USER: | |
32 | @@ -575,6 +578,21 @@ static BOOL pack_smb_acl(SMB_ACL_T *smb_ | |
33 | errfun = "sys_acl_add_perm"; | |
34 | break; | |
35 | } | |
36 | + if (race->access & 8) | |
37 | + if (sys_acl_add_perm(permset, SMB_ACL_DELETE)) { | |
38 | + errfun = "sys_acl_add_perm"; | |
39 | + break; | |
40 | + } | |
41 | + if (race->access & 16) | |
42 | + if (sys_acl_add_perm(permset, SMB_ACL_CHMOD)) { | |
43 | + errfun = "sys_acl_add_perm"; | |
44 | + break; | |
45 | + } | |
46 | + if (race->access & 32) | |
47 | + if (sys_acl_add_perm(permset, SMB_ACL_CHOWN)) { | |
48 | + errfun = "sys_acl_add_perm"; | |
49 | + break; | |
50 | + } | |
51 | if (sys_acl_set_permset(entry, permset)) { | |
52 | errfun = "sys_acl_set_permset"; | |
53 | break; | |
54 | @@ -634,7 +652,7 @@ static void receive_rsync_acl(rsync_acl | |
55 | exit_cleanup(RERR_STREAMIO); | |
56 | } | |
57 | race->access = read_byte(f); | |
58 | - if (race->access & ~ (4 | 2 | 1)) { | |
59 | + if (race->access & ~(32 | 16 | 8 | 4 | 2 | 1)) { | |
60 | rprintf(FERROR, "receive_rsync_acl: bogus permset %o\n", | |
61 | race->access); | |
62 | exit_cleanup(RERR_STREAMIO); | |
63 | --- old/smb_acls.h | |
64 | +++ new/smb_acls.h | |
65 | @@ -33,6 +33,11 @@ | |
66 | #define SMB_ACL_READ ACL_READ | |
67 | #define SMB_ACL_WRITE ACL_WRITE | |
68 | #define SMB_ACL_EXECUTE ACL_EXECUTE | |
69 | +/* These are custom ACL bits used by Adaptec's modifications | |
70 | + * to XFS on their SnapOS units. */ | |
71 | +#define SMB_ACL_DELETE 0x08 | |
72 | +#define SMB_ACL_CHMOD 0x10 | |
73 | +#define SMB_ACL_CHOWN 0x20 | |
74 | ||
75 | /* Types of ACLs. */ | |
76 | #define SMB_ACL_USER ACL_USER |