From owner-freebsd-bugs@FreeBSD.ORG Thu Sep 9 07:40:19 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 509D816A4CE for ; Thu, 9 Sep 2004 07:40:19 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 2FD8A43D5C for ; Thu, 9 Sep 2004 07:40:19 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i897eJh1041550 for ; Thu, 9 Sep 2004 07:40:19 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i897eJei041546; Thu, 9 Sep 2004 07:40:19 GMT (envelope-from gnats) Resent-Date: Thu, 9 Sep 2004 07:40:19 GMT Resent-Message-Id: <200409090740.i897eJei041546@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Andre Albsmeier Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EE2BE16A4CE for ; Thu, 9 Sep 2004 07:39:57 +0000 (GMT) Received: from goliath.siemens.de (goliath.siemens.de [192.35.17.28]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3D96443D2F for ; Thu, 9 Sep 2004 07:39:57 +0000 (GMT) (envelope-from andre.albsmeier@siemens.com) Received: from mail1.siemens.de (mail1.siemens.de [139.23.33.14]) by goliath.siemens.de (8.12.6/8.12.6) with ESMTP id i897dtec005828 for ; Thu, 9 Sep 2004 09:39:55 +0200 Received: from mars.cert.siemens.com (mars.cert.siemens.com [139.25.19.9]) by mail1.siemens.de (8.12.6/8.12.6) with ESMTP id i897dtW1003931 for ; Thu, 9 Sep 2004 09:39:55 +0200 Received: from curry.mchp.siemens.de (curry.mchp.siemens.de [139.25.42.7]) mail/cert.mc.pre,v 1.62 2004/08/23 18:38:16 mailadm Exp $) with ESMTP id i897dtva087231 for ; Thu, 9 Sep 2004 09:39:55 +0200 (CEST) Received: (from localhost) by curry.mchp.siemens.de (8.13.1/8.13.1) id i897doqB094112 for FreeBSD-gnats-submit@freebsd.org; Thu, 9 Sep 2004 09:39:50 +0200 (CEST) Message-Id: <200409090739.i897dox6008632@curry.mchp.siemens.de> Date: Thu, 9 Sep 2004 09:39:50 +0200 (CEST) From: Andre Albsmeier To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 Subject: bin/71513: [PATCH] allow -user/group +/-id constructs in find(1) X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Sep 2004 07:40:19 -0000 >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: