Got rid of the extra file-list int32 index vars on the sending side.
[rsync/rsync-patches.git] / acls.diff
index 7204134..cf94a56 100644 (file)
--- a/acls.diff
+++ b/acls.diff
@@ -30,7 +30,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
  popt_OBJS=popt/findme.o  popt/popt.o  popt/poptconfig.o \
 --- old/acls.c
 +++ new/acls.c
-@@ -0,0 +1,1080 @@
+@@ -0,0 +1,1079 @@
 +/*
 + * Handle passing Access Control Lists between systems.
 + *
@@ -183,7 +183,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +      return True;
 +}
 +
-+static BOOL rsync_acls_equal(const rsync_acl *racl1, const rsync_acl *racl2)
++static BOOL rsync_acl_equal(const rsync_acl *racl1, const rsync_acl *racl2)
 +{
 +      return (racl1->user_obj == racl2->user_obj
 +           && racl1->group_obj == racl2->group_obj
@@ -198,8 +198,8 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 + * only meaningful for access ACLs!  Note: the 1st arg is a fully-populated
 + * rsync_acl, but the 2nd parameter can be a condensed rsync_acl, which means
 + * that it might have several of its perm objects set to NO_ENTRY. */
-+static BOOL rsync_acls_equal_enough(const rsync_acl *racl1,
-+                                  const rsync_acl *racl2, mode_t m)
++static BOOL rsync_acl_equal_enough(const rsync_acl *racl1,
++                                 const rsync_acl *racl2, mode_t m)
 +{
 +      if ((racl1->mask ^ racl2->mask) & NO_ENTRY)
 +              return False; /* One has a mask and the other doesn't */
@@ -229,7 +229,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +      *racl = empty_rsync_acl;
 +}
 +
-+void free_acls(statx *sxp)
++void free_acl(statx *sxp)
 +{
 +      if (sxp->acc_acl) {
 +              rsync_acl_free(sxp->acc_acl);
@@ -512,7 +512,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +              *match = racl_list->count - 1;
 +      while (count--) {
 +              rsync_acl *base = racl_list->items;
-+              if (rsync_acls_equal(base + *match, racl))
++              if (rsync_acl_equal(base + *match, racl))
 +                      return *match;
 +              if (!(*match)--)
 +                      *match = racl_list->count - 1;
@@ -524,7 +524,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +
 +/* Turn the ACL data in statx into cached ACL data, setting the index
 + * values in the file struct. */
-+void cache_acls(struct file_struct *file, statx *sxp)
++void cache_acl(struct file_struct *file, statx *sxp)
 +{
 +      SMB_ACL_TYPE_T type;
 +      rsync_acl *racl;
@@ -557,7 +557,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +}
 +
 +/* Return the ACL(s) for the given filename. */
-+int get_acls(const char *fname, statx *sxp)
++int get_acl(const char *fname, statx *sxp)
 +{
 +      SMB_ACL_TYPE_T type;
 +
@@ -570,7 +570,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +              rsync_acl *racl = new(rsync_acl);
 +
 +              if (!racl)
-+                      out_of_memory("get_acls");
++                      out_of_memory("get_acl");
 +              if (type == SMB_ACL_TYPE_ACCESS)
 +                      sxp->acc_acl = racl;
 +              else
@@ -581,7 +581,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +
 +                      sys_acl_free_acl(sacl);
 +                      if (!ok) {
-+                              free_acls(sxp);
++                              free_acl(sxp);
 +                              return -1;
 +                      }
 +              } else if (errno == ENOTSUP) {
@@ -590,9 +590,9 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +                      if (type == SMB_ACL_TYPE_ACCESS)
 +                              rsync_acl_fake_perms(racl, sxp->st.st_mode);
 +              } else {
-+                      rsyserr(FERROR, errno, "get_acls: sys_acl_get_file(%s, %s)",
++                      rsyserr(FERROR, errno, "get_acl: sys_acl_get_file(%s, %s)",
 +                              fname, str_acl_type(type));
-+                      free_acls(sxp);
++                      free_acl(sxp);
 +                      return -1;
 +              }
 +      } while (BUMP_TYPE(type) && S_ISDIR(sxp->st.st_mode));
@@ -653,9 +653,9 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +      }
 +}
 +
-+/* Send the ACLs from the statx structure down the indicated file descriptor.
++/* Send the ACL from the statx structure down the indicated file descriptor.
 + * This also frees the ACL data. */
-+void send_acls(statx *sxp, int f)
++void send_acl(statx *sxp, int f)
 +{
 +      SMB_ACL_TYPE_T type;
 +      rsync_acl *racl, *new_racl;
@@ -681,7 +681,6 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +              if ((ndx = find_matching_rsync_acl(type, racl_list, racl)) != -1) {
 +                      write_byte(f, type == SMB_ACL_TYPE_ACCESS ? 'a' : 'd');
 +                      write_int(f, ndx);
-+                      rsync_acl_free(racl);
 +              } else {
 +                      new_racl = EXPAND_ITEM_LIST(racl_list, rsync_acl, 1000);
 +                      write_byte(f, type == SMB_ACL_TYPE_ACCESS ? 'A' : 'D');
@@ -693,7 +692,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +              racl_list = &default_acl_list;
 +      } while (BUMP_TYPE(type) && S_ISDIR(sxp->st.st_mode));
 +
-+      free_acls(sxp);
++      free_acl(sxp);
 +}
 +
 +/* === Receive functions === */
@@ -794,7 +793,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +}
 +
 +/* Receive the ACL info the sender has included for this file-list entry. */
-+void receive_acls(struct file_struct *file, int f)
++void receive_acl(struct file_struct *file, int f)
 +{
 +      SMB_ACL_TYPE_T type;
 +      item_list *racl_list;
@@ -835,7 +834,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +                      duo_item->sacl = NULL;
 +              } else {
 +                      ndx = read_int(f);
-+                      if ((size_t)ndx >= racl_list->count) {
++                      if (ndx < 0 || (size_t)ndx >= racl_list->count) {
 +                              rprintf(FERROR, "receive_acl %s: %s ACL index %d out of range\n",
 +                                      f_name(file, NULL), str_acl_type(type), ndx);
 +                              exit_cleanup(RERR_STREAMIO);
@@ -931,7 +930,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 + *
 + * Returns 1 for unchanged, 0 for changed, -1 for failed.  Call this
 + * with fname set to NULL to just check if the ACLs are unchanged. */
-+int set_acls(const char *fname, const struct file_struct *file, statx *sxp)
++int set_acl(const char *fname, const struct file_struct *file, statx *sxp)
 +{
 +      int unchanged = 1;
 +      SMB_ACL_TYPE_T type;
@@ -952,11 +951,11 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +              if (type == SMB_ACL_TYPE_ACCESS) {
 +                      duo_item = access_acl_list.items;
 +                      duo_item += ndx;
-+                      eq = rsync_acls_equal_enough(sxp->acc_acl, &duo_item->racl, file->mode);
++                      eq = rsync_acl_equal_enough(sxp->acc_acl, &duo_item->racl, file->mode);
 +              } else {
 +                      duo_item = default_acl_list.items;
 +                      duo_item += ndx;
-+                      eq = rsync_acls_equal(sxp->def_acl, &duo_item->racl);
++                      eq = rsync_acl_equal(sxp->def_acl, &duo_item->racl);
 +              }
 +              if (eq)
 +                      continue;
@@ -1150,8 +1149,8 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +                                      continue;
 +#ifdef SUPPORT_ACLS
 +                              if (preserve_acls) {
-+                                      get_acls(rel, &sx);
-+                                      cache_acls(file, &sx);
++                                      get_acl(rel, &sx);
++                                      cache_acl(file, &sx);
 +                              }
 +#endif
 +                              set_file_attrs(fullpath, file, NULL, 0);
@@ -1186,8 +1185,8 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
  
 +#ifdef SUPPORT_ACLS
 +      if (preserve_acls) {
-+              get_acls(fname, &sx);
-+              cache_acls(file, &sx);
++              get_acl(fname, &sx);
++              cache_acl(file, &sx);
 +      }
 +#endif
 +
@@ -1310,7 +1309,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
  
        permstring(permbuf, f->mode);
  
-+      /* TODO: indicate '+' if the entry has ACLs. */
++      /* TODO: indicate '+' if the entry has an ACL. */
 +
  #ifdef SUPPORT_LINKS
        if (preserve_links && S_ISLNK(f->mode)) {
@@ -1332,7 +1331,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +#ifdef SUPPORT_ACLS
 +      /* We need one or two index int32s when we're preserving ACLs. */
 +      if (preserve_acls)
-+              xtra_len = (S_ISDIR(mode) ? 2 : 1) * sizeof (int32);
++              xtra_len = (S_ISDIR(mode) ? 2 : 1) * 4;
 +      else
 +              xtra_len = 0;
 +#endif
@@ -1359,54 +1358,13 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
  
 +#ifdef SUPPORT_ACLS
 +      if (preserve_acls)
-+              receive_acls(file, f);
++              receive_acl(file, f);
 +#endif
 +
        return file;
  }
  
-@@ -733,6 +758,9 @@ struct file_struct *make_file(char *fnam
-       char thisname[MAXPATHLEN];
-       char linkname[MAXPATHLEN];
-       int alloc_len, basename_len, dirname_len, linkname_len, sum_len;
-+#ifdef SUPPORT_ACLS
-+      int xtra_len;
-+#endif
-       char *basename, *dirname, *bp;
-       if (!flist || !flist->count)    /* Ignore lastdir when invalid. */
-@@ -848,8 +876,19 @@ struct file_struct *make_file(char *fnam
-       sum_len = always_checksum && am_sender && S_ISREG(st.st_mode)
-               ? MD4_SUM_LENGTH : 0;
-+#ifdef SUPPORT_ACLS
-+      /* We need one or two index int32s when we're preserving ACLs. */
-+      if (preserve_acls)
-+              xtra_len = (S_ISDIR(st.st_mode) ? 2 : 1) * sizeof (int32);
-+      else
-+              xtra_len = 0;
-+#endif
-+
-       alloc_len = file_struct_len + dirname_len + basename_len
--          + linkname_len + sum_len;
-+#ifdef SUPPORT_ACLS
-+                + xtra_len
-+#endif
-+                + linkname_len + sum_len;
-       if (flist)
-               bp = pool_alloc(flist->file_pool, alloc_len, "make_file");
-       else {
-@@ -860,6 +899,9 @@ struct file_struct *make_file(char *fnam
-       file = (struct file_struct *)bp;
-       memset(bp, 0, file_struct_len);
-       bp += file_struct_len;
-+#ifdef SUPPORT_ACLS
-+      bp += xtra_len;
-+#endif
-       file->flags = flags;
-       file->modtime = st.st_mtime;
-@@ -952,6 +994,9 @@ static struct file_struct *send_file_nam
+@@ -952,6 +977,9 @@ static struct file_struct *send_file_nam
                                          unsigned short flags)
  {
        struct file_struct *file;
@@ -1416,7 +1374,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
  
        file = make_file(fname, flist, stp, flags,
                         f == -2 ? SERVER_FILTERS : ALL_FILTERS);
-@@ -961,6 +1006,15 @@ static struct file_struct *send_file_nam
+@@ -961,6 +989,15 @@ static struct file_struct *send_file_nam
        if (chmod_modes && !S_ISLNK(file->mode))
                file->mode = tweak_mode(file->mode, chmod_modes);
  
@@ -1424,7 +1382,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +      if (preserve_acls) {
 +              sx.st.st_mode = file->mode;
 +              sx.acc_acl = sx.def_acl = NULL;
-+              if (get_acls(fname, &sx) < 0)
++              if (get_acl(fname, &sx) < 0)
 +                      return NULL;
 +      }
 +#endif
@@ -1432,18 +1390,18 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
        maybe_emit_filelist_progress(flist->count + flist_count_offset);
  
        flist_expand(flist);
-@@ -968,6 +1022,15 @@ static struct file_struct *send_file_nam
+@@ -968,6 +1005,15 @@ static struct file_struct *send_file_nam
        if (file->basename[0]) {
                flist->files[flist->count++] = file;
                send_file_entry(file, f);
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls)
-+                      send_acls(&sx, f);
++                      send_acl(&sx, f);
 +#endif
 +      } else {
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls)
-+                      free_acls(&sx);
++                      free_acl(&sx);
 +#endif
        }
        return file;
@@ -1487,7 +1445,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
                return 0;
  
 +#ifdef SUPPORT_ACLS
-+      if (preserve_acls && set_acls(NULL, file, sxp) == 0)
++      if (preserve_acls && set_acl(NULL, file, sxp) == 0)
 +              return 0;
 +#endif
 +
@@ -1522,7 +1480,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +                  && sxp->st.st_gid != file->gid)
                        iflags |= ITEM_REPORT_GROUP;
 +#ifdef SUPPORT_ACLS
-+              if (preserve_acls && set_acls(NULL, file, sxp) == 0)
++              if (preserve_acls && set_acl(NULL, file, sxp) == 0)
 +                      iflags |= ITEM_REPORT_ACL;
 +#endif
        } else
@@ -1560,7 +1518,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 -                      if (!unchanged_attrs(file, stp))
 +#ifdef SUPPORT_ACLS
 +                      if (preserve_acls)
-+                              get_acls(cmpbuf, sxp);
++                              get_acl(cmpbuf, sxp);
 +#endif
 +                      if (!unchanged_attrs(file, sxp))
                                continue;
@@ -1595,7 +1553,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +              } else if (itemizing) {
 +#ifdef SUPPORT_ACLS
 +                      if (preserve_acls && !ACL_READY(*sxp))
-+                              get_acls(fname, sxp);
++                              get_acl(fname, sxp);
 +#endif
 +                      itemize(file, ndx, 0, sxp, 0, 0, NULL);
 +              }
@@ -1611,7 +1569,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +              if (itemizing) {
 +#ifdef SUPPORT_ACLS
 +                      if (preserve_acls && !ACL_READY(*sxp))
-+                              get_acls(fname, sxp);
++                              get_acl(fname, sxp);
 +#endif
 +                      itemize(file, ndx, 0, sxp, ITEM_LOCAL_CHANGE, 0, NULL);
 +              }
@@ -1634,7 +1592,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +                      continue;
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls)
-+                      get_acls(fnamebuf, &sx);
++                      get_acl(fnamebuf, &sx);
 +#endif
 +              if (!unchanged_attrs(file, &sx))
                        continue;
@@ -1660,12 +1618,12 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 -                      itemize(file, ndx, 0, &st, changes, 0, lp);
 +#ifdef SUPPORT_ACLS
 +                      if (preserve_acls)
-+                              get_acls(fname, &sx);
++                              get_acl(fname, &sx);
 +#endif
 +                      itemize(file, ndx, 0, &sx, changes, 0, lp);
 +#ifdef SUPPORT_ACLS
 +                      if (preserve_acls)
-+                              free_acls(&sx);
++                              free_acl(&sx);
 +#endif
                }
                if (verbose > 1 && maybe_ATTRS_REPORT) {
@@ -1757,7 +1715,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 -                      itemize(file, ndx, statret, &st,
 +#ifdef SUPPORT_ACLS
 +                      if (preserve_acls && statret == 0)
-+                              get_acls(fname, &sx);
++                              get_acl(fname, &sx);
 +#endif
 +                      itemize(file, ndx, statret, &sx,
                                statret ? ITEM_LOCAL_CHANGE : 0, 0, NULL);
@@ -1846,7 +1804,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
                }
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls && statret == 0)
-+                      get_acls(fname, &sx);
++                      get_acl(fname, &sx);
 +#endif
                if (statret != 0
 -               || (st.st_mode & ~CHMOD_BITS) != (file->mode & ~CHMOD_BITS)
@@ -1977,7 +1935,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 -                      itemize(file, ndx, real_ret, &real_st,
 +#ifdef SUPPORT_ACLS
 +                      if (preserve_acls && real_ret == 0)
-+                              get_acls(fname, &real_sx);
++                              get_acl(fname, &real_sx);
 +#endif
 +                      itemize(file, ndx, real_ret, &real_sx,
                                0, 0, NULL);
@@ -1987,7 +1945,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +                                      sx.acc_acl = real_sx.acc_acl;
 +                                      sx.def_acl = real_sx.def_acl;
 +                              } else
-+                                      free_acls(&real_sx);
++                                      free_acl(&real_sx);
 +                      }
 +#endif
                }
@@ -2018,7 +1976,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
                statret = real_ret = -1;
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls && ACL_READY(sx))
-+                      free_acls(&sx);
++                      free_acl(&sx);
 +#endif
                goto notify_others;
        }
@@ -2064,13 +2022,13 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 -              itemize(file, -1, real_ret, &real_st, iflags, fnamecmp_type,
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls && real_ret == 0)
-+                      get_acls(fname, &real_sx);
++                      get_acl(fname, &real_sx);
 +#endif
 +              itemize(file, -1, real_ret, &real_sx, iflags, fnamecmp_type,
                        fuzzy_file ? fuzzy_file->basename : NULL);
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls)
-+                      free_acls(&real_sx);
++                      free_acl(&real_sx);
 +#endif
        }
  
@@ -2103,7 +2061,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +  cleanup:
 +#ifdef SUPPORT_ACLS
 +      if (preserve_acls)
-+              free_acls(&sx);
++              free_acl(&sx);
 +#endif
 +      return;
  }
@@ -2146,7 +2104,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 -                              itemize(file, ndx, statret, st,
 +#ifdef SUPPORT_ACLS
 +                              if (preserve_acls && !ACL_READY(*sxp))
-+                                      get_acls(fname, sxp);
++                                      get_acl(fname, sxp);
 +#endif
 +                              itemize(file, ndx, statret, sxp,
                                        ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS,
@@ -2186,7 +2144,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +                                      sxp->st = st3;
 +#ifdef SUPPORT_ACLS
 +                                      if (preserve_acls)
-+                                              get_acls(cmpbuf, sxp);
++                                              get_acl(cmpbuf, sxp);
 +#endif
 +                                      if (unchanged_attrs(file, sxp))
                                                break;
@@ -2213,7 +2171,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 -              itemize(file, ndx, statret, st,
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls && statret == 0 && !ACL_READY(*sxp))
-+                      get_acls(fname, sxp);
++                      get_acl(fname, sxp);
 +#endif
 +              itemize(file, ndx, statret, sxp,
                        ITEM_LOCAL_CHANGE | ITEM_XNAME_FOLLOWS, 0,
@@ -2246,7 +2204,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +                              hlink1, &st, itemizing, code);
 +#ifdef SUPPORT_ACLS
 +              if (preserve_acls)
-+                      free_acls(&sx);
++                      free_acl(&sx);
 +#endif
                file->F_HLINDEX = FINISHED_LINK;
        } while (!(file->flags & FLAG_HLINK_EOL));
@@ -5496,7 +5454,12 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +}
 --- old/lib/sysacls.h
 +++ new/lib/sysacls.h
-@@ -0,0 +1,28 @@
+@@ -0,0 +1,33 @@
++#if defined SUPPORT_ACLS && defined HAVE_SYS_ACL_H
++#include <sys/acl.h>
++#endif
++#include "smb_acls.h"
++
 +#define SMB_MALLOC(cnt) new_array(char, cnt)
 +#define SMB_MALLOC_P(obj) new_array(obj, 1)
 +#define SMB_MALLOC_ARRAY(obj, cnt) new_array(obj, cnt)
@@ -5754,7 +5717,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 -      if (!preserve_times || (S_ISDIR(st->st_mode) && omit_dir_times))
 +#ifdef SUPPORT_ACLS
 +      if (preserve_acls && !ACL_READY(*sxp))
-+              get_acls(fname, sxp);
++              get_acl(fname, sxp);
 +#endif
 +
 +      if (!preserve_times || (S_ISDIR(sxp->st.st_mode) && omit_dir_times))
@@ -5827,13 +5790,13 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
        }
  
 +#ifdef SUPPORT_ACLS
-+      /* It's OK to call set_acls() now, even for a dir, as the generator
++      /* It's OK to call set_acl() now, even for a dir, as the generator
 +       * will enable owner-writability using chmod, if necessary.
 +       * 
-+       * If set_acl changes permission bits in the process of setting
++       * If set_acl() changes permission bits in the process of setting
 +       * an access ACL, it changes sxp->st.st_mode so we know whether we
-+       * need to chmod. */
-+      if (preserve_acls && set_acls(fname, file, sxp) == 0)
++       * need to chmod(). */
++      if (preserve_acls && set_acl(fname, file, sxp) == 0)
 +              updated = 1;
 +#endif
 +
@@ -5859,7 +5822,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +  cleanup:
 +#ifdef SUPPORT_ACLS
 +      if (preserve_acls && sxp == &sx2)
-+              free_acls(&sx2);
++              free_acl(&sx2);
 +#endif
        return updated;
  }
@@ -5900,15 +5863,10 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
  #include "byteorder.h"
  #include "lib/mdfour.h"
  #include "lib/wildmatch.h"
-@@ -660,6 +680,21 @@ struct chmod_mode_struct;
+@@ -660,6 +680,16 @@ struct chmod_mode_struct;
  
  #define UNUSED(x) x __attribute__((__unused__))
  
-+#if defined SUPPORT_ACLS && defined HAVE_SYS_ACL_H
-+#include <sys/acl.h>
-+#endif
-+#include "smb_acls.h"
-+
 +typedef struct {
 +    STRUCT_STAT st;
 +#ifdef SUPPORT_ACLS
@@ -6742,7 +6700,7 @@ latest ACL-enabling patch to send files to an older ACL-enabled rsync.
 +              size_t new_size = lp->malloced;
 +              if (incr < 0)
 +                      new_size -= incr; /* increase slowly */
-+              else if (new_size < incr)
++              else if (new_size < (size_t)incr)
 +                      new_size += incr;
 +              else
 +                      new_size *= 2;