Browse Source

restore_xattrs: ignore if setxattr fails with EACCES, fixes #162

e.g.:
- setting any security.* key is expected to fail with EACCES if one is not root.
- issue #162 on our issue tracker: user was root, but due to some specific scenario
  involving docker and selinux, setting security.selinux key fails even when running as root

not sure if it is the best solution to silently ignore this, but some lines below this change
failure to do a chown is also silently ignored (happens e.g. when restoring a file not owned
by the current user as a non-root user).
Thomas Waldmann 9 years ago
parent
commit
9ebc53ad77
1 changed files with 5 additions and 1 deletions
  1. 5 1
      borg/archive.py

+ 5 - 1
borg/archive.py

@@ -328,7 +328,11 @@ class Archive:
             try:
             try:
                 xattr.setxattr(fd or path, k, v, follow_symlinks=False)
                 xattr.setxattr(fd or path, k, v, follow_symlinks=False)
             except OSError as e:
             except OSError as e:
-                if e.errno != errno.ENOTSUP:
+                if e.errno not in (errno.ENOTSUP, errno.EACCES, ):
+                    # only raise if the errno is not on our ignore list:
+                    # ENOTSUP == xattrs not supported here
+                    # EACCES == permission denied to set this specific xattr
+                    #           (this may happen related to security.* keys)
                     raise
                     raise
         uid = gid = None
         uid = gid = None
         if not self.numeric_owner:
         if not self.numeric_owner: