Date: Thu, 9 Sep 2004 09:39:50 +0200 (CEST) From: Andre Albsmeier <andre.albsmeier@siemens.com> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/71513: [PATCH] allow -user/group +/-id constructs in find(1) Message-ID: <200409090739.i897dox6008632@curry.mchp.siemens.de> Resent-Message-ID: <200409090740.i897eJei041546@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 71513 >Category: bin >Synopsis: [PATCH] allow -user/group +/-id constructs in find(1) >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Thu Sep 09 07:40:18 GMT 2004 >Closed-Date: >Last-Modified: >Originator: Andre Albsmeier >Release: FreeBSD 4.10-STABLE i386 >Organization: >Environment: System: FreeBSD 4.10-STABLE #0: Thu Aug 5 12:18:13 CEST 2004 >Description: find(1) currently doesn't allow the use of -user (-group) primaries with numeric arguments and +/- prefixes. >How-To-Repeat: find . -user +999 >Fix: The patch below adds this feature. As a side effect, it enhances the detection of invalid numerical arguments: Before, the command find . -user 0bla1 found all files belonging to root. This is now honoured with an error message. However, the existing logic to detect args which obviously should have been usernames was adjusted so commands like find . -user bla still spit out the "no such user" message as they did before (if bla doesn't exist, of course). --- usr.bin/find/function.c.ORI Wed Jun 16 19:03:23 2004 +++ usr.bin/find/function.c Thu Sep 9 09:00:55 2004 @@ -862,7 +862,7 @@ PLAN *plan; FTSENT *entry; { - return entry->fts_statp->st_gid == plan->g_data; + COMPARE(entry->fts_statp->st_gid, plan->g_data); } PLAN * @@ -878,15 +878,19 @@ gname = nextarg(option, argvp); ftsoptions &= ~FTS_NOSTAT; + new = palloc(option); g = getgrnam(gname); if (g == NULL) { + char* cp = gname; + if( gname[0] == '-' || gname[0] == '+' ) + gname++; gid = atoi(gname); if (gid == 0 && gname[0] != '0') errx(1, "%s: %s: no such group", option->name, gname); + gid = find_parsenum(new, option->name, cp, NULL); } else gid = g->gr_gid; - new = palloc(option); new->g_data = gid; return new; } @@ -1435,7 +1439,7 @@ PLAN *plan; FTSENT *entry; { - return entry->fts_statp->st_uid == plan->u_data; + COMPARE(entry->fts_statp->st_uid, plan->u_data); } PLAN * @@ -1451,15 +1455,19 @@ username = nextarg(option, argvp); ftsoptions &= ~FTS_NOSTAT; + new = palloc(option); p = getpwnam(username); if (p == NULL) { + char* cp = username; + if( username[0] == '-' || username[0] == '+' ) + username++; uid = atoi(username); if (uid == 0 && username[0] != '0') errx(1, "%s: %s: no such user", option->name, username); + uid = find_parsenum(new, option->name, cp, NULL); } else uid = p->pw_uid; - new = palloc(option); new->u_data = uid; return new; } >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200409090739.i897dox6008632>