Problem/fix combining -A and --link-dest
Andrew Gideon
c172driver99820 at tagonline.com
Mon Feb 28 00:04:47 GMT 2005
Wayne Davison wrote:
> This hasn't been fixed yet, so I'd like to see your changes so I can
> incorporate them into the patches/acls.diff for 2.6.4. Thanks!
Okay. I was hoping that someone else had done this (better than
I). Please keep in mind my caveats.
- Andrew
To acls.c I just added:
/* Skip for S_ISLNK(file->mode) or not preserve_acls */
static int test_if_acls_match_for_one_type(const char *fname, const struct file_struct *file, SMB_ACL_TYPE_T type)
{
int aclidx = find_file_acl_index(file_acl_index_lists(type), file);
rsync_acl *racl_new = &(rsync_acl_lists(type)->racls[aclidx]);
SMB_ACL_T sacl_orig = sys_acl_get_file(fname, type);
rsync_acl racl_orig;
int match = 0;
if (sacl_orig != NULL)
{
if (unpack_smb_acl(&racl_orig, sacl_orig))
{
match = rsync_acls_equal(&racl_orig, racl_new);
rsync_acl_free(&racl_orig);
}
sys_acl_free_acl(sacl_orig);
}
return(match);
}
int test_if_acls_match(const char *fname, const struct file_struct *file)
{
int matching = 1;
SMB_ACL_TYPE_T *type, types[] = {SMB_ACL_TYPE_ACCESS, SMB_ACL_TYPE_DEFAULT};
for (type = &types[0];
matching &&
type < &types[0] + sizeof types / sizeof types[0]
&& (*type == SMB_ACL_TYPE_ACCESS || S_ISDIR(file->mode));
type++)
{
matching = test_if_acls_match_for_one_type(fname, file, *type);
}
return(matching);
}
The diff for generator.c, the changes to which were a bit more complex, is:
*** original/rsync-2.6.2/generator.c 2005-02-27 18:45:06.000000000 -0500
--- rsync-2.6.2/generator.c 2005-02-27 18:53:53.000000000 -0500
***************
*** 52,57 ****
--- 52,60 ----
extern int safe_symlinks;
+ extern int preserve_acls; /* AWG */
+ extern int test_if_acls_match(const char *fname, const struct file_struct *file); /* AWG */
+
/* choose whether to skip a particular file */
static int skip_file(char *fname, struct file_struct *file, STRUCT_STAT *st)
{
***************
*** 59,71 ****
--- 62,86 ----
return 0;
}
if (link_dest) {
+ /* Presume preserve_acls supercedes the idea of preserve_perms */
+ if (preserve_acls && !S_ISLNK(file->mode)) /* AWG */
+ {
+ int match = test_if_acls_match(fname, file);
+ if (!match)
+ {
+ return(0);
+ }
+ }
+ else
if (preserve_perms
&& (st->st_mode & CHMOD_BITS) != (file->mode & CHMOD_BITS))
return 0;
+
if (am_root && preserve_uid && st->st_uid != file->uid)
return 0;
+
if (preserve_gid && file->gid != GID_NONE
&& st->st_gid != file->gid)
return 0;
***************
*** 327,334 ****
permission and modification time repair */
if (set_perms(fname,file,NULL,0) && verbose && (f_out != -1))
rprintf(FINFO,"%s/\n",fname);
! if (f_out == -1)
! SET_ACL(fname, file);
return;
}
--- 342,351 ----
permission and modification time repair */
if (set_perms(fname,file,NULL,0) && verbose && (f_out != -1))
rprintf(FINFO,"%s/\n",fname);
! #if SUPPORT_ACLS
! if (f_out == -1)
! SET_ACL(fname, file);
! #endif
return;
}
More information about the rsync
mailing list