19b50d902SRodney W. Grimes /* 29b50d902SRodney W. Grimes * Copyright (c) 1989, 1993 39b50d902SRodney W. Grimes * The Regents of the University of California. All rights reserved. 49b50d902SRodney W. Grimes * 59b50d902SRodney W. Grimes * This code is derived from software contributed to Berkeley by 69b50d902SRodney W. Grimes * Tony Nardo of the Johns Hopkins University/Applied Physics Lab. 79b50d902SRodney W. Grimes * 89b50d902SRodney W. Grimes * Redistribution and use in source and binary forms, with or without 99b50d902SRodney W. Grimes * modification, are permitted provided that the following conditions 109b50d902SRodney W. Grimes * are met: 119b50d902SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 129b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer. 139b50d902SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 149b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 159b50d902SRodney W. Grimes * documentation and/or other materials provided with the distribution. 169b50d902SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 179b50d902SRodney W. Grimes * may be used to endorse or promote products derived from this software 189b50d902SRodney W. Grimes * without specific prior written permission. 199b50d902SRodney W. Grimes * 209b50d902SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 219b50d902SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 229b50d902SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 239b50d902SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 249b50d902SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 259b50d902SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 269b50d902SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 279b50d902SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 289b50d902SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 299b50d902SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 309b50d902SRodney W. Grimes * SUCH DAMAGE. 319b50d902SRodney W. Grimes */ 329b50d902SRodney W. Grimes 3386641d8fSPaul Traina /* 3486641d8fSPaul Traina * Luke Mewburn <lm@rmit.edu.au> added the following on 940622: 3586641d8fSPaul Traina * - mail status ("No Mail", "Mail read:...", or "New Mail ..., 3686641d8fSPaul Traina * Unread since ...".) 3786641d8fSPaul Traina * - 4 digit phone extensions (3210 is printed as x3210.) 3886641d8fSPaul Traina * - host/office toggling in short format with -h & -o. 3986641d8fSPaul Traina * - short day names (`Tue' printed instead of `Jun 21' if the 4086641d8fSPaul Traina * login time is < 6 days. 4186641d8fSPaul Traina */ 4286641d8fSPaul Traina 439b50d902SRodney W. Grimes #ifndef lint 441e832bf8SRuslan Ermilov static const char copyright[] = 459b50d902SRodney W. Grimes "@(#) Copyright (c) 1989, 1993\n\ 469b50d902SRodney W. Grimes The Regents of the University of California. All rights reserved.\n"; 479b50d902SRodney W. Grimes #endif /* not lint */ 489b50d902SRodney W. Grimes 499f5b04e9SDavid Malone #if 0 509b50d902SRodney W. Grimes #ifndef lint 519f5b04e9SDavid Malone static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; 524c86f3adSPhilippe Charnier #endif 539f5b04e9SDavid Malone #endif 549f5b04e9SDavid Malone 559f5b04e9SDavid Malone #include <sys/cdefs.h> 569f5b04e9SDavid Malone __FBSDID("$FreeBSD$"); 579b50d902SRodney W. Grimes 589b50d902SRodney W. Grimes /* 599b50d902SRodney W. Grimes * Finger prints out information about users. It is not portable since 609b50d902SRodney W. Grimes * certain fields (e.g. the full user name, office, and phone numbers) are 619b50d902SRodney W. Grimes * extracted from the gecos field of the passwd file which other UNIXes 629b50d902SRodney W. Grimes * may not have or may use for other things. 639b50d902SRodney W. Grimes * 649b50d902SRodney W. Grimes * There are currently two output formats; the short format is one line 659b50d902SRodney W. Grimes * per user and displays login name, tty, login time, real name, idle time, 6686641d8fSPaul Traina * and either remote host information (default) or office location/phone 6786641d8fSPaul Traina * number, depending on if -h or -o is used respectively. 6886641d8fSPaul Traina * The long format gives the same information (in a more legible format) as 6986641d8fSPaul Traina * well as home directory, shell, mail info, and .plan/.project files. 709b50d902SRodney W. Grimes */ 719b50d902SRodney W. Grimes 723daa8471SHajimu UMEMOTO #include <sys/types.h> 733daa8471SHajimu UMEMOTO #include <sys/socket.h> 74df3f5d9dSPeter Wemm #include <db.h> 75df3f5d9dSPeter Wemm #include <err.h> 76df3f5d9dSPeter Wemm #include <pwd.h> 779b50d902SRodney W. Grimes #include <stdio.h> 789b50d902SRodney W. Grimes #include <stdlib.h> 799b50d902SRodney W. Grimes #include <string.h> 80df3f5d9dSPeter Wemm #include <time.h> 81df3f5d9dSPeter Wemm #include <unistd.h> 82550dcc59SEd Schouten #include <utmpx.h> 83dc675fc2SAndrey A. Chernov #include <locale.h> 84df3f5d9dSPeter Wemm 859b50d902SRodney W. Grimes #include "finger.h" 86098c6e87SBrian Somers #include "pathnames.h" 879b50d902SRodney W. Grimes 889b50d902SRodney W. Grimes DB *db; 899b50d902SRodney W. Grimes time_t now; 90f8871cc8SDag-Erling Smørgrav int entries, gflag, kflag, lflag, mflag, pplan, sflag, oflag; 911acb5329SMaxim Sobolev sa_family_t family = PF_UNSPEC; 92f4d292b7SAndrey A. Chernov int d_first = -1; 939b50d902SRodney W. Grimes char tbuf[1024]; 94d2e4ea2aSDiomidis Spinellis int invoker_root = 0; 959b50d902SRodney W. Grimes 96f1bb2cd2SWarner Losh static void loginlist(void); 97f1bb2cd2SWarner Losh static int option(int, char **); 98f1bb2cd2SWarner Losh static void usage(void); 99f1bb2cd2SWarner Losh static void userlist(int, char **); 1009b50d902SRodney W. Grimes 1014e030ba6SMark Murray static int 102f4ac32deSDavid Malone option(int argc, char **argv) 1039b50d902SRodney W. Grimes { 1049b50d902SRodney W. Grimes int ch; 1059b50d902SRodney W. Grimes 10659be6088SPaul Traina optind = 1; /* reset getopt */ 10786641d8fSPaul Traina 108b49339d7SDag-Erling Smørgrav while ((ch = getopt(argc, argv, "46gklmpsho")) != -1) 1099b50d902SRodney W. Grimes switch(ch) { 1103daa8471SHajimu UMEMOTO case '4': 1113daa8471SHajimu UMEMOTO family = AF_INET; 1123daa8471SHajimu UMEMOTO break; 1133daa8471SHajimu UMEMOTO case '6': 1143daa8471SHajimu UMEMOTO family = AF_INET6; 1153daa8471SHajimu UMEMOTO break; 1160830bd13SJonathan Mini case 'g': 1170830bd13SJonathan Mini gflag = 1; 1180830bd13SJonathan Mini break; 119ad468669SJuli Mallett case 'k': 120ad468669SJuli Mallett kflag = 1; /* keep going without utmp */ 121ad468669SJuli Mallett break; 1229b50d902SRodney W. Grimes case 'l': 1239b50d902SRodney W. Grimes lflag = 1; /* long format */ 1249b50d902SRodney W. Grimes break; 1259b50d902SRodney W. Grimes case 'm': 1269b50d902SRodney W. Grimes mflag = 1; /* force exact match of names */ 1279b50d902SRodney W. Grimes break; 1289b50d902SRodney W. Grimes case 'p': 1299b50d902SRodney W. Grimes pplan = 1; /* don't show .plan/.project */ 1309b50d902SRodney W. Grimes break; 1319b50d902SRodney W. Grimes case 's': 1329b50d902SRodney W. Grimes sflag = 1; /* short format */ 1339b50d902SRodney W. Grimes break; 13486641d8fSPaul Traina case 'h': 13586641d8fSPaul Traina oflag = 0; /* remote host info */ 13686641d8fSPaul Traina break; 13786641d8fSPaul Traina case 'o': 13886641d8fSPaul Traina oflag = 1; /* office info */ 13986641d8fSPaul Traina break; 1409b50d902SRodney W. Grimes case '?': 1419b50d902SRodney W. Grimes default: 142b14d8277SPhilippe Charnier usage(); 1439b50d902SRodney W. Grimes } 14459be6088SPaul Traina 14559be6088SPaul Traina return optind; 14659be6088SPaul Traina } 14759be6088SPaul Traina 148b14d8277SPhilippe Charnier static void 149f4ac32deSDavid Malone usage(void) 150b14d8277SPhilippe Charnier { 151f682f10cSRuslan Ermilov (void)fprintf(stderr, 152b49339d7SDag-Erling Smørgrav "usage: finger [-46gklmpsho] [user ...] [user@host ...]\n"); 153b14d8277SPhilippe Charnier exit(1); 154b14d8277SPhilippe Charnier } 155b14d8277SPhilippe Charnier 156b14d8277SPhilippe Charnier int 157f4ac32deSDavid Malone main(int argc, char **argv) 15859be6088SPaul Traina { 159b14d8277SPhilippe Charnier int envargc, argcnt; 16059be6088SPaul Traina char *envargv[3]; 161dd5288f3SDavid E. O'Brien struct passwd *pw; 1624e030ba6SMark Murray static char myname[] = "finger"; 163dd5288f3SDavid E. O'Brien 164dd5288f3SDavid E. O'Brien if (getuid() == 0 || geteuid() == 0) { 165d2e4ea2aSDiomidis Spinellis invoker_root = 1; 166dd5288f3SDavid E. O'Brien if ((pw = getpwnam(UNPRIV_NAME)) && pw->pw_uid > 0) { 1676e46c1ccSSimon L. B. Nielsen if (setgid(pw->pw_gid) != 0) 1686e46c1ccSSimon L. B. Nielsen err(1, "setgid()"); 1696e46c1ccSSimon L. B. Nielsen if (setuid(pw->pw_uid) != 0) 1706e46c1ccSSimon L. B. Nielsen err(1, "setuid()"); 171dd5288f3SDavid E. O'Brien } else { 1726e46c1ccSSimon L. B. Nielsen if (setgid(UNPRIV_UGID) != 0) 1736e46c1ccSSimon L. B. Nielsen err(1, "setgid()"); 1746e46c1ccSSimon L. B. Nielsen if (setuid(UNPRIV_UGID) != 0) 1756e46c1ccSSimon L. B. Nielsen err(1, "setuid()"); 176dd5288f3SDavid E. O'Brien } 177dd5288f3SDavid E. O'Brien } 17859be6088SPaul Traina 179d1b2ad1aSAndrey A. Chernov (void) setlocale(LC_ALL, ""); 180dc675fc2SAndrey A. Chernov 18159be6088SPaul Traina /* remove this line to get remote host */ 18259be6088SPaul Traina oflag = 1; /* default to old "office" behavior */ 18359be6088SPaul Traina 18459be6088SPaul Traina /* 18559be6088SPaul Traina * Process environment variables followed by command line arguments. 18659be6088SPaul Traina */ 18759be6088SPaul Traina if ((envargv[1] = getenv("FINGER"))) { 18859be6088SPaul Traina envargc = 2; 1894e030ba6SMark Murray envargv[0] = myname; 19059be6088SPaul Traina envargv[2] = NULL; 19159be6088SPaul Traina (void) option(envargc, envargv); 19259be6088SPaul Traina } 19359be6088SPaul Traina 19459be6088SPaul Traina argcnt = option(argc, argv); 19559be6088SPaul Traina argc -= argcnt; 19659be6088SPaul Traina argv += argcnt; 1979b50d902SRodney W. Grimes 1989b50d902SRodney W. Grimes (void)time(&now); 1999b50d902SRodney W. Grimes setpassent(1); 2009b50d902SRodney W. Grimes if (!*argv) { 2019b50d902SRodney W. Grimes /* 2029b50d902SRodney W. Grimes * Assign explicit "small" format if no names given and -l 2039b50d902SRodney W. Grimes * not selected. Force the -s BEFORE we get names so proper 2049b50d902SRodney W. Grimes * screening will be done. 2059b50d902SRodney W. Grimes */ 2069b50d902SRodney W. Grimes if (!lflag) 2079b50d902SRodney W. Grimes sflag = 1; /* if -l not explicit, force -s */ 2089b50d902SRodney W. Grimes loginlist(); 2099b50d902SRodney W. Grimes if (entries == 0) 2109b50d902SRodney W. Grimes (void)printf("No one logged on.\n"); 2119b50d902SRodney W. Grimes } else { 2129b50d902SRodney W. Grimes userlist(argc, argv); 2139b50d902SRodney W. Grimes /* 2149b50d902SRodney W. Grimes * Assign explicit "large" format if names given and -s not 2159b50d902SRodney W. Grimes * explicitly stated. Force the -l AFTER we get names so any 2169b50d902SRodney W. Grimes * remote finger attempts specified won't be mishandled. 2179b50d902SRodney W. Grimes */ 2189b50d902SRodney W. Grimes if (!sflag) 2199b50d902SRodney W. Grimes lflag = 1; /* if -s not explicit, force -l */ 2209b50d902SRodney W. Grimes } 2219ef5c48bSBill Fumerola if (entries) { 2229b50d902SRodney W. Grimes if (lflag) 2239b50d902SRodney W. Grimes lflag_print(); 2249b50d902SRodney W. Grimes else 2259b50d902SRodney W. Grimes sflag_print(); 2269ef5c48bSBill Fumerola } 227df3f5d9dSPeter Wemm return (0); 2289b50d902SRodney W. Grimes } 2299b50d902SRodney W. Grimes 2309b50d902SRodney W. Grimes static void 231f4ac32deSDavid Malone loginlist(void) 2329b50d902SRodney W. Grimes { 2334e030ba6SMark Murray PERSON *pn; 2349b50d902SRodney W. Grimes DBT data, key; 2359b50d902SRodney W. Grimes struct passwd *pw; 23670ad88f3SEd Schouten struct utmpx *user; 2374e030ba6SMark Murray int r, sflag1; 2389b50d902SRodney W. Grimes 239ad468669SJuli Mallett if (kflag) 240ad468669SJuli Mallett errx(1, "can't list logins without reading utmp"); 241ad468669SJuli Mallett 24270ad88f3SEd Schouten setutxent(); 24370ad88f3SEd Schouten while ((user = getutxent()) != NULL) { 24470ad88f3SEd Schouten if (user->ut_type != USER_PROCESS) 2459b50d902SRodney W. Grimes continue; 24670ad88f3SEd Schouten if ((pn = find_person(user->ut_user)) == NULL) { 24770ad88f3SEd Schouten if ((pw = getpwnam(user->ut_user)) == NULL) 2489b50d902SRodney W. Grimes continue; 2498829c73eSJordan K. Hubbard if (hide(pw)) 2508829c73eSJordan K. Hubbard continue; 2519b50d902SRodney W. Grimes pn = enter_person(pw); 2529b50d902SRodney W. Grimes } 25370ad88f3SEd Schouten enter_where(user, pn); 2549b50d902SRodney W. Grimes } 25570ad88f3SEd Schouten endutxent(); 2569b50d902SRodney W. Grimes if (db && lflag) 2574e030ba6SMark Murray for (sflag1 = R_FIRST;; sflag1 = R_NEXT) { 258df3f5d9dSPeter Wemm PERSON *tmp; 259df3f5d9dSPeter Wemm 2604e030ba6SMark Murray r = (*db->seq)(db, &key, &data, sflag1); 2619b50d902SRodney W. Grimes if (r == -1) 262df3f5d9dSPeter Wemm err(1, "db seq"); 2639b50d902SRodney W. Grimes if (r == 1) 2649b50d902SRodney W. Grimes break; 265df3f5d9dSPeter Wemm memmove(&tmp, data.data, sizeof tmp); 266df3f5d9dSPeter Wemm enter_lastlog(tmp); 2679b50d902SRodney W. Grimes } 2689b50d902SRodney W. Grimes } 2699b50d902SRodney W. Grimes 2709b50d902SRodney W. Grimes static void 271f4ac32deSDavid Malone userlist(int argc, char **argv) 2729b50d902SRodney W. Grimes { 2734e030ba6SMark Murray PERSON *pn; 2749b50d902SRodney W. Grimes DBT data, key; 27570ad88f3SEd Schouten struct utmpx *user; 2769b50d902SRodney W. Grimes struct passwd *pw; 2774e030ba6SMark Murray int r, sflag1, *used, *ip; 2789b50d902SRodney W. Grimes char **ap, **nargv, **np, **p; 279098c6e87SBrian Somers FILE *conf_fp; 280098c6e87SBrian Somers char conf_alias[LINE_MAX]; 281098c6e87SBrian Somers char *conf_realname; 282098c6e87SBrian Somers int conf_length; 2839b50d902SRodney W. Grimes 2849b50d902SRodney W. Grimes if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL || 2859b50d902SRodney W. Grimes (used = calloc(argc, sizeof(int))) == NULL) 286df3f5d9dSPeter Wemm err(1, NULL); 2879b50d902SRodney W. Grimes 2889b50d902SRodney W. Grimes /* Pull out all network requests. */ 2899b50d902SRodney W. Grimes for (ap = p = argv, np = nargv; *p; ++p) 290*b3608ae1SEd Schouten if (strchr(*p, '@')) 2919b50d902SRodney W. Grimes *np++ = *p; 2929b50d902SRodney W. Grimes else 2939b50d902SRodney W. Grimes *ap++ = *p; 2949b50d902SRodney W. Grimes 2959b50d902SRodney W. Grimes *np++ = NULL; 2969b50d902SRodney W. Grimes *ap++ = NULL; 2979b50d902SRodney W. Grimes 2989b50d902SRodney W. Grimes if (!*argv) 2999b50d902SRodney W. Grimes goto net; 3009b50d902SRodney W. Grimes 3019b50d902SRodney W. Grimes /* 3027ce8924aSBrian Somers * Mark any arguments beginning with '/' as invalid so that we 303487ac9acSUlrich Spörlein * don't accidentally confuse them with expansions from finger.conf 3047ce8924aSBrian Somers */ 3057ce8924aSBrian Somers for (p = argv, ip = used; *p; ++p, ++ip) 3067ce8924aSBrian Somers if (**p == '/') { 3077ce8924aSBrian Somers *ip = 1; 3087ce8924aSBrian Somers warnx("%s: no such user", *p); 3097ce8924aSBrian Somers } 3107ce8924aSBrian Somers 3117ce8924aSBrian Somers /* 312098c6e87SBrian Somers * Traverse the finger alias configuration file of the form 313098c6e87SBrian Somers * alias:(user|alias), ignoring comment lines beginning '#'. 314098c6e87SBrian Somers */ 315098c6e87SBrian Somers if ((conf_fp = fopen(_PATH_FINGERCONF, "r")) != NULL) { 316098c6e87SBrian Somers while(fgets(conf_alias, sizeof(conf_alias), conf_fp) != NULL) { 317098c6e87SBrian Somers conf_length = strlen(conf_alias); 318098c6e87SBrian Somers if (*conf_alias == '#' || conf_alias[--conf_length] != '\n') 319098c6e87SBrian Somers continue; 320098c6e87SBrian Somers conf_alias[conf_length] = '\0'; /* Remove trailing LF */ 321098c6e87SBrian Somers if ((conf_realname = strchr(conf_alias, ':')) == NULL) 322098c6e87SBrian Somers continue; 323098c6e87SBrian Somers *conf_realname = '\0'; /* Replace : with NUL */ 324098c6e87SBrian Somers for (p = argv; *p; ++p) { 325f342fec6SBruce Evans if (strcmp(*p, conf_alias) == 0) { 326098c6e87SBrian Somers if ((*p = strdup(conf_realname+1)) == NULL) { 327098c6e87SBrian Somers err(1, NULL); 328098c6e87SBrian Somers } 329098c6e87SBrian Somers } 330098c6e87SBrian Somers } 331098c6e87SBrian Somers } 332098c6e87SBrian Somers (void)fclose(conf_fp); 333098c6e87SBrian Somers } 334098c6e87SBrian Somers 335098c6e87SBrian Somers /* 3369b50d902SRodney W. Grimes * Traverse the list of possible login names and check the login name 337040864acSBrian Somers * and real name against the name specified by the user. If the name 338040864acSBrian Somers * begins with a '/', try to read the file of that name instead of 339040864acSBrian Somers * gathering the traditional finger information. 3409b50d902SRodney W. Grimes */ 3419b50d902SRodney W. Grimes if (mflag) 3420272ef9bSRuslan Ermilov for (p = argv, ip = used; *p; ++p, ++ip) { 3430272ef9bSRuslan Ermilov if (**p != '/' || *ip == 1 || !show_text("", *p, "")) { 344df3f5d9dSPeter Wemm if (((pw = getpwnam(*p)) != NULL) && !hide(pw)) 3459b50d902SRodney W. Grimes enter_person(pw); 3460272ef9bSRuslan Ermilov else if (!*ip) 347b14d8277SPhilippe Charnier warnx("%s: no such user", *p); 348040864acSBrian Somers } 349040864acSBrian Somers } 3509b50d902SRodney W. Grimes else { 3511b57e365SBrian Somers while ((pw = getpwent()) != NULL) { 3529b50d902SRodney W. Grimes for (p = argv, ip = used; *p; ++p, ++ip) 353040864acSBrian Somers if (**p == '/' && *ip != 1 3541b57e365SBrian Somers && show_text("", *p, "")) 355040864acSBrian Somers *ip = 1; 3561b57e365SBrian Somers else if (match(pw, *p) && !hide(pw)) { 3579b50d902SRodney W. Grimes enter_person(pw); 3589b50d902SRodney W. Grimes *ip = 1; 3599b50d902SRodney W. Grimes } 3608829c73eSJordan K. Hubbard } 3619b50d902SRodney W. Grimes for (p = argv, ip = used; *p; ++p, ++ip) 3629b50d902SRodney W. Grimes if (!*ip) 363b14d8277SPhilippe Charnier warnx("%s: no such user", *p); 3649b50d902SRodney W. Grimes } 3659b50d902SRodney W. Grimes 3669b50d902SRodney W. Grimes /* Handle network requests. */ 367a5af661eSPaul Traina net: for (p = nargv; *p;) { 3689b50d902SRodney W. Grimes netfinger(*p++); 369a5af661eSPaul Traina if (*p || entries) 370a5af661eSPaul Traina printf("\n"); 371a5af661eSPaul Traina } 3729b50d902SRodney W. Grimes 37313cf266eSXin LI free(used); 3749b50d902SRodney W. Grimes if (entries == 0) 3759b50d902SRodney W. Grimes return; 3769b50d902SRodney W. Grimes 377ad468669SJuli Mallett if (kflag) 378ad468669SJuli Mallett return; 379ad468669SJuli Mallett 3809b50d902SRodney W. Grimes /* 3819b50d902SRodney W. Grimes * Scan thru the list of users currently logged in, saving 3829b50d902SRodney W. Grimes * appropriate data whenever a match occurs. 3839b50d902SRodney W. Grimes */ 38470ad88f3SEd Schouten setutxent(); 38570ad88f3SEd Schouten while ((user = getutxent()) != NULL) { 38670ad88f3SEd Schouten if (user->ut_type != USER_PROCESS) 3879b50d902SRodney W. Grimes continue; 38870ad88f3SEd Schouten if ((pn = find_person(user->ut_user)) == NULL) 3899b50d902SRodney W. Grimes continue; 39070ad88f3SEd Schouten enter_where(user, pn); 3919b50d902SRodney W. Grimes } 39270ad88f3SEd Schouten endutxent(); 3939b50d902SRodney W. Grimes if (db) 3944e030ba6SMark Murray for (sflag1 = R_FIRST;; sflag1 = R_NEXT) { 395df3f5d9dSPeter Wemm PERSON *tmp; 396df3f5d9dSPeter Wemm 3974e030ba6SMark Murray r = (*db->seq)(db, &key, &data, sflag1); 3989b50d902SRodney W. Grimes if (r == -1) 399df3f5d9dSPeter Wemm err(1, "db seq"); 4009b50d902SRodney W. Grimes if (r == 1) 4019b50d902SRodney W. Grimes break; 402df3f5d9dSPeter Wemm memmove(&tmp, data.data, sizeof tmp); 403df3f5d9dSPeter Wemm enter_lastlog(tmp); 4049b50d902SRodney W. Grimes } 4059b50d902SRodney W. Grimes } 406