From: Tim Kientzle Date: Wed, 21 Oct 2015 08:08:20 +0000 (-0700) Subject: When comparing ACLs for these tests, ignore 'Guest' account X-Git-Tag: v3.1.900a~63 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8e388bb8dc9a222896982782488ada111579b731;p=thirdparty%2Flibarchive.git When comparing ACLs for these tests, ignore 'Guest' account information that may vary between machines. --- diff --git a/libarchive/test/test_write_disk_appledouble.c b/libarchive/test/test_write_disk_appledouble.c index 4f1850b3d..502fac316 100644 --- a/libarchive/test/test_write_disk_appledouble.c +++ b/libarchive/test/test_write_disk_appledouble.c @@ -33,6 +33,32 @@ __FBSDID("$FreeBSD$"); #include #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); diff --git a/libarchive/test/test_write_disk_mac_metadata.c b/libarchive/test/test_write_disk_mac_metadata.c index b834a58ed..eb2bd5633 100644 --- a/libarchive/test/test_write_disk_mac_metadata.c +++ b/libarchive/test/test_write_disk_mac_metadata.c @@ -33,6 +33,32 @@ __FBSDID("$FreeBSD$"); #include #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);