aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/find/function.c
diff options
context:
space:
mode:
authorBosko Milekic <bmilekic@FreeBSD.org>2004-04-03 17:10:04 +0000
committerBosko Milekic <bmilekic@FreeBSD.org>2004-04-03 17:10:04 +0000
commit9c5d31dff2f1e62c01964e9959f997fe1b6169d2 (patch)
treefdb94cf9e8ca2a9605f8284a0491cc62e9a02a89 /usr.bin/find/function.c
parent263377339cd8d5cb97519ba9595a03828d0ca99c (diff)
Notes
Diffstat (limited to 'usr.bin/find/function.c')
-rw-r--r--usr.bin/find/function.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c
index 3ba755517fdb..72bf8aae6f65 100644
--- a/usr.bin/find/function.c
+++ b/usr.bin/find/function.c
@@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/ucred.h>
#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/acl.h>
#include <sys/wait.h>
#include <sys/mount.h>
#include <sys/timeb.h>
@@ -352,6 +354,55 @@ c_mXXdepth(OPTION *option, char ***argvp)
}
/*
+ * -acl function --
+ *
+ * Show files with EXTENDED ACL attributes.
+ */
+int
+f_acl(PLAN *plan__unused, FTSENT *entry)
+{
+ int match, entries;
+ acl_entry_t ae;
+ acl_t facl;
+
+ 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;
+ }
+ 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;
+ }
+ }
+ }
+ acl_free(facl);
+ } else
+ warn("%s", entry->fts_accpath);
+ return match;
+}
+
+PLAN *
+c_acl(OPTION *option, char ***argvp__unused)
+{
+ ftsoptions &= ~FTS_NOSTAT;
+ return (palloc(option));
+}
+
+/*
* -delete functions --
*
* True always. Makes its best shot and continues on regardless.