From 5e29ecdb70c46bec46b2c3a5375487508261772e Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 12 Jul 2009 21:33:31 +0000 Subject: Accept numeric UIDs as well as usernames like pgrep etc. ok millert --- usr.bin/fstat/fstat.c | 16 +++++++++++----- 1 file 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 @@ -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 @@ -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': -- cgit v1.2.3