]> arthur.barton.de Git - bup.git/commitdiff
Fix ACL tests, and the bugs revealed thereby.
authorRob Browning <rlb@defaultvalue.org>
Sun, 27 Oct 2013 18:02:08 +0000 (13:02 -0500)
committerRob Browning <rlb@defaultvalue.org>
Fri, 1 Nov 2013 23:24:16 +0000 (18:24 -0500)
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
lib/bup/metadata.py
t/test-meta.sh

index 042eb4d81279867abeb139ecac8c6b3540732f49..3aa5f4da8219fb6defff6dc67f301aa493c26175 100644 (file)
@@ -476,8 +476,8 @@ class Metadata:
                     acl = posix1e.ACL(file=path)
                     acls = [acl, acl] # txt and num are the same
                     if stat.S_ISDIR(st.st_mode):
-                        acl = posix1e.ACL(filedef=path)
-                        def_acls = [acl_def, acl_def]
+                        def_acl = posix1e.ACL(filedef=path)
+                        def_acls = [def_acl, def_acl]
             except EnvironmentError, e:
                 if e.errno not in (errno.EOPNOTSUPP, errno.ENOSYS):
                     raise
@@ -485,10 +485,10 @@ class Metadata:
                 txt_flags = posix1e.TEXT_ABBREVIATE
                 num_flags = posix1e.TEXT_ABBREVIATE | posix1e.TEXT_NUMERIC_IDS
                 acl_rep = [acls[0].to_any_text('', '\n', txt_flags),
-                            acls[1].to_any_text('', '\n', num_flags)]
+                           acls[1].to_any_text('', '\n', num_flags)]
                 if def_acls:
-                    acl_rep.append(def_acls[2].to_any_text('', '\n', txt_flags))
-                    acl_rep.append(def_acls[3].to_any_text('', '\n', num_flags))
+                    acl_rep.append(def_acls[0].to_any_text('', '\n', txt_flags))
+                    acl_rep.append(def_acls[1].to_any_text('', '\n', num_flags))
                 self.posix1e_acl = acl_rep
 
     def _same_posix1e_acl(self, other):
@@ -926,16 +926,12 @@ def detailed_str(meta, fields = None):
     if 'linux-xattr' in fields and meta.linux_xattr:
         for name, value in meta.linux_xattr:
             result.append('linux-xattr: %s -> %s' % (name, repr(value)))
-    if 'posix1e-acl' in fields and meta.posix1e_acl and posix1e:
-        flags = posix1e.TEXT_ABBREVIATE
+    if 'posix1e-acl' in fields and meta.posix1e_acl:
+        acl = meta.posix1e_acl[0]
+        result.append('posix1e-acl: ' + acl + '\n')
         if stat.S_ISDIR(meta.mode):
-            acl = meta.posix1e_acl[0]
-            default_acl = meta.posix1e_acl[2]
-            result.append(acl.to_any_text('posix1e-acl: ', '\n', flags))
-            result.append(acl.to_any_text('posix1e-acl-default: ', '\n', flags))
-        else:
-            acl = meta.posix1e_acl[0]
-            result.append(acl.to_any_text('posix1e-acl: ', '\n', flags))
+            def_acl = meta.posix1e_acl[2]
+            result.append('posix1e-acl-default: ' + def_acl + '\n')
     return '\n'.join(result)
 
 
index 8fbcf62ca720b1bc97a7fabf9ca52681c15dc48f..33a51dddfc5d9d2bb6dcce8d321605ae5bd94200 100755 (executable)
@@ -678,7 +678,7 @@ if [ $(t/root-status) == root ]; then
         ) || exit $?
 
         # FIXME: skip remaining tests until we fix them.
-        test "$BUP_SKIP_BROKEN_TESTS" && exit 0
+        if ! test "$BUP_SKIP_BROKEN_TESTS"; then
 
         set -e
 
@@ -705,29 +705,29 @@ if [ $(t/root-status) == root ]; then
                       'import sys; exit(not len(sys.stdin.readlines()) == 2)'
             )
         )
+        fi
 
+        set +e
         WVSTART 'meta - POSIX.1e ACLs (as root)'
-        force-delete testfs/src
-        mkdir testfs/src
-        (
-            touch testfs/src/foo
-            mkdir testfs/src/bar
-            setfacl -m u:root:r testfs/src/foo
-            setfacl -m u:root:r testfs/src/bar
-            (cd testfs && test-src-create-extract)
+        WVPASS force-delete testfs/src
+        WVPASS mkdir testfs/src
+        WVPASS touch testfs/src/foo
+        WVPASS mkdir testfs/src/bar
+        WVPASS setfacl -m u:root:r testfs/src/foo
+        WVPASS setfacl -m u:root:r testfs/src/bar
+        (WVPASS cd testfs; WVPASS test-src-create-extract) || exit $?
 
-            # Test restoration to a limited filesystem (vfat).
-            (
-                WVPASS bup meta --create --recurse --file testfs/src.meta \
-                    testfs/src
-                force-delete testfs-limited/src-restore
-                mkdir testfs-limited/src-restore
-                cd testfs-limited/src-restore
-                WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
-                    | WVPASS grep -e '^POSIX1e ACL applyto:' \
-                    | WVPASS python -c \
-                      'import sys; exit(not len(sys.stdin.readlines()) == 2)'
-            )
-        )
+        # Test restoration to a limited filesystem (vfat).
+        (
+            WVPASS bup meta --create --recurse --file testfs/src.meta \
+                testfs/src
+            WVPASS force-delete testfs-limited/src-restore
+            WVPASS mkdir testfs-limited/src-restore
+            WVPASS cd testfs-limited/src-restore
+            WVFAIL bup meta --extract --file ../../testfs/src.meta 2>&1 \
+                | WVPASS grep -e '^POSIX1e ACL applyto:' \
+                | WVPASS python -c \
+                'import sys; exit(not len(sys.stdin.readlines()) == 2)'
+        ) || exit $?
     ) || exit $?
 fi