[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    [PATCH] support for find -user
From:       Natanael Copa <natanael.copa () gmail ! com>
Date:       2007-01-31 20:55:31
Message-ID: 1170276931.18296.5.camel () studio
[Download RAW message or body]

The attatched patch adds support for option -user. The arg to -user can
be either username or uid.

Would be nice if it could be committed.
Thanks!

["bb-find-user.patch" (bb-find-user.patch)]

Index: findutils/find.c
===================================================================
--- findutils/find.c	(revision 17686)
+++ findutils/find.c	(working copy)
@@ -68,6 +68,7 @@
 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 @@
 }
 #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 @@
 				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_strtoul(arg1, (char **)NULL, 10);
+			if (errno)
+				ap->uid = xuname2uid(arg1);
+		}
+#endif
 #if ENABLE_DESKTOP
 		else if (LONE_CHAR(arg, '(')) {
 			action_paren *ap;
Index: findutils/Config.in
===================================================================
--- findutils/Config.in	(revision 17686)
+++ findutils/Config.in	(working copy)
@@ -83,6 +83,13 @@
 	  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


_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic