aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/find
diff options
context:
space:
mode:
authorEdward Tomasz Napierala <trasz@FreeBSD.org>2009-09-04 20:01:16 +0000
committerEdward Tomasz Napierala <trasz@FreeBSD.org>2009-09-04 20:01:16 +0000
commitfa2db9145a26f6194ece563aa6ac7f6217dc99e9 (patch)
tree7dbe6acb53bab02bde9478032cbf57ec61c5a686 /usr.bin/find
parentaf582ea7afc05fc6b15596dd3a058adc4d81cbf7 (diff)
downloadsrc-fa2db9145a26f6194ece563aa6ac7f6217dc99e9.tar.gz
src-fa2db9145a26f6194ece563aa6ac7f6217dc99e9.zip
Add NFSv4 ACL support to find(1).
Reviewed by: rwatson
Notes
Notes: svn path=/head/; revision=196839
Diffstat (limited to 'usr.bin/find')
-rw-r--r--usr.bin/find/function.c60
1 files changed, 35 insertions, 25 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index bfa0a36a9c55..c11d24f8bab7 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -371,38 +371,48 @@ c_mXXdepth(OPTION *option, char ***argvp)
int
f_acl(PLAN *plan __unused, FTSENT *entry)
{
- int match, entries;
- acl_entry_t ae;
acl_t facl;
+ acl_type_t acl_type;
+ int acl_supported = 0, ret, trivial;
if (S_ISLNK(entry->fts_statp->st_mode))
return 0;
- if ((match = pathconf(entry->fts_accpath, _PC_ACL_EXTENDED)) <= 0) {
- if (match < 0 && errno != EINVAL)
- warn("%s", entry->fts_accpath);
- else
- return 0;
+ ret = pathconf(entry->fts_accpath, _PC_ACL_NFS4);
+ if (ret > 0) {
+ acl_supported = 1;
+ acl_type = ACL_TYPE_NFS4;
+ } else if (ret < 0 && errno != EINVAL) {
+ warn("%s", entry->fts_accpath);
+ return (0);
}
- match = 0;
- if ((facl = acl_get_file(entry->fts_accpath,ACL_TYPE_ACCESS)) != NULL) {
- if (acl_get_entry(facl, ACL_FIRST_ENTRY, &ae) == 1) {
- /*
- * POSIX.1e requires that ACLs of type ACL_TYPE_ACCESS
- * must have at least three entries (owner, group,
- * other).
- */
- entries = 1;
- while (acl_get_entry(facl, ACL_NEXT_ENTRY, &ae) == 1) {
- if (++entries > 3) {
- match = 1;
- break;
- }
- }
+ if (acl_supported == 0) {
+ ret = pathconf(entry->fts_accpath, _PC_ACL_EXTENDED);
+ if (ret > 0) {
+ acl_supported = 1;
+ acl_type = ACL_TYPE_ACCESS;
+ } else if (ret < 0 && errno != EINVAL) {
+ warn("%s", entry->fts_accpath);
+ return (0);
}
- acl_free(facl);
- } else
+ }
+ if (acl_supported == 0)
+ return (0);
+
+ facl = acl_get_file(entry->fts_accpath, acl_type);
+ if (facl == NULL) {
warn("%s", entry->fts_accpath);
- return match;
+ return (0);
+ }
+ ret = acl_is_trivial_np(facl, &trivial);
+ acl_free(facl);
+ if (ret) {
+ warn("%s", entry->fts_accpath);
+ acl_free(facl);
+ return (0);
+ }
+ if (trivial)
+ return (0);
+ return (1);
}
PLAN *