diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-12 21:33:31 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-07-12 21:33:31 +0000 |
commit | 5e29ecdb70c46bec46b2c3a5375487508261772e (patch) | |
tree | 01a23167fac4bc056a0b8d0caa5bbe8db0d10b42 /usr.bin/fstat/fstat.c | |
parent | 5a3e7a6a35587f07eeead2f43a4e0ba30574e7ad (diff) |
Accept numeric UIDs as well as usernames like pgrep etc.
ok millert
Diffstat (limited to 'usr.bin/fstat/fstat.c')
-rw-r--r-- | usr.bin/fstat/fstat.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c index 491ba0d8738..9a41950ea9e 100644 --- a/usr.bin/fstat/fstat.c +++ b/usr.bin/fstat/fstat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fstat.c,v 1.68 2009/07/08 16:04:00 millert Exp $ */ +/* $OpenBSD: fstat.c,v 1.69 2009/07/12 21:33:30 nicm Exp $ */ /* * Copyright (c) 2009 Todd C. Miller <Todd.Miller@courtesan.com> @@ -53,7 +53,7 @@ static const char copyright[] = #ifndef lint /*static const char sccsid[] = "from: @(#)fstat.c 8.1 (Berkeley) 6/6/93";*/ -static const char rcsid[] = "$OpenBSD: fstat.c,v 1.68 2009/07/08 16:04:00 millert Exp $"; +static const char rcsid[] = "$OpenBSD: fstat.c,v 1.69 2009/07/12 21:33:30 nicm Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -210,10 +210,16 @@ main(int argc, char *argv[]) if (uflg++) usage(); if (!fuser) { - if (!(passwd = getpwnam(optarg))) - errx(1, "%s: unknown uid", optarg); + if (!(passwd = getpwnam(optarg))) { + arg = strtonum(optarg, 0, UID_MAX, + &errstr); + if (errstr != NULL) { + errx(1, "%s: unknown uid", + optarg); + } + } else + arg = passwd->pw_uid; what = KERN_FILE_BYUID; - arg = passwd->pw_uid; } break; case 'v': |