summaryrefslogtreecommitdiffstats
path: root/lib/libc/posix1e
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2010-09-20 17:10:06 +0000
committertrasz <trasz@FreeBSD.org>2010-09-20 17:10:06 +0000
commit3e2d23f909272476403e9cfd83e4f5c8c0110d07 (patch)
treef8114c58aa3c9da5fbe374cab1b67f84701f28fa /lib/libc/posix1e
parent154966ba66b85cf61d19a97a29e55b603e63a9ec (diff)
downloadFreeBSD-src-3e2d23f909272476403e9cfd83e4f5c8c0110d07.zip
FreeBSD-src-3e2d23f909272476403e9cfd83e4f5c8c0110d07.tar.gz
First step at adopting FreeBSD to support PSARC/2010/029. This makes
acl_is_trivial_np(3) properly recognize the new trivial ACLs. From the user point of view, that means "ls -l" no longer shows plus signs for all the files when running ZFS v28.
Diffstat (limited to 'lib/libc/posix1e')
-rw-r--r--lib/libc/posix1e/acl_strip.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/lib/libc/posix1e/acl_strip.c b/lib/libc/posix1e/acl_strip.c
index 82eacdc..c4065d6 100644
--- a/lib/libc/posix1e/acl_strip.c
+++ b/lib/libc/posix1e/acl_strip.c
@@ -31,19 +31,21 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
#include <assert.h>
#include <sys/acl.h>
+#include <sys/stat.h>
#include "acl_support.h"
/*
- * These two routines from sys/kern/subr_acl_nfs4.c are used by both kernel
+ * These three routines from sys/kern/subr_acl_nfs4.c are used by both kernel
* and libc.
*/
+void acl_nfs4_trivial_from_mode(struct acl *aclp, mode_t mode);
void acl_nfs4_sync_acl_from_mode(struct acl *aclp, mode_t mode,
int file_owner_id);
void acl_nfs4_sync_mode_from_acl(mode_t *_mode, const struct acl *aclp);
static acl_t
-_nfs4_acl_strip_np(const acl_t aclp, int recalculate_mask)
+_nfs4_acl_strip_np(const acl_t aclp, int canonical_six)
{
acl_t newacl;
mode_t mode = 0;
@@ -57,7 +59,10 @@ _nfs4_acl_strip_np(const acl_t aclp, int recalculate_mask)
_acl_brand_as(newacl, ACL_BRAND_NFS4);
acl_nfs4_sync_mode_from_acl(&mode, &(aclp->ats_acl));
- acl_nfs4_sync_acl_from_mode(&(newacl->ats_acl), mode, -1);
+ if (canonical_six)
+ acl_nfs4_sync_acl_from_mode(&(newacl->ats_acl), mode, -1);
+ else
+ acl_nfs4_trivial_from_mode(&(newacl->ats_acl), mode);
return (newacl);
}
@@ -136,7 +141,7 @@ acl_strip_np(const acl_t aclp, int recalculate_mask)
{
switch (_acl_brand(aclp)) {
case ACL_BRAND_NFS4:
- return (_nfs4_acl_strip_np(aclp, recalculate_mask));
+ return (_nfs4_acl_strip_np(aclp, 1));
case ACL_BRAND_POSIX:
return (_posix1e_acl_strip_np(aclp, recalculate_mask));
@@ -185,10 +190,25 @@ acl_is_trivial_np(const acl_t aclp, int *trivialp)
}
/*
- * Calculate trivial ACL - using acl_strip_np - and compare
+ * Calculate trivial ACL - using acl_strip_np(3) - and compare
* with the original.
*/
- tmpacl = acl_strip_np(aclp, 0);
+ tmpacl = _nfs4_acl_strip_np(aclp, 0);
+ if (tmpacl == NULL)
+ return (-1);
+
+ differs = _acl_differs(aclp, tmpacl);
+ acl_free(tmpacl);
+
+ if (differs == 0) {
+ *trivialp = 1;
+ return (0);
+ }
+
+ /*
+ * Try again with an old-style, "canonical six" trivial ACL.
+ */
+ tmpacl = _nfs4_acl_strip_np(aclp, 1);
if (tmpacl == NULL)
return (-1);
OpenPOWER on IntegriCloud