summaryrefslogtreecommitdiff
path: root/test_utils
diff options
context:
space:
mode:
authorMartin Matuska <martin@matuska.org>2017-03-15 23:27:48 +0100
committerMartin Matuska <martin@matuska.org>2017-03-16 11:39:08 +0100
commitbea9f9cf03b97018f2398df070193835b3822713 (patch)
tree843247e3d304df3a70d0b9ecee641b8e8ca33942 /test_utils
parentf57d129d828f411d6f1eb81ca51dfd9e1fead353 (diff)
downloadlibarchive-bea9f9cf03b97018f2398df070193835b3822713.tar.gz
Add NFSv4 ACL support for Linux via librichacl
Richacls are interpreted as NFSv4 ACLs and stored in archive_acl (Richacl flags and masks are not stored). Analog to mac_metadata, NFSv4 ACLs do not get extracted when the extraction of extended attributes is enabled and the "trusted.richacl" extended attribute is present. RichACL masks and are calculated from file mode on extraction. mac_metadata acl check has been moved in the code to be together with the richacl check.
Diffstat (limited to 'test_utils')
-rw-r--r--test_utils/test_main.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/test_utils/test_main.c b/test_utils/test_main.c
index 699dcf8d..0ef6d6fc 100644
--- a/test_utils/test_main.c
+++ b/test_utils/test_main.c
@@ -67,6 +67,9 @@
#ifdef HAVE_SYS_ACL_H
#include <sys/acl.h>
#endif
+#ifdef HAVE_SYS_RICHACL_H
+#include <sys/richacl.h>
+#endif
#if HAVE_MEMBERSHIP_H
#include <membership.h>
#endif
@@ -2507,9 +2510,12 @@ setTestAcl(const char *path)
{
#if ARCHIVE_ACL_SUPPORT
int r = 1;
-#if !ARCHIVE_ACL_SUNOS
+#if ARCHIVE_ACL_LIBACL || ARCHIVE_ACL_FREEBSD || ARCHIVE_ACL_DARWIN
acl_t acl;
#endif
+#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,"
@@ -2533,6 +2539,15 @@ setTestAcl(const char *path)
"owner@:rwpxaARWcCos::allow,"
"group@:rwpxaRcs::allow,"
"everyone@:rxaRcs::allow";
+#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 |
@@ -2579,6 +2594,11 @@ setTestAcl(const char *path)
failure("acl_from_text() error: %s", strerror(errno));
if (assert(acl != NULL) == 0)
return (0);
+#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));
@@ -2620,6 +2640,9 @@ setTestAcl(const char *path)
#if ARCHIVE_ACL_FREEBSD
r = acl_set_file(path, ACL_TYPE_NFS4, acl);
acl_free(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);