]> git.ipfire.org Git - thirdparty/rsync.git/commitdiff
Avoid reading ACL/xattr info on filetypes not being copied.
authorWayne Davison <wayned@samba.org>
Mon, 3 Jan 2011 19:07:47 +0000 (11:07 -0800)
committerWayne Davison <wayned@samba.org>
Mon, 3 Jan 2011 19:23:19 +0000 (11:23 -0800)
Make Linux avoid xattr access on symlinks.
Make OS X avoid xattr access on device/special files.
Fixes bug 5458.

acls.c
configure.ac
flist.c
xattrs.c

diff --git a/acls.c b/acls.c
index e2bdc4c9d8897f74f7bb45f965b5c6297cb18ab4..27a93c0b125e91b3ddffe081932a99aa38ee96a9 100644 (file)
--- a/acls.c
+++ b/acls.c
@@ -31,6 +31,8 @@ extern int list_only;
 extern int orig_umask;
 extern int numeric_ids;
 extern int inc_recurse;
+extern int preserve_devices;
+extern int preserve_specials;
 
 /* Flags used to indicate what items are being transmitted for an entry. */
 #define XMIT_USER_OBJ (1<<0)
@@ -540,6 +542,23 @@ static int get_rsync_acl(const char *fname, rsync_acl *racl,
 int get_acl(const char *fname, stat_x *sxp)
 {
        sxp->acc_acl = create_racl();
+
+       if (S_ISREG(sxp->st.st_mode) || S_ISDIR(sxp->st.st_mode)) {
+               /* Everyone supports this. */
+       } else if (S_ISLNK(sxp->st.st_mode)) {
+               return 0;
+       } else if (IS_SPECIAL(sxp->st.st_mode)) {
+#ifndef NO_SPECIAL_ACLS
+               if (!preserve_specials)
+#endif
+                       return 0;
+       } else if (IS_DEVICE(sxp->st.st_mode)) {
+#ifndef NO_DEVICE_ACLS
+               if (!preserve_devices)
+#endif
+                       return 0;
+       }
+
        if (get_rsync_acl(fname, sxp->acc_acl, SMB_ACL_TYPE_ACCESS,
                          sxp->st.st_mode) < 0) {
                free_acl(sxp);
index d447b897d61e6c5cb23d7c75000e8cd2cc721ce4..845ce0fc419b348b7fa50819dc989ee5ac14e5ae 100644 (file)
@@ -963,11 +963,14 @@ else
        AC_MSG_RESULT(Using Linux xattrs)
        AC_DEFINE(HAVE_LINUX_XATTRS, 1, [True if you have Linux xattrs])
        AC_DEFINE(SUPPORT_XATTRS, 1)
+       AC_DEFINE(NO_SYMLINK_XATTRS, 1, [True if symlinks do not support xattrs])
        ;;
     darwin*)
        AC_MSG_RESULT(Using OS X xattrs)
        AC_DEFINE(HAVE_OSX_XATTRS, 1, [True if you have Mac OS X xattrs])
        AC_DEFINE(SUPPORT_XATTRS, 1)
+       AC_DEFINE(NO_DEVICE_XATTRS, 1, [True if device files do not support xattrs])
+       AC_DEFINE(NO_SPECIAL_XATTRS, 1, [True if special files do not support xattrs])
        ;;
     freebsd*)
        AC_MSG_RESULT(Using FreeBSD extattrs)
diff --git a/flist.c b/flist.c
index 253dbe0ade44bc689acaee69704a4010fc923898..86e45412f78ebad71e6661858d31b943f7c674e1 100644 (file)
--- a/flist.c
+++ b/flist.c
@@ -1429,6 +1429,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist,
 #endif
 #ifdef SUPPORT_XATTRS
                if (preserve_xattrs) {
+                       sx.st.st_mode = file->mode;
                        sx.xattr = NULL;
                        if (get_xattr(fname, &sx) < 0) {
                                io_error |= IOERR_GENERAL;
index cc8f8d7968ff3741778d3b07a452695c5562b3b3..6f9afc9497445571eb3159b99bd8e192a15ccec6 100644 (file)
--- a/xattrs.c
+++ b/xattrs.c
@@ -32,6 +32,9 @@ extern int am_generator;
 extern int read_only;
 extern int list_only;
 extern int preserve_xattrs;
+extern int preserve_links;
+extern int preserve_devices;
+extern int preserve_specials;
 extern int checksum_seed;
 
 #define RSYNC_XAL_INITIAL 5
@@ -283,6 +286,26 @@ int get_xattr(const char *fname, stat_x *sxp)
 {
        sxp->xattr = new(item_list);
        *sxp->xattr = empty_xattr;
+
+       if (S_ISREG(sxp->st.st_mode) || S_ISDIR(sxp->st.st_mode)) {
+               /* Everyone supports this. */
+       } else if (S_ISLNK(sxp->st.st_mode)) {
+#ifndef NO_SYMLINK_XATTRS
+               if (!preserve_links)
+#endif
+                       return 0;
+       } else if (IS_SPECIAL(sxp->st.st_mode)) {
+#ifndef NO_SPECIAL_XATTRS
+               if (!preserve_specials)
+#endif
+                       return 0;
+       } else if (IS_DEVICE(sxp->st.st_mode)) {
+#ifndef NO_DEVICE_XATTRS
+               if (!preserve_devices)
+#endif
+                       return 0;
+       }
+
        if (rsync_xal_get(fname, sxp->xattr) < 0) {
                free_xattr(sxp);
                return -1;