]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
When comparing ACLs for these tests, ignore 'Guest' account
authorTim Kientzle <kientzle@gmail.com>
Wed, 21 Oct 2015 08:08:20 +0000 (01:08 -0700)
committerTim Kientzle <kientzle@gmail.com>
Wed, 21 Oct 2015 08:08:20 +0000 (01:08 -0700)
information that may vary between machines.

libarchive/test/test_write_disk_appledouble.c
libarchive/test/test_write_disk_mac_metadata.c

index 4f1850b3df4db307e58ae46ac1517058d6a337cf..502fac316473d28557aa5280b8a4c95456910fe3 100644 (file)
@@ -33,6 +33,32 @@ __FBSDID("$FreeBSD$");
 #include <sys/xattr.h>
 #endif
 
+//
+// The test ACL used here is sometimes assigned to the 'Guest' user
+// This changes the text and breaks the test.  This function simply
+// strips the 'Guest' information from the string to help ensure
+// consistent results on different machines.
+//
+static char _acl_temp[256];
+static const char *
+clean_acl(const char *acl) {
+       char *p, *q;
+       if (strlen(acl) >= sizeof(_acl_temp))
+               return acl;
+
+       strcpy(_acl_temp, acl);
+       p = strstr(_acl_temp, ":Guest:");
+       if (p != NULL) {
+               fprintf(stderr, "Shortening: %s\n", p + 1);
+               memmove(p + 1, p + 6, strlen(p + 6) + 1);
+               q = strstr(p + 2, ":");
+               fprintf(stderr, "Shortening: %s\n", q);
+               memmove(p + 2, q, strlen(q) + 1);
+               return _acl_temp;
+       }
+       return _acl_temp;
+}
+
 #if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\
        && defined(HAVE_ZLIB_H)
 static int
@@ -136,9 +162,9 @@ DEFINE_TEST(test_write_disk_appledouble)
        failure("'%s' should have decompfs xattr", "file3");
        assertEqualInt(1, has_xattr("file3", "com.apple.decmpfs"));
        assert(NULL != (acl = acl_get_file("file3", ACL_TYPE_EXTENDED)));
-       assertEqualString(acl_to_text(acl, NULL),
+       assertEqualString(clean_acl(acl_to_text(acl, NULL)),
            "!#acl 1\n"
-           "user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000C9:Guest:201:deny:read\n"
+           "user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000C9:::deny:read\n"
            "group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000050:admin:80:allow:write\n"
        );
        if (acl) acl_free(acl);
@@ -195,9 +221,9 @@ DEFINE_TEST(test_write_disk_appledouble)
        failure("'%s' should not have decmpfs", "file3");
        assertEqualInt(0, has_xattr("file3", "com.apple.decmpfs"));
        assert(NULL != (acl = acl_get_file("file3", ACL_TYPE_EXTENDED)));
-       assertEqualString(acl_to_text(acl, NULL),
+       assertEqualString(clean_acl(acl_to_text(acl, NULL)),
            "!#acl 1\n"
-           "user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000C9:Guest:201:deny:read\n"
+           "user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000C9:::deny:read\n"
            "group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000050:admin:80:allow:write\n"
        );
        if (acl) acl_free(acl);
index b834a58ed5cac19b41b79fe6e0affd31b2397b76..eb2bd5633c6b0bab40c17f28403b6ce0095468b9 100644 (file)
@@ -33,6 +33,32 @@ __FBSDID("$FreeBSD$");
 #include <sys/xattr.h>
 #endif
 
+//
+// The test ACL used here is sometimes assigned to the 'Guest' user
+// This changes the text and breaks the test.  This function simply
+// strips the 'Guest' information from the string to help ensure
+// consistent results on different machines.
+//
+static char _acl_temp[256];
+static const char *
+clean_acl(const char *acl) {
+       char *p, *q;
+       if (strlen(acl) >= sizeof(_acl_temp))
+               return acl;
+
+       strcpy(_acl_temp, acl);
+       p = strstr(_acl_temp, ":Guest:");
+       if (p != NULL) {
+               fprintf(stderr, "Shortening: %s\n", p + 1);
+               memmove(p + 1, p + 6, strlen(p + 6) + 1);
+               q = strstr(p + 2, ":");
+               fprintf(stderr, "Shortening: %s\n", q);
+               memmove(p + 2, q, strlen(q) + 1);
+               return _acl_temp;
+       }
+       return _acl_temp;
+}
+
 #if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\
        && defined(HAVE_ZLIB_H)
 static int
@@ -129,9 +155,9 @@ DEFINE_TEST(test_write_disk_mac_metadata)
        failure("'%s' should have decompfs xattr", "file3");
        assertEqualInt(1, has_xattr("file3", "com.apple.decmpfs"));
        assert(NULL != (acl = acl_get_file("file3", ACL_TYPE_EXTENDED)));
-       assertEqualString(acl_to_text(acl, NULL),
+       assertEqualString(clean_acl(acl_to_text(acl, NULL)),
            "!#acl 1\n"
-           "user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000C9:Guest:201:deny:read\n"
+           "user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000C9:::deny:read\n"
            "group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000050:admin:80:allow:write\n"
        );
        if (acl) acl_free(acl);
@@ -180,9 +206,9 @@ DEFINE_TEST(test_write_disk_mac_metadata)
        failure("'%s' should not have decmpfs", "file3");
        assertEqualInt(0, has_xattr("file3", "com.apple.decmpfs"));
        assert(NULL != (acl = acl_get_file("file3", ACL_TYPE_EXTENDED)));
-       assertEqualString(acl_to_text(acl, NULL),
+       assertEqualString(clean_acl(acl_to_text(acl, NULL)),
            "!#acl 1\n"
-           "user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000C9:Guest:201:deny:read\n"
+           "user:FFFFEEEE-DDDD-CCCC-BBBB-AAAA000000C9:::deny:read\n"
            "group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF00000050:admin:80:allow:write\n"
        );
        if (acl) acl_free(acl);