summaryrefslogtreecommitdiff
path: root/usr.bin/finger/finger.c
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-26 16:57:14 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2015-10-26 16:57:14 +0000
commite3546a01a9c4cd1bc24535ee37e9b22590650557 (patch)
tree0692adcb83e65bb55f3e4f736a926a7124cefafd /usr.bin/finger/finger.c
parent8221e233064027330df923653dc6aa2a19782713 (diff)
Rather than setpassent(1) for the lifetime of the program, use two smaller
windows of setpassent(1) + entpwent() ok tedu millert
Diffstat (limited to 'usr.bin/finger/finger.c')
-rw-r--r--usr.bin/finger/finger.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c
index 5d18467d600..7d64dd080d3 100644
--- a/usr.bin/finger/finger.c
+++ b/usr.bin/finger/finger.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: finger.c,v 1.24 2015/10/18 03:54:22 deraadt Exp $ */
+/* $OpenBSD: finger.c,v 1.25 2015/10/26 16:57:13 deraadt Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
@@ -130,7 +130,6 @@ main(int argc, char *argv[])
err(1, "pledge");
(void)time(&now);
- setpassent(1);
if (!*argv) {
/*
* Assign explicit "small" format if no names given and -l
@@ -174,6 +173,7 @@ loginlist(void)
if (!freopen(_PATH_UTMP, "r", stdin))
err(2, _PATH_UTMP);
name[UT_NAMESIZE] = '\0';
+ setpassent(1);
while (fread((char *)&user, sizeof(user), 1, stdin) == 1) {
if (!user.ut_name[0])
continue;
@@ -185,6 +185,7 @@ loginlist(void)
}
enter_where(&user, pn);
}
+ endpwent();
for (pn = phead; lflag && pn != NULL; pn = pn->next)
enter_lastlog(pn);
}
@@ -227,6 +228,7 @@ userlist(int argc, char **argv)
* traverse the list of possible login names and check the login name
* and real name against the name specified by the user.
*/
+ setpassent(1);
if ((mflag - Mflag) > 0) {
for (i = 0; i < argc; i++)
if (used[i] >= 0 && (pw = getpwnam(argv[i]))) {
@@ -241,6 +243,7 @@ userlist(int argc, char **argv)
enter_person(pw);
used[i] = 1;
}
+ endpwent();
/* list errors */
for (i = 0; i < argc; i++)