summaryrefslogtreecommitdiff
path: root/usr.bin/top
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2018-09-16 02:44:08 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2018-09-16 02:44:08 +0000
commitb5def64de55a2a39374221bb2c618e52880a6339 (patch)
tree682253c002d50f19b6913e6b7944f4c3a5b78206 /usr.bin/top
parent9c8f73324a0075fd194fa0cdfe30ea838752d595 (diff)
Use uid_from_user(3) and gid_from_group(3) in utilities that
do repeated lookups. OK tb@
Diffstat (limited to 'usr.bin/top')
-rw-r--r--usr.bin/top/username.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/usr.bin/top/username.c b/usr.bin/top/username.c
index 21d8d396efa..c5c402c16f5 100644
--- a/usr.bin/top/username.c
+++ b/usr.bin/top/username.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: username.c,v 1.18 2018/09/13 15:23:32 millert Exp $ */
+/* $OpenBSD: username.c,v 1.19 2018/09/16 02:44:06 millert Exp $ */
/*
* Top users/processes display for Unix
@@ -48,12 +48,9 @@ username(uid_t uid)
}
uid_t
-userid(char *username)
+userid(const char *username)
{
- struct passwd *pwd;
+ uid_t uid;
- if ((pwd = getpwnam(username)) == NULL)
- return ((uid_t)-1);
-
- return (pwd->pw_uid);
+ return uid_from_user(username, &uid);
}