summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWayne Davison <wayned@samba.org>2009-09-12 09:27:07 -0700
committerWayne Davison <wayned@samba.org>2009-09-12 09:27:07 -0700
commitee1c00fea8647356e403368fad9ad4c909e9ef08 (patch)
treeeae7a614d05e6ca49d0244bf7f337302f8cb58ff
parent1b502f3ec234bf1045c6bb146f64734d09e81956 (diff)
downloadrsync-ee1c00fea8647356e403368fad9ad4c909e9ef08.tar.gz
Pass "new_mode" to set_acl() and change its return values.
-rw-r--r--acls.c39
-rw-r--r--generator.c4
-rw-r--r--rsync.c6
3 files changed, 25 insertions, 24 deletions
diff --git a/acls.c b/acls.c
index 24dc1777..f7070dd8 100644
--- a/acls.c
+++ b/acls.c
@@ -732,7 +732,7 @@ static int recv_rsync_acl(int f, item_list *racl_list, SMB_ACL_TYPE_T type)
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;
@@ -984,17 +984,17 @@ static int set_rsync_acl(const char *fname, acl_duo *duo_item,
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;
@@ -1008,18 +1008,18 @@ int set_acl(const char *fname, const struct file_struct *file, stat_x *sxp)
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) {
@@ -1027,16 +1027,15 @@ int set_acl(const char *fname, const struct file_struct *file, stat_x *sxp)
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.
diff --git a/generator.c b/generator.c
index 836633e8..acf4b888 100644
--- a/generator.c
+++ b/generator.c
@@ -417,7 +417,7 @@ int unchanged_attrs(const char *fname, struct file_struct *file, stat_x *sxp)
if (preserve_acls && !S_ISLNK(file->mode)) {
if (!ACL_READY(*sxp))
get_acl(fname, sxp);
- if (set_acl(NULL, file, sxp) == 0)
+ if (set_acl(NULL, file, sxp, file->mode))
return 0;
}
#endif
@@ -476,7 +476,7 @@ void itemize(const char *fnamecmp, struct file_struct *file, int ndx, int statre
if (preserve_acls && !S_ISLNK(file->mode)) {
if (!ACL_READY(*sxp))
get_acl(fnamecmp, sxp);
- if (set_acl(NULL, file, sxp) == 0)
+ if (set_acl(NULL, file, sxp, file->mode))
iflags |= ITEM_REPORT_ACL;
}
#endif
diff --git a/rsync.c b/rsync.c
index db7abcc5..c84e8e8d 100644
--- a/rsync.c
+++ b/rsync.c
@@ -497,8 +497,10 @@ int set_file_attrs(const char *fname, struct file_struct *file, stat_x *sxp,
* 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 && !S_ISLNK(new_mode) && set_acl(fname, file, sxp) == 0)
- updated = 1;
+ if (preserve_acls && !S_ISLNK(new_mode)) {
+ if (set_acl(fname, file, sxp, new_mode) > 0)
+ updated = 1;
+ }
#endif
#ifdef HAVE_CHMOD