--- old/acls.c
+++ new/acls.c
-@@ -89,6 +89,18 @@ static const char *str_acl_type(SMB_ACL_
+@@ -98,6 +98,18 @@ static const char *str_acl_type(SMB_ACL_
: "unknown SMB_ACL_TYPE_T";
}
+
+static int old_count_racl_entries(const rsync_acl *racl)
+{
-+ return racl->users.count + racl->groups.count
++ return racl->names.count
+ + (racl->user_obj != NO_ENTRY)
+ + (racl->group_obj != NO_ENTRY)
+ + (racl->mask_obj != NO_ENTRY)
static int calc_sacl_entries(const rsync_acl *racl)
{
/* A System ACL always gets user/group/other permission entries. */
-@@ -544,6 +556,91 @@ int get_acl(const char *fname, statx *sx
+@@ -522,6 +534,96 @@ int get_acl(const char *fname, statx *sx
return 0;
}
+ id_access *ida;
+ size_t count = idal->count;
+ for (ida = idal->idas; count--; ida++) {
++ if (tag_char == 'U') {
++ if (!(ida->access & NAME_IS_USER))
++ continue;
++ add_uid(ida->id);
++ } else {
++ if (ida->access & NAME_IS_USER)
++ continue;
++ add_gid(ida->id);
++ }
+ write_byte(f, tag_char);
+ write_byte(f, ida->access);
+ write_int(f, ida->id);
-+ if (tag_char == 'U')
-+ add_uid(ida->id);
-+ else
-+ add_gid(ida->id);
+ }
+}
+
+ write_byte(f, 'u');
+ write_byte(f, racl->user_obj);
+ }
-+ old_send_ida_entries(f, &racl->users, 'U');
++ old_send_ida_entries(f, &racl->names, 'U');
+ if (racl->group_obj != NO_ENTRY) {
+ write_byte(f, 'g');
+ write_byte(f, racl->group_obj);
+ }
-+ old_send_ida_entries(f, &racl->groups, 'G');
++ old_send_ida_entries(f, &racl->names, 'G');
+ if (racl->mask_obj != NO_ENTRY) {
+ write_byte(f, 'm');
+ write_byte(f, racl->mask_obj);
/* === Send functions === */
/* The general strategy with the tag_type <-> character mapping is that
-@@ -630,6 +727,11 @@ static void send_rsync_acl(rsync_acl *ra
+@@ -604,6 +706,11 @@ static void send_rsync_acl(rsync_acl *ra
* This also frees the ACL data. */
void send_acl(statx *sxp, int f)
{
if (!sxp->acc_acl) {
sxp->acc_acl = create_racl();
rsync_acl_fake_perms(sxp->acc_acl, sxp->st.st_mode);
-@@ -647,6 +749,146 @@ void send_acl(statx *sxp, int f)
+@@ -621,6 +728,160 @@ void send_acl(statx *sxp, int f)
}
}
+static void old_recv_rsync_acl(rsync_acl *racl, int f)
+{
+ static item_list temp_ida_list = EMPTY_ITEM_LIST;
-+ SMB_ACL_TAG_T tag_type = 0, prior_list_type = 0;
++ SMB_ACL_TAG_T tag_type = 0;
+ uchar computed_mask_bits = 0;
+ id_access *ida;
+ size_t count;
+ tag);
+ exit_cleanup(RERR_STREAMIO);
+ }
-+ if (tag_type != prior_list_type) {
-+ if (prior_list_type)
-+ save_idas(racl, prior_list_type, &temp_ida_list);
-+ prior_list_type = tag_type;
-+ }
+ ida = EXPAND_ITEM_LIST(&temp_ida_list, id_access, -10);
-+ ida->access = access;
++ ida->access = access | (tag_type == SMB_ACL_USER ? NAME_IS_USER : 0);
+ ida->id = read_int(f);
+ computed_mask_bits |= access;
+ }
-+ if (prior_list_type)
-+ save_idas(racl, prior_list_type, &temp_ida_list);
+
-+ if (!racl->users.count && !racl->groups.count) {
++ /* Transfer the count id_access items out of the temp_ida_list
++ * into the names ida_entries list in racl. */
++ if (temp_ida_list.count) {
++#ifdef SMB_ACL_NEED_SORT
++ if (temp_ida_list.count > 1) {
++ qsort(temp_ida_list.items, temp_ida_list.count,
++ sizeof (id_access), id_access_sorter);
++ }
++#endif
++ if (!(racl->names.idas = new_array(id_access, temp_ida_list.count)))
++ out_of_memory("unpack_smb_acl");
++ memcpy(racl->names.idas, temp_ida_list.items,
++ temp_ida_list.count * sizeof (id_access));
++ } else
++ racl->names.idas = NULL;
++
++ racl->names.count = temp_ida_list.count;
++
++ /* Truncate the temporary list now that its idas have been saved. */
++ temp_ida_list.count = 0;
++
++ if (!racl->names.count) {
+ /* If we received a superfluous mask, throw it away. */
+ if (racl->mask_obj != NO_ENTRY) {
+ /* Mask off the group perms with it first. */
+ racl->mask_obj = NO_ENTRY;
+ }
+ } else if (racl->mask_obj == NO_ENTRY) /* Must be non-empty with lists. */
-+ racl->mask_obj = computed_mask_bits | (racl->group_obj & 7);
++ racl->mask_obj = (computed_mask_bits | racl->group_obj) & 7;
+}
+
+/* Receive the ACL info the sender has included for this file-list entry. */
+
/* === Receive functions === */
- static uchar recv_acl_access(uchar *name_follows_val, int f)
-@@ -766,6 +1008,11 @@ static int recv_rsync_acl(item_list *rac
+ static uint32 recv_acl_access(uchar *name_follows_ptr, int f)
+@@ -738,6 +999,11 @@ static int recv_rsync_acl(item_list *rac
/* Receive the ACL info the sender has included for this file-list entry. */
void receive_acl(struct file_struct *file, int f)
{
if (S_ISDIR(file->mode))
--- old/compat.c
+++ new/compat.c
-@@ -115,13 +115,6 @@ void setup_protocol(int f_out,int f_in)
- protocol_version);
- exit_cleanup(RERR_PROTOCOL);
- }
+@@ -148,13 +148,6 @@ void setup_protocol(int f_out,int f_in)
+ if (protocol_version < 30) {
+ if (append_mode == 1)
+ append_mode = 2;
- if (preserve_acls && !local_server) {
- rprintf(FERROR,
- "--acls requires protocol 30 or higher"