+ 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
+ * 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 */
+ *racl = empty_rsync_acl;
+}
+
-+void free_acls(statx *sxp)
++void free_acl(statx *sxp)
+{
+ if (sxp->acc_acl) {
+ rsync_acl_free(sxp->acc_acl);
+ *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;
+
+/* 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;
+}
+
+/* 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;
+
+ 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
+
+ sys_acl_free_acl(sacl);
+ if (!ok) {
-+ free_acls(sxp);
++ free_acl(sxp);
+ return -1;
+ }
+ } else if (errno == ENOTSUP) {
+ 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));
+ }
+}
+
-+/* 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;
+ racl_list = &default_acl_list;
+ } while (BUMP_TYPE(type) && S_ISDIR(sxp->st.st_mode));
+
-+ free_acls(sxp);
++ free_acl(sxp);
+}
+
+/* === Receive functions === */
+}
+
+/* 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;
+ *
+ * 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;
+ 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;
+ 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);
+#ifdef SUPPORT_ACLS
+ if (preserve_acls) {
-+ get_acls(fname, &sx);
-+ cache_acls(file, &sx);
++ get_acl(fname, &sx);
++ cache_acl(file, &sx);
+ }
+#endif
+
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)) {
+#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
+#ifdef SUPPORT_ACLS
+ if (preserve_acls)
-+ receive_acls(file, f);
++ receive_acl(file, f);
+#endif
+
return file;
? MD4_SUM_LENGTH : 0;
+#ifdef SUPPORT_ACLS
-+ /* We need one or two index int32s when we're preserving ACLs. */
++ /* We need one or two index int32s when we're preserving an ACL. */
+ if (preserve_acls)
-+ xtra_len = (S_ISDIR(st.st_mode) ? 2 : 1) * sizeof (int32);
++ xtra_len = (S_ISDIR(st.st_mode) ? 2 : 1) * 4;
+ else
+ xtra_len = 0;
+#endif
+ 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
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;
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
+
+ && 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
- 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;
+ } 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);
+ }
+ 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);
+ }
+ continue;
+#ifdef SUPPORT_ACLS
+ if (preserve_acls)
-+ get_acls(fnamebuf, &sx);
++ get_acl(fnamebuf, &sx);
+#endif
+ if (!unchanged_attrs(file, &sx))
continue;
- 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) {
- 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);
}
+#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)
- 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);
+ sx.acc_acl = real_sx.acc_acl;
+ sx.def_acl = real_sx.def_acl;
+ } else
-+ free_acls(&real_sx);
++ free_acl(&real_sx);
+ }
+#endif
}
statret = real_ret = -1;
+#ifdef SUPPORT_ACLS
+ if (preserve_acls && ACL_READY(sx))
-+ free_acls(&sx);
++ free_acl(&sx);
+#endif
goto notify_others;
}
- 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
}
+ cleanup:
+#ifdef SUPPORT_ACLS
+ if (preserve_acls)
-+ free_acls(&sx);
++ free_acl(&sx);
+#endif
+ return;
}
- 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,
+ sxp->st = st3;
+#ifdef SUPPORT_ACLS
+ if (preserve_acls)
-+ get_acls(cmpbuf, sxp);
++ get_acl(cmpbuf, sxp);
+#endif
+ if (unchanged_attrs(file, sxp))
break;
- 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,
+ 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));
- 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))
}
+#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
+
+ cleanup:
+#ifdef SUPPORT_ACLS
+ if (preserve_acls && sxp == &sx2)
-+ free_acls(&sx2);
++ free_acl(&sx2);
+#endif
return updated;
}
+ 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;