diff options
author | krion <krion@FreeBSD.org> | 2006-05-25 21:20:43 +0000 |
---|---|---|
committer | krion <krion@FreeBSD.org> | 2006-05-25 21:20:43 +0000 |
commit | 9c2cd9fe0d5cbaab62fc95836329ae5ce490689e (patch) | |
tree | 6a34a6dd47dcd0e79a615b301412f5b3638cf30e | |
parent | 401d20187f8d8ba614c3a31ead803e4d19d68a58 (diff) | |
download | FreeBSD-src-9c2cd9fe0d5cbaab62fc95836329ae5ce490689e.zip FreeBSD-src-9c2cd9fe0d5cbaab62fc95836329ae5ce490689e.tar.gz |
Enable numeric arguments and +/- prefixes with -user (-group)
options.
PR: bin/71513
Submitted by: Andre Albsmeier <Andre.Albsmeier@siemens.com>
MFC after: 7 days
-rw-r--r-- | usr.bin/find/function.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index f1c473e..152512d 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -952,7 +952,7 @@ c_fstype(OPTION *option, char ***argvp) int f_group(PLAN *plan, FTSENT *entry) { - return entry->fts_statp->st_gid == plan->g_data; + COMPARE(entry->fts_statp->st_gid, plan->g_data); } PLAN * @@ -966,15 +966,19 @@ c_group(OPTION *option, char ***argvp) 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; } @@ -1465,7 +1469,7 @@ c_type(OPTION *option, char ***argvp) int f_user(PLAN *plan, FTSENT *entry) { - return entry->fts_statp->st_uid == plan->u_data; + COMPARE(entry->fts_statp->st_uid, plan->u_data); } PLAN * @@ -1479,15 +1483,19 @@ c_user(OPTION *option, char ***argvp) 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; } |