Browse Source

Fix bug where xattrs on symlinks were not correctly restored

Jonas Borgström 11 years ago
parent
commit
4bbde41466
3 changed files with 12 additions and 3 deletions
  1. 8 0
      CHANGES
  2. 1 1
      attic/archive.py
  3. 3 2
      attic/testsuite/archiver.py

+ 8 - 0
CHANGES

@@ -3,6 +3,14 @@ Attic Changelog
 
 Here you can see the full list of changes between each Attic release.
 
+Version 0.13
+------------
+
+(feature release, released on X)
+
+- Fix bug where xattrs on symlinks were not correctly restored
+
+
 Version 0.12
 ------------
 

+ 1 - 1
attic/archive.py

@@ -285,7 +285,7 @@ class Archive:
         if xattrs:
                 for k, v in xattrs.items():
                     try:
-                        xattr.setxattr(fd or path, k, v)
+                        xattr.setxattr(fd or path, k, v, follow_symlinks=False)
                     except OSError as e:
                         if e.errno != errno.ENOTSUP:
                             raise

+ 3 - 2
attic/testsuite/archiver.py

@@ -128,13 +128,14 @@ class ArchiverTestCase(ArchiverTestCaseBase):
         os.mknod('input/bdev', 0o600 | stat.S_IFBLK,  os.makedev(10, 20))
         # Char device
         os.mknod('input/cdev', 0o600 | stat.S_IFCHR,  os.makedev(30, 40))
-        if xattr.is_enabled():
-            xattr.setxattr(os.path.join(self.input_path, 'file1'), 'user.foo', b'bar')
         # Hard link
         os.link(os.path.join(self.input_path, 'file1'),
                 os.path.join(self.input_path, 'hardlink'))
         # Symlink
         os.symlink('somewhere', os.path.join(self.input_path, 'link1'))
+        if xattr.is_enabled():
+            xattr.setxattr(os.path.join(self.input_path, 'file1'), 'user.foo', b'bar')
+            xattr.setxattr(os.path.join(self.input_path, 'link1'), 'user.foo_symlink', b'bar_symlink', follow_symlinks=False)
         # FIFO node
         os.mkfifo(os.path.join(self.input_path, 'fifo1'))