summaryrefslogtreecommitdiff
path: root/usr.bin/pkill
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/pkill
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/pkill')
-rw-r--r--usr.bin/pkill/pkill.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/usr.bin/pkill/pkill.c b/usr.bin/pkill/pkill.c
index a318e5968fa..4ceab86db19 100644
--- a/usr.bin/pkill/pkill.c
+++ b/usr.bin/pkill/pkill.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pkill.c,v 1.39 2016/10/10 02:22:59 gsoares Exp $ */
+/* $OpenBSD: pkill.c,v 1.40 2018/09/16 02:44:06 millert Exp $ */
/* $NetBSD: pkill.c,v 1.5 2002/10/27 11:49:34 kleink Exp $ */
/*-
@@ -544,10 +544,10 @@ static void
makelist(struct listhead *head, enum listtype type, char *src)
{
struct list *li;
- struct passwd *pw;
- struct group *gr;
struct stat st;
char *sp, *p, buf[PATH_MAX];
+ uid_t uid;
+ gid_t gid;
int empty;
empty = 1;
@@ -588,14 +588,14 @@ makelist(struct listhead *head, enum listtype type, char *src)
switch (type) {
case LT_USER:
- if ((pw = getpwnam(sp)) == NULL)
+ if (uid_from_user(sp, &uid) == -1)
errx(STATUS_BADUSAGE, "unknown user `%s'", sp);
- li->li_number = pw->pw_uid;
+ li->li_number = uid;
break;
case LT_GROUP:
- if ((gr = getgrnam(sp)) == NULL)
+ if (gid_from_group(sp, &gid) == -1)
errx(STATUS_BADUSAGE, "unknown group `%s'", sp);
- li->li_number = gr->gr_gid;
+ li->li_number = gid;
break;
case LT_TTY:
if (strcmp(sp, "-") == 0) {