/* Removes the permission-bit entries from the ACL because these
* can be reconstructed from the file's mode. */
-static void rsync_acl_strip_perms(rsync_acl *racl)
+static void rsync_acl_strip_perms(stat_x *sxp)
{
+ rsync_acl *racl = sxp->acc_acl;
+
racl->user_obj = NO_ENTRY;
if (racl->mask_obj == NO_ENTRY)
racl->group_obj = NO_ENTRY;
else {
- if (racl->group_obj == racl->mask_obj)
+ int group_perms = (sxp->st.st_mode >> 3) & 7;
+ if (racl->group_obj == group_perms)
racl->group_obj = NO_ENTRY;
- if (racl->names.count != 0)
+#ifndef HAVE_SOLARIS_ACLS
+ if (racl->names.count != 0 && racl->mask_obj == group_perms)
racl->mask_obj = NO_ENTRY;
+#endif
}
racl->other_obj = NO_ENTRY;
}
/* Truncate the temporary list now that its idas have been saved. */
temp_ida_list.count = 0;
-#ifdef ACLS_NEED_MASK
- if (!racl->names.count && racl->mask_obj != NO_ENTRY) {
- /* Throw away a superfluous mask, but mask off the
- * group perms with it first. */
- racl->group_obj &= racl->mask_obj;
- racl->mask_obj = NO_ENTRY;
- }
-#endif
-
return True;
}
rsync_acl_fake_perms(sxp->acc_acl, sxp->st.st_mode);
}
/* Avoid sending values that can be inferred from other data. */
- rsync_acl_strip_perms(sxp->acc_acl);
+ rsync_acl_strip_perms(sxp);
send_rsync_acl(f, sxp->acc_acl, SMB_ACL_TYPE_ACCESS, &access_acl_list);
return computed_mask_bits & ~NO_ENTRY;
}
-static int recv_rsync_acl(int f, item_list *racl_list, SMB_ACL_TYPE_T type)
+static int recv_rsync_acl(int f, item_list *racl_list, SMB_ACL_TYPE_T type, mode_t mode)
{
uchar computed_mask_bits = 0;
acl_duo *duo_item;
if (ndx != 0)
return ndx - 1;
-
+
ndx = racl_list->count;
duo_item = EXPAND_ITEM_LIST(racl_list, acl_duo, 1000);
duo_item->racl = empty_rsync_acl;
/* If we received a superfluous mask, throw it away. */
duo_item->racl.mask_obj = NO_ENTRY;
#else
- if (duo_item->racl.names.count && duo_item->racl.mask_obj == NO_ENTRY) /* Must be non-empty with lists. */
- duo_item->racl.mask_obj = (computed_mask_bits | duo_item->racl.group_obj) & ~NO_ENTRY;
+ if (duo_item->racl.names.count && duo_item->racl.mask_obj == NO_ENTRY) {
+ /* Mask must be non-empty with lists. */
+ if (type == SMB_ACL_TYPE_ACCESS)
+ computed_mask_bits = (mode >> 3) & 7;
+ else
+ computed_mask_bits |= duo_item->racl.group_obj & ~NO_ENTRY;
+ duo_item->racl.mask_obj = computed_mask_bits;
+ }
#endif
duo_item->sacl = NULL;
/* Receive the ACL info the sender has included for this file-list entry. */
void receive_acl(int f, struct file_struct *file)
{
- F_ACL(file) = recv_rsync_acl(f, &access_acl_list, SMB_ACL_TYPE_ACCESS);
+ F_ACL(file) = recv_rsync_acl(f, &access_acl_list, SMB_ACL_TYPE_ACCESS, file->mode);
if (S_ISDIR(file->mode))
- F_DIR_DEFACL(file) = recv_rsync_acl(f, &default_acl_list, SMB_ACL_TYPE_DEFAULT);
+ F_DIR_DEFACL(file) = recv_rsync_acl(f, &default_acl_list, SMB_ACL_TYPE_DEFAULT, 0);
}
static int cache_rsync_acl(rsync_acl *racl, SMB_ACL_TYPE_T type, item_list *racl_list)
COE2( store_access_in_entry,((mode >> 3) & 7, entry) );
break;
case SMB_ACL_MASK:
+#ifndef HAVE_SOLARIS_ACLS
#ifndef ACLS_NEED_MASK
/* mask is only empty when we don't need it. */
if (racl->mask_obj == NO_ENTRY)
break;
#endif
COE2( store_access_in_entry,((mode >> 3) & 7, entry) );
+#endif
break;
case SMB_ACL_OTHER:
COE2( store_access_in_entry,(mode & 7, entry) );
return 0;
}
-/* Set ACL on indicated filename.
+/* Given a fname, this sets extended access ACL entries, the default ACL (for a
+ * dir), and the regular mode bits on the file. Call this with fname set to
+ * NULL to just check if the ACL is different.
*
- * This sets extended access ACL entries and default ACL. If convenient,
- * it sets permission bits along with the access ACL and signals having
- * done so by modifying sxp->st.st_mode.
+ * If the ACL operation has a side-effect of changing the file's mode, the
+ * sxp->st.st_mode value will be changed to match.
*
- * Returns 1 for unchanged, 0 for changed, -1 for failed. Call this
- * with fname set to NULL to just check if the ACL is unchanged. */
-int set_acl(const char *fname, const struct file_struct *file, stat_x *sxp)
+ * Returns 0 for an unchanged ACL, 1 for changed, -1 for failed. */
+int set_acl(const char *fname, const struct file_struct *file, stat_x *sxp, mode_t new_mode)
{
- int unchanged = 1;
+ int changed = 0;
int32 ndx;
BOOL eq;
acl_duo *duo_item = access_acl_list.items;
duo_item += ndx;
eq = sxp->acc_acl
- && rsync_acl_equal_enough(sxp->acc_acl, &duo_item->racl, file->mode);
+ && rsync_acl_equal_enough(sxp->acc_acl, &duo_item->racl, new_mode);
if (!eq) {
- unchanged = 0;
+ changed = 1;
if (!dry_run && fname
&& set_rsync_acl(fname, duo_item, SMB_ACL_TYPE_ACCESS,
- sxp, file->mode) < 0)
- unchanged = -1;
+ sxp, new_mode) < 0)
+ return -1;
}
}
- if (!S_ISDIR(sxp->st.st_mode))
- return unchanged;
+ if (!S_ISDIR(new_mode))
+ return changed;
ndx = F_DIR_DEFACL(file);
if (ndx >= 0 && (size_t)ndx < default_acl_list.count) {
duo_item += ndx;
eq = sxp->def_acl && rsync_acl_equal(sxp->def_acl, &duo_item->racl);
if (!eq) {
- if (unchanged > 0)
- unchanged = 0;
+ changed = 1;
if (!dry_run && fname
&& set_rsync_acl(fname, duo_item, SMB_ACL_TYPE_DEFAULT,
- sxp, file->mode) < 0)
- unchanged = -1;
+ sxp, new_mode) < 0)
+ return -1;
}
}
- return unchanged;
+ return changed;
}
/* Non-incremental recursion needs to convert all the received IDs.