From 3e2d23f909272476403e9cfd83e4f5c8c0110d07 Mon Sep 17 00:00:00 2001 From: trasz Date: Mon, 20 Sep 2010 17:10:06 +0000 Subject: 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. --- lib/libc/posix1e/acl_strip.c | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'lib/libc/posix1e') 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 #include #include +#include #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); -- cgit v1.1