浏览代码

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 年之前
父节点
当前提交
9ebc53ad77
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      borg/archive.py

+ 5 - 1
borg/archive.py

@@ -328,7 +328,11 @@ class Archive:
             try:
                 xattr.setxattr(fd or path, k, v, follow_symlinks=False)
             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
         uid = gid = None
         if not self.numeric_owner: