summaryrefslogtreecommitdiff
path: root/findutils
diff options
context:
space:
mode:
authorDenis Vlasenko2007-02-02 01:17:52 +0000
committerDenis Vlasenko2007-02-02 01:17:52 +0000
commita100707c04a41510bfe3460bf15a88c339ce4f30 (patch)
tree576d48e7a524624804c06891b37649965881b798 /findutils
parent731d3572959774b36bab415bd1ae8bcd1958639b (diff)
downloadbusybox-a100707c04a41510bfe3460bf15a88c339ce4f30.zip
busybox-a100707c04a41510bfe3460bf15a88c339ce4f30.tar.gz
find -user support by Natanael Copa <natanael.copa@gmail.com>
Diffstat (limited to 'findutils')
-rw-r--r--findutils/Config.in7
-rw-r--r--findutils/find.c19
2 files changed, 26 insertions, 0 deletions
diff --git a/findutils/Config.in b/findutils/Config.in
index 5a4476a..73ce36f 100644
--- a/findutils/Config.in
+++ b/findutils/Config.in
@@ -83,6 +83,13 @@ config FEATURE_FIND_EXEC
Support the 'find -exec' option for executing commands based upon
the files matched.
+config FEATURE_FIND_USER
+ bool "Enable username/uid matching (-user) option"
+ default y
+ depends on FIND
+ help
+ Support the 'find -user' option for searching by username or uid.
+
config GREP
bool "grep"
default n
diff --git a/findutils/find.c b/findutils/find.c
index 0c22ee6..2decb36 100644
--- a/findutils/find.c
+++ b/findutils/find.c
@@ -68,6 +68,7 @@ USE_FEATURE_FIND_MMIN( ACTS(mmin, char mmin_char; unsigned mmin_mins;))
USE_FEATURE_FIND_NEWER( ACTS(newer, time_t newer_mtime;))
USE_FEATURE_FIND_INUM( ACTS(inum, ino_t inode_num;))
USE_FEATURE_FIND_EXEC( ACTS(exec, char **exec_argv; int *subst_count; int exec_argc;))
+USE_FEATURE_FIND_USER( ACTS(user, int uid;))
USE_DESKTOP( ACTS(paren, action ***subexpr;))
USE_DESKTOP( ACTS(size, off_t size;))
USE_DESKTOP( ACTS(prune))
@@ -212,6 +213,13 @@ ACTF(exec)
}
#endif
+#if ENABLE_FEATURE_FIND_USER
+ACTF(user)
+{
+ return (statbuf->st_uid == ap->uid);
+}
+#endif
+
#if ENABLE_FEATURE_FIND_PRINT0
ACTF(print0)
{
@@ -478,6 +486,17 @@ static action*** parse_params(char **argv)
ap->subst_count[i] = count_subst(ap->exec_argv[i]);
}
#endif
+#ifdef ENABLE_FEATURE_FIND_USER
+ else if (strcmp(arg, "-user") == 0) {
+ action_user *ap;
+ if (!*++argv)
+ bb_error_msg_and_die(bb_msg_requires_arg, arg);
+ ap = ALLOC_ACTION(user);
+ ap->uid = bb_strtou(arg1, NULL, 10);
+ if (errno)
+ ap->uid = xuname2uid(arg1);
+ }
+#endif
#if ENABLE_DESKTOP
else if (LONE_CHAR(arg, '(')) {
action_paren *ap;