diff options
| author | Martin Matuska <mm@FreeBSD.org> | 2017-03-20 11:12:31 +0000 |
|---|---|---|
| committer | Martin Matuska <mm@FreeBSD.org> | 2017-03-20 11:12:31 +0000 |
| commit | 4a7f6834348e3853977e1b7d69ff44f6eb93313c (patch) | |
| tree | 27f68e9bbe812cb11d4094911825d437242a25d7 /test_utils/test_main.c | |
| parent | 086ca70a2894f87d7cd5ac72a6d891b00d5b4dc5 (diff) | |
Notes
Diffstat (limited to 'test_utils/test_main.c')
| -rw-r--r-- | test_utils/test_main.c | 82 |
1 files changed, 53 insertions, 29 deletions
diff --git a/test_utils/test_main.c b/test_utils/test_main.c index 86ab5f1a489f..0ef6d6fcf7f0 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,10 @@ #ifdef HAVE_SYS_ACL_H #include <sys/acl.h> #endif -#if HAVE_DARWIN_ACL +#ifdef HAVE_SYS_RICHACL_H +#include <sys/richacl.h> +#endif +#if HAVE_MEMBERSHIP_H #include <membership.h> #endif @@ -2436,7 +2440,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 +2453,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 +2496,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 +2508,22 @@ 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_LIBACL || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_DARWIN acl_t acl; #endif -#if HAVE_POSIX_ACL /* Linux, FreeBSD POSIX.1e */ +#if ARCHIVE_ACL_LIBRICHACL + struct richacl *richacl; +#endif +#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 +2533,22 @@ 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_LIBRICHACL + const char *acltext_nfs4 = "owner:rwpxaARWcCoS::mask," + "group:rwpxaRcS::mask," + "other:rxaRcS::mask," + "user:1:rwpaRcS::allow," + "group:15:rxaRcS::allow," + "owner@:rwpxaARWcCoS::allow," + "group@:rwpxaRcS::allow," + "everyone@:rxaRcS::allow"; +#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 +2569,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 +2587,19 @@ 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_LIBRICHACL + richacl = richacl_from_text(acltext_nfs4, NULL, NULL); + failure("richacl_from_text() error: %s", strerror(errno)); + if (assert(richacl != NULL) == 0) + return (0); +#elif ARCHIVE_ACL_DARWIN acl = acl_init(1); failure("acl_init() error: %s", strerror(errno)); if (assert(acl != NULL) == 0) @@ -2605,33 +2626,36 @@ setTestAcl(const char *path) failure("acl_set_permset() error: %s", strerror(errno)); if (assertEqualInt(r, 0) == 0) goto testacl_free; - r = mbr_identifier_to_uuid(ID_TYPE_UID, &uid, sizeof(uid_t), uuid); - failure("mbr_identifier_to_uuid() error: %s", strerror(errno)); + r = mbr_uid_to_uuid(uid, uuid); + failure("mbr_uid_to_uuid() error: %s", strerror(errno)); if (assertEqualInt(r, 0) == 0) goto testacl_free; r = acl_set_qualifier(aclent, uuid); 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_LIBRICHACL + r = richacl_set_file(path, richacl); + richacl_free(richacl); +#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 +2663,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 +2671,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); } |
