#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
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);
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);
#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
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);
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);