From c40ea1328bb33abaec14f1fc92ac2349b5ee2715 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Tue, 14 Jul 2015 22:29:16 -0700 Subject: Merge from gnulib This incorporates: 2015-07-05 acl-permissions: Document FreeBSD ACL_TYPE_NFS4 acls 2015-07-05 acl-permissions: Fix on FreeBSD 2015-07-05 file-has-acl, acl-permissions: fix some more HP-UX typos * lib/acl-internal.c, lib/acl-internal.h, lib/get-permissions.c: * lib/set-permissions.c: Copy from gnulib. --- lib/acl-internal.c | 7 +++++++ lib/acl-internal.h | 6 ++++++ lib/get-permissions.c | 6 ++++++ lib/set-permissions.c | 12 +++++++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/acl-internal.c b/lib/acl-internal.c index 1a2f8c44bf..1eaa671bd3 100644 --- a/lib/acl-internal.c +++ b/lib/acl-internal.c @@ -115,6 +115,13 @@ acl_access_nontrivial (acl_t acl) # endif } +int +acl_default_nontrivial (acl_t acl) +{ + /* acl is non-trivial if it is non-empty. */ + return (acl_entries (acl) > 0); +} + # endif #elif USE_ACL && HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ diff --git a/lib/acl-internal.h b/lib/acl-internal.h index 4f042adc96..38a4ab2eb3 100644 --- a/lib/acl-internal.h +++ b/lib/acl-internal.h @@ -155,6 +155,12 @@ extern int acl_extended_nontrivial (acl_t); Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. Return -1 and set errno upon failure to determine it. */ extern int acl_access_nontrivial (acl_t); + +/* ACL is an ACL, from a file, stored as type ACL_TYPE_DEFAULT. + Return 1 if the given ACL is non-trivial. + Return 0 if it is trivial, i.e. equivalent to a simple stat() mode. + Return -1 and set errno upon failure to determine it. */ +extern int acl_default_nontrivial (acl_t); # endif # elif HAVE_FACL && defined GETACL /* Solaris, Cygwin, not HP-UX */ diff --git a/lib/get-permissions.c b/lib/get-permissions.c index 6c6618df98..459513c925 100644 --- a/lib/get-permissions.c +++ b/lib/get-permissions.c @@ -60,6 +60,12 @@ get_permissions (const char *name, int desc, mode_t mode, return -1; } +# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */ + + /* TODO (see set_permissions). */ + +# endif + # else /* HAVE_ACL_TYPE_EXTENDED */ /* Mac OS X */ diff --git a/lib/set-permissions.c b/lib/set-permissions.c index 25c463d966..1aa5b4941c 100644 --- a/lib/set-permissions.c +++ b/lib/set-permissions.c @@ -530,7 +530,8 @@ set_acls (struct permission_context *ctx, const char *name, int desc, *acls_set = true; if (S_ISDIR(ctx->mode)) { - if (! from_mode && ctx->default_acl) + if (! from_mode && ctx->default_acl && + acl_default_nontrivial (ctx->default_acl)) ret = acl_set_file (name, ACL_TYPE_DEFAULT, ctx->default_acl); else @@ -540,6 +541,15 @@ set_acls (struct permission_context *ctx, const char *name, int desc, } } +# if HAVE_ACL_TYPE_NFS4 /* FreeBSD */ + + /* File systems either support POSIX ACLs (for example, ufs) or NFS4 ACLs + (for example, zfs). */ + + /* TODO: Implement setting ACLs once get_permissions() reads them. */ + +# endif + # else /* HAVE_ACL_TYPE_EXTENDED */ /* Mac OS X */ -- cgit v1.2.3