summaryrefslogtreecommitdiff
path: root/test_utils
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.org>2017-03-13 15:49:38 +0100
committerMartin Matuska <martin@matuska.org>2017-03-14 12:48:53 +0100
commitf57d129d828f411d6f1eb81ca51dfd9e1fead353 (patch)
tree2683fbe533ae01206a3e0a2365ae2d263eb5e697 /test_utils
parent500b90526996eb64b9cb5a02ac9de61f0a2ec14f (diff)
downloadlibarchive-f57d129d828f411d6f1eb81ca51dfd9e1fead353.tar.gz
Move platform-specific ACL code to individual source files.
This makes the code much more readable and eases the addition of new ACL implementatons in the future. Additional changes: - most of ACL detection is now done at configure stage - configuration now reports what ACL was detected - NFSv4 ACL tests now test INHERIT_ONLY and NO_PROPAGATE_INHERIT
Diffstat (limited to 'test_utils')
-rw-r--r--test_utils/test_common.h38
-rw-r--r--test_utils/test_main.c55
2 files changed, 31 insertions, 62 deletions
diff --git a/test_utils/test_common.h b/test_utils/test_common.h
index 44215a35..43cbc5ed 100644
--- a/test_utils/test_common.h
+++ b/test_utils/test_common.h
@@ -127,43 +127,11 @@
#define O_BINARY 0
#endif
-/*
- * If this platform has <sys/acl.h>, acl_create(), acl_init(),
- * acl_set_file(), and ACL_USER, we assume it has the rest of the
- * POSIX.1e draft functions used in archive_read_extract.c.
- */
-#if HAVE_SYS_ACL_H && HAVE_ACL_CREATE_ENTRY && HAVE_ACL_INIT && HAVE_ACL_SET_FILE
-#if HAVE_DECL_ACL_USER
-#define HAVE_POSIX_ACL 1
-#elif HAVE_DECL_ACL_TYPE_EXTENDED && HAVE_MEMBERSHIP_H
-#define HAVE_DARWIN_ACL 1
-#endif
-#if HAVE_DECL_ACL_TYPE_NFS4
-#define HAVE_FREEBSD_NFS4_ACL 1
-#endif
-#endif
-
-/*
- * If this platform has <sys/acl.h>, acl_get(), facl_get(), acl_set(),
- * facl_set() and types aclent_t and ace_t it uses Solaris-style ACL functions
- */
-#if HAVE_SYS_ACL_H && HAVE_ACL && HAVE_FACL && HAVE_ACLENT_T && \
- HAVE_DECL_GETACL && HAVE_DECL_GETACLCNT && HAVE_DECL_SETACL
-#define HAVE_SUN_ACL 1
-#if HAVE_ACE_T && HAVE_DECL_ACE_GETACL && HAVE_DECL_ACE_GETACLCNT && \
- HAVE_DECL_ACE_SETACL
-#define HAVE_SUN_NFS4_ACL 1
-#endif
-#endif
-
-/* Define if platform supports NFSv4 ACLs */
-#if HAVE_FREEBSD_NFS4_ACL || HAVE_SUN_NFS4_ACL || HAVE_DARWIN_ACL
-#define HAVE_NFS4_ACL 1
-#endif
-
+#include "archive_platform_acl.h"
#define ARCHIVE_TEST_ACL_TYPE_POSIX1E 1
#define ARCHIVE_TEST_ACL_TYPE_NFS4 2
+
/*
* Redefine DEFINE_TEST for use in defining the test functions.
*/
@@ -378,7 +346,7 @@ int setTestAcl(const char *path);
/* Return true if the file has large i-node number(>0xffffffff). */
int is_LargeInode(const char *);
-#if HAVE_SUN_ACL
+#if ARCHIVE_ACL_SUNOS
/* Fetch ACLs on Solaris using acl() or facl() */
void *sunacl_get(int cmd, int *aclcnt, int fd, const char *path);
#endif
diff --git a/test_utils/test_main.c b/test_utils/test_main.c
index 5d0e287d..699dcf8d 100644
--- a/test_utils/test_main.c
+++ b/test_utils/test_main.c
@@ -56,7 +56,8 @@
#include <stdarg.h>
#include <time.h>
-/* ACL support */
+#ifdef HAVE_SIGNAL_H
+#endif
#ifdef HAVE_ACL_LIBACL_H
#include <acl/libacl.h>
#endif
@@ -66,7 +67,7 @@
#ifdef HAVE_SYS_ACL_H
#include <sys/acl.h>
#endif
-#if HAVE_DARWIN_ACL
+#if HAVE_MEMBERSHIP_H
#include <membership.h>
#endif
@@ -2436,7 +2437,7 @@ canNodump(void)
return (0);
}
-#if HAVE_SUN_ACL
+#if ARCHIVE_ACL_SUNOS
/* Fetch ACLs on Solaris using acl() or facl() */
void *
sunacl_get(int cmd, int *aclcnt, int fd, const char *path)
@@ -2449,7 +2450,7 @@ sunacl_get(int cmd, int *aclcnt, int fd, const char *path)
cntcmd = GETACLCNT;
size = sizeof(aclent_t);
}
-#if HAVE_SUN_NFS4_ACL
+#if ARCHIVE_ACL_SUNOS_NFS4
else if (cmd == ACE_GETACL) {
cntcmd = ACE_GETACLCNT;
size = sizeof(ace_t);
@@ -2492,7 +2493,7 @@ sunacl_get(int cmd, int *aclcnt, int fd, const char *path)
*aclcnt = cnt;
return (aclp);
}
-#endif /* HAVE_SUN_ACL */
+#endif /* ARCHIVE_ACL_SUNOS */
/*
* Set test ACLs on a path
@@ -2504,19 +2505,19 @@ sunacl_get(int cmd, int *aclcnt, int fd, const char *path)
int
setTestAcl(const char *path)
{
-#if HAVE_POSIX_ACL || HAVE_NFS4_ACL
+#if ARCHIVE_ACL_SUPPORT
int r = 1;
-#if !HAVE_SUN_ACL
+#if !ARCHIVE_ACL_SUNOS
acl_t acl;
#endif
-#if HAVE_POSIX_ACL /* Linux, FreeBSD POSIX.1e */
+#if ARCHIVE_ACL_LIBACL || ARCHIVE_ACL_FREEBSD
const char *acltext_posix1e = "user:1:rw-,"
"group:15:r-x,"
"user::rwx,"
"group::rwx,"
"other::r-x,"
"mask::rwx";
-#elif HAVE_SUN_ACL /* Solaris POSIX.1e */
+#elif ARCHIVE_ACL_SUNOS /* Solaris POSIX.1e */
aclent_t aclp_posix1e[] = {
{ USER_OBJ, -1, 4 | 2 | 1 },
{ USER, 1, 4 | 2 },
@@ -2526,13 +2527,13 @@ setTestAcl(const char *path)
{ OTHER_OBJ, -1, 4 | 2 | 1 }
};
#endif
-#if HAVE_FREEBSD_NFS4_ACL /* FreeBSD NFS4 */
+#if ARCHIVE_ACL_FREEBSD /* FreeBSD NFS4 */
const char *acltext_nfs4 = "user:1:rwpaRcs::allow:1,"
"group:15:rxaRcs::allow:15,"
"owner@:rwpxaARWcCos::allow,"
"group@:rwpxaRcs::allow,"
"everyone@:rxaRcs::allow";
-#elif HAVE_SUN_NFS4_ACL /* Solaris NFS4 */
+#elif ARCHIVE_ACL_SUNOS_NFS4 /* Solaris NFS4 */
ace_t aclp_nfs4[] = {
{ 1, ACE_READ_DATA | ACE_WRITE_DATA | ACE_APPEND_DATA |
ACE_READ_ATTRIBUTES | ACE_READ_NAMED_ATTRS | ACE_READ_ACL |
@@ -2553,7 +2554,7 @@ setTestAcl(const char *path)
ACE_READ_NAMED_ATTRS | ACE_READ_ACL | ACE_SYNCHRONIZE,
ACE_EVERYONE, ACE_ACCESS_ALLOWED_ACE_TYPE }
};
-#elif HAVE_DARWIN_ACL /* Mac OS X */
+#elif ARCHIVE_ACL_DARWIN /* Mac OS X */
acl_entry_t aclent;
acl_permset_t permset;
const uid_t uid = 1;
@@ -2571,14 +2572,14 @@ setTestAcl(const char *path)
ACL_SYNCHRONIZE
#endif
};
-#endif /* HAVE_DARWIN_ACL */
+#endif /* ARCHIVE_ACL_DARWIN */
-#if HAVE_FREEBSD_NFS4_ACL
+#if ARCHIVE_ACL_FREEBSD
acl = acl_from_text(acltext_nfs4);
failure("acl_from_text() error: %s", strerror(errno));
if (assert(acl != NULL) == 0)
return (0);
-#elif HAVE_DARWIN_ACL
+#elif ARCHIVE_ACL_DARWIN
acl = acl_init(1);
failure("acl_init() error: %s", strerror(errno));
if (assert(acl != NULL) == 0)
@@ -2613,25 +2614,25 @@ setTestAcl(const char *path)
failure("acl_set_qualifier() error: %s", strerror(errno));
if (assertEqualInt(r, 0) == 0)
goto testacl_free;
-#endif /* HAVE_DARWIN_ACL */
+#endif /* ARCHIVE_ACL_DARWIN */
-#if HAVE_NFS4_ACL
-#if HAVE_FREEBSD_NFS4_ACL
+#if ARCHIVE_ACL_NFS4
+#if ARCHIVE_ACL_FREEBSD
r = acl_set_file(path, ACL_TYPE_NFS4, acl);
acl_free(acl);
-#elif HAVE_SUN_NFS4_ACL
+#elif ARCHIVE_ACL_SUNOS_NFS4
r = acl(path, ACE_SETACL,
(int)(sizeof(aclp_nfs4)/sizeof(aclp_nfs4[0])), aclp_nfs4);
-#elif HAVE_DARWIN_ACL
+#elif ARCHIVE_ACL_DARWIN
r = acl_set_file(path, ACL_TYPE_EXTENDED, acl);
acl_free(acl);
#endif
if (r == 0)
return (ARCHIVE_TEST_ACL_TYPE_NFS4);
-#endif /* HAVE_NFS4_ACL */
+#endif /* ARCHIVE_ACL_NFS4 */
-#if HAVE_POSIX_ACL || HAVE_SUN_ACL
-#if HAVE_POSIX_ACL
+#if ARCHIVE_ACL_POSIX1E
+#if ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_LIBACL
acl = acl_from_text(acltext_posix1e);
failure("acl_from_text() error: %s", strerror(errno));
if (assert(acl != NULL) == 0)
@@ -2639,7 +2640,7 @@ setTestAcl(const char *path)
r = acl_set_file(path, ACL_TYPE_ACCESS, acl);
acl_free(acl);
-#elif HAVE_SUN_ACL
+#elif ARCHIVE_ACL_SUNOS
r = acl(path, SETACL,
(int)(sizeof(aclp_posix1e)/sizeof(aclp_posix1e[0])), aclp_posix1e);
#endif
@@ -2647,12 +2648,12 @@ setTestAcl(const char *path)
return (ARCHIVE_TEST_ACL_TYPE_POSIX1E);
else
return (0);
-#endif /* HAVE_POSIX_ACL || HAVE_SUN_ACL */
-#if HAVE_DARWIN_ACL
+#endif /* ARCHIVE_ACL_POSIX1E */
+#if ARCHIVE_ACL_DARWIN
testacl_free:
acl_free(acl);
#endif
-#endif /* HAVE_POSIX_ACL || HAVE_NFS4_ACL */
+#endif /* ARCHIVE_ACL_SUPPORT */
(void)path; /* UNUSED */
return (0);
}