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 * 3. All advertising materials mentioning features or use of this software 179b50d902SRodney W. Grimes * must display the following acknowledgement: 189b50d902SRodney W. Grimes * This product includes software developed by the University of 199b50d902SRodney W. Grimes * California, Berkeley and its contributors. 209b50d902SRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 219b50d902SRodney W. Grimes * may be used to endorse or promote products derived from this software 229b50d902SRodney W. Grimes * without specific prior written permission. 239b50d902SRodney W. Grimes * 249b50d902SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 259b50d902SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 269b50d902SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 279b50d902SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 289b50d902SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 299b50d902SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 309b50d902SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 319b50d902SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 329b50d902SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 339b50d902SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 349b50d902SRodney W. Grimes * SUCH DAMAGE. 359b50d902SRodney W. Grimes */ 369b50d902SRodney W. Grimes 3786641d8fSPaul Traina /* 3886641d8fSPaul Traina * Luke Mewburn <lm@rmit.edu.au> added the following on 940622: 3986641d8fSPaul Traina * - mail status ("No Mail", "Mail read:...", or "New Mail ..., 4086641d8fSPaul Traina * Unread since ...".) 4186641d8fSPaul Traina * - 4 digit phone extensions (3210 is printed as x3210.) 4286641d8fSPaul Traina * - host/office toggling in short format with -h & -o. 4386641d8fSPaul Traina * - short day names (`Tue' printed instead of `Jun 21' if the 4486641d8fSPaul Traina * login time is < 6 days. 4586641d8fSPaul Traina */ 4686641d8fSPaul Traina 479b50d902SRodney W. Grimes #ifndef lint 481e832bf8SRuslan Ermilov static const char copyright[] = 499b50d902SRodney W. Grimes "@(#) Copyright (c) 1989, 1993\n\ 509b50d902SRodney W. Grimes The Regents of the University of California. All rights reserved.\n"; 519b50d902SRodney W. Grimes #endif /* not lint */ 529b50d902SRodney W. Grimes 539f5b04e9SDavid Malone #if 0 549b50d902SRodney W. Grimes #ifndef lint 559f5b04e9SDavid Malone static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95"; 564c86f3adSPhilippe Charnier #endif 579f5b04e9SDavid Malone #endif 589f5b04e9SDavid Malone 599f5b04e9SDavid Malone #include <sys/cdefs.h> 609f5b04e9SDavid Malone __FBSDID("$FreeBSD$"); 619b50d902SRodney W. Grimes 629b50d902SRodney W. Grimes /* 639b50d902SRodney W. Grimes * Finger prints out information about users. It is not portable since 649b50d902SRodney W. Grimes * certain fields (e.g. the full user name, office, and phone numbers) are 659b50d902SRodney W. Grimes * extracted from the gecos field of the passwd file which other UNIXes 669b50d902SRodney W. Grimes * may not have or may use for other things. 679b50d902SRodney W. Grimes * 689b50d902SRodney W. Grimes * There are currently two output formats; the short format is one line 699b50d902SRodney W. Grimes * per user and displays login name, tty, login time, real name, idle time, 7086641d8fSPaul Traina * and either remote host information (default) or office location/phone 7186641d8fSPaul Traina * number, depending on if -h or -o is used respectively. 7286641d8fSPaul Traina * The long format gives the same information (in a more legible format) as 7386641d8fSPaul Traina * well as home directory, shell, mail info, and .plan/.project files. 749b50d902SRodney W. Grimes */ 759b50d902SRodney W. Grimes 763daa8471SHajimu UMEMOTO #include <sys/types.h> 773daa8471SHajimu UMEMOTO #include <sys/socket.h> 78df3f5d9dSPeter Wemm #include <db.h> 79df3f5d9dSPeter Wemm #include <err.h> 80df3f5d9dSPeter Wemm #include <pwd.h> 819b50d902SRodney W. Grimes #include <stdio.h> 829b50d902SRodney W. Grimes #include <stdlib.h> 839b50d902SRodney W. Grimes #include <string.h> 84df3f5d9dSPeter Wemm #include <time.h> 85df3f5d9dSPeter Wemm #include <unistd.h> 86df3f5d9dSPeter Wemm #include <utmp.h> 87dc675fc2SAndrey A. Chernov #include <locale.h> 88df3f5d9dSPeter Wemm 899b50d902SRodney W. Grimes #include "finger.h" 90098c6e87SBrian Somers #include "pathnames.h" 919b50d902SRodney W. Grimes 929b50d902SRodney W. Grimes DB *db; 939b50d902SRodney W. Grimes time_t now; 940830bd13SJonathan Mini int entries, gflag, lflag, mflag, pplan, sflag, oflag, Tflag; 953daa8471SHajimu UMEMOTO sa_family_t family = PF_UNSPEC; 96f4d292b7SAndrey A. Chernov int d_first = -1; 979b50d902SRodney W. Grimes char tbuf[1024]; 989b50d902SRodney W. Grimes 99f1bb2cd2SWarner Losh static void loginlist(void); 100f1bb2cd2SWarner Losh static int option(int, char **); 101f1bb2cd2SWarner Losh static void usage(void); 102f1bb2cd2SWarner Losh static void userlist(int, char **); 1039b50d902SRodney W. Grimes 1044e030ba6SMark Murray static int 10559be6088SPaul Traina option(argc, argv) 1069b50d902SRodney W. Grimes int argc; 1079b50d902SRodney W. Grimes char **argv; 1089b50d902SRodney W. Grimes { 1099b50d902SRodney W. Grimes int ch; 1109b50d902SRodney W. Grimes 11159be6088SPaul Traina optind = 1; /* reset getopt */ 11286641d8fSPaul Traina 1133daa8471SHajimu UMEMOTO while ((ch = getopt(argc, argv, "46glmpshoT")) != -1) 1149b50d902SRodney W. Grimes switch(ch) { 1153daa8471SHajimu UMEMOTO case '4': 1163daa8471SHajimu UMEMOTO family = AF_INET; 1173daa8471SHajimu UMEMOTO break; 1183daa8471SHajimu UMEMOTO case '6': 1193daa8471SHajimu UMEMOTO family = AF_INET6; 1203daa8471SHajimu UMEMOTO break; 1210830bd13SJonathan Mini case 'g': 1220830bd13SJonathan Mini gflag = 1; 1230830bd13SJonathan Mini break; 1249b50d902SRodney W. Grimes case 'l': 1259b50d902SRodney W. Grimes lflag = 1; /* long format */ 1269b50d902SRodney W. Grimes break; 1279b50d902SRodney W. Grimes case 'm': 1289b50d902SRodney W. Grimes mflag = 1; /* force exact match of names */ 1299b50d902SRodney W. Grimes break; 1309b50d902SRodney W. Grimes case 'p': 1319b50d902SRodney W. Grimes pplan = 1; /* don't show .plan/.project */ 1329b50d902SRodney W. Grimes break; 1339b50d902SRodney W. Grimes case 's': 1349b50d902SRodney W. Grimes sflag = 1; /* short format */ 1359b50d902SRodney W. Grimes break; 13686641d8fSPaul Traina case 'h': 13786641d8fSPaul Traina oflag = 0; /* remote host info */ 13886641d8fSPaul Traina break; 13986641d8fSPaul Traina case 'o': 14086641d8fSPaul Traina oflag = 1; /* office info */ 14186641d8fSPaul Traina break; 14203801815SAndras Olah case 'T': 14303801815SAndras Olah Tflag = 1; /* disable T/TCP */ 14403801815SAndras Olah break; 1459b50d902SRodney W. Grimes case '?': 1469b50d902SRodney W. Grimes default: 147b14d8277SPhilippe Charnier usage(); 1489b50d902SRodney W. Grimes } 14959be6088SPaul Traina 15059be6088SPaul Traina return optind; 15159be6088SPaul Traina } 15259be6088SPaul Traina 153b14d8277SPhilippe Charnier static void 154b14d8277SPhilippe Charnier usage() 155b14d8277SPhilippe Charnier { 1563daa8471SHajimu UMEMOTO (void)fprintf(stderr, "usage: finger [-46lmpshoT] [login ...]\n"); 157b14d8277SPhilippe Charnier exit(1); 158b14d8277SPhilippe Charnier } 159b14d8277SPhilippe Charnier 160b14d8277SPhilippe Charnier int 16159be6088SPaul Traina main(argc, argv) 16259be6088SPaul Traina int argc; 16359be6088SPaul Traina char **argv; 16459be6088SPaul Traina { 165b14d8277SPhilippe Charnier int envargc, argcnt; 16659be6088SPaul Traina char *envargv[3]; 167dd5288f3SDavid E. O'Brien struct passwd *pw; 1684e030ba6SMark Murray static char myname[] = "finger"; 169dd5288f3SDavid E. O'Brien 170dd5288f3SDavid E. O'Brien if (getuid() == 0 || geteuid() == 0) { 171dd5288f3SDavid E. O'Brien if ((pw = getpwnam(UNPRIV_NAME)) && pw->pw_uid > 0) { 172dd5288f3SDavid E. O'Brien setgid(pw->pw_gid); 173dd5288f3SDavid E. O'Brien setuid(pw->pw_uid); 174dd5288f3SDavid E. O'Brien } else { 175dd5288f3SDavid E. O'Brien setgid(UNPRIV_UGID); 176dd5288f3SDavid E. O'Brien setuid(UNPRIV_UGID); 177dd5288f3SDavid E. O'Brien } 178dd5288f3SDavid E. O'Brien } 17959be6088SPaul Traina 180d1b2ad1aSAndrey A. Chernov (void) setlocale(LC_ALL, ""); 181dc675fc2SAndrey A. Chernov 18259be6088SPaul Traina /* remove this line to get remote host */ 18359be6088SPaul Traina oflag = 1; /* default to old "office" behavior */ 18459be6088SPaul Traina 18559be6088SPaul Traina /* 18659be6088SPaul Traina * Process environment variables followed by command line arguments. 18759be6088SPaul Traina */ 18859be6088SPaul Traina if ((envargv[1] = getenv("FINGER"))) { 18959be6088SPaul Traina envargc = 2; 1904e030ba6SMark Murray envargv[0] = myname; 19159be6088SPaul Traina envargv[2] = NULL; 19259be6088SPaul Traina (void) option(envargc, envargv); 19359be6088SPaul Traina } 19459be6088SPaul Traina 19559be6088SPaul Traina argcnt = option(argc, argv); 19659be6088SPaul Traina argc -= argcnt; 19759be6088SPaul Traina argv += argcnt; 1989b50d902SRodney W. Grimes 1999b50d902SRodney W. Grimes (void)time(&now); 2009b50d902SRodney W. Grimes setpassent(1); 2019b50d902SRodney W. Grimes if (!*argv) { 2029b50d902SRodney W. Grimes /* 2039b50d902SRodney W. Grimes * Assign explicit "small" format if no names given and -l 2049b50d902SRodney W. Grimes * not selected. Force the -s BEFORE we get names so proper 2059b50d902SRodney W. Grimes * screening will be done. 2069b50d902SRodney W. Grimes */ 2079b50d902SRodney W. Grimes if (!lflag) 2089b50d902SRodney W. Grimes sflag = 1; /* if -l not explicit, force -s */ 2099b50d902SRodney W. Grimes loginlist(); 2109b50d902SRodney W. Grimes if (entries == 0) 2119b50d902SRodney W. Grimes (void)printf("No one logged on.\n"); 2129b50d902SRodney W. Grimes } else { 2139b50d902SRodney W. Grimes userlist(argc, argv); 2149b50d902SRodney W. Grimes /* 2159b50d902SRodney W. Grimes * Assign explicit "large" format if names given and -s not 2169b50d902SRodney W. Grimes * explicitly stated. Force the -l AFTER we get names so any 2179b50d902SRodney W. Grimes * remote finger attempts specified won't be mishandled. 2189b50d902SRodney W. Grimes */ 2199b50d902SRodney W. Grimes if (!sflag) 2209b50d902SRodney W. Grimes lflag = 1; /* if -s not explicit, force -l */ 2219b50d902SRodney W. Grimes } 2229ef5c48bSBill Fumerola if (entries) { 2239b50d902SRodney W. Grimes if (lflag) 2249b50d902SRodney W. Grimes lflag_print(); 2259b50d902SRodney W. Grimes else 2269b50d902SRodney W. Grimes sflag_print(); 2279ef5c48bSBill Fumerola } 228df3f5d9dSPeter Wemm return (0); 2299b50d902SRodney W. Grimes } 2309b50d902SRodney W. Grimes 2319b50d902SRodney W. Grimes static void 2329b50d902SRodney W. Grimes loginlist() 2339b50d902SRodney W. Grimes { 2344e030ba6SMark Murray PERSON *pn; 2359b50d902SRodney W. Grimes DBT data, key; 2369b50d902SRodney W. Grimes struct passwd *pw; 2379b50d902SRodney W. Grimes struct utmp user; 2384e030ba6SMark Murray int r, sflag1; 2399b50d902SRodney W. Grimes char name[UT_NAMESIZE + 1]; 2409b50d902SRodney W. Grimes 2419b50d902SRodney W. Grimes if (!freopen(_PATH_UTMP, "r", stdin)) 242df3f5d9dSPeter Wemm err(1, "%s", _PATH_UTMP); 243b14d8277SPhilippe Charnier name[UT_NAMESIZE] = '\0'; 2449b50d902SRodney W. Grimes while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { 2459b50d902SRodney W. Grimes if (!user.ut_name[0]) 2469b50d902SRodney W. Grimes continue; 2479b50d902SRodney W. Grimes if ((pn = find_person(user.ut_name)) == NULL) { 2489b50d902SRodney W. Grimes bcopy(user.ut_name, name, UT_NAMESIZE); 2499b50d902SRodney W. Grimes if ((pw = getpwnam(name)) == NULL) 2509b50d902SRodney W. Grimes continue; 2518829c73eSJordan K. Hubbard if (hide(pw)) 2528829c73eSJordan K. Hubbard continue; 2539b50d902SRodney W. Grimes pn = enter_person(pw); 2549b50d902SRodney W. Grimes } 2559b50d902SRodney W. Grimes enter_where(&user, pn); 2569b50d902SRodney W. Grimes } 2579b50d902SRodney W. Grimes if (db && lflag) 2584e030ba6SMark Murray for (sflag1 = R_FIRST;; sflag1 = R_NEXT) { 259df3f5d9dSPeter Wemm PERSON *tmp; 260df3f5d9dSPeter Wemm 2614e030ba6SMark Murray r = (*db->seq)(db, &key, &data, sflag1); 2629b50d902SRodney W. Grimes if (r == -1) 263df3f5d9dSPeter Wemm err(1, "db seq"); 2649b50d902SRodney W. Grimes if (r == 1) 2659b50d902SRodney W. Grimes break; 266df3f5d9dSPeter Wemm memmove(&tmp, data.data, sizeof tmp); 267df3f5d9dSPeter Wemm enter_lastlog(tmp); 2689b50d902SRodney W. Grimes } 2699b50d902SRodney W. Grimes } 2709b50d902SRodney W. Grimes 2719b50d902SRodney W. Grimes static void 2729b50d902SRodney W. Grimes userlist(argc, argv) 2734e030ba6SMark Murray int argc; 2744e030ba6SMark Murray char **argv; 2759b50d902SRodney W. Grimes { 2764e030ba6SMark Murray PERSON *pn; 2779b50d902SRodney W. Grimes DBT data, key; 2789b50d902SRodney W. Grimes struct utmp user; 2799b50d902SRodney W. Grimes struct passwd *pw; 2804e030ba6SMark Murray int r, sflag1, *used, *ip; 2819b50d902SRodney W. Grimes char **ap, **nargv, **np, **p; 282098c6e87SBrian Somers FILE *conf_fp; 283098c6e87SBrian Somers char conf_alias[LINE_MAX]; 284098c6e87SBrian Somers char *conf_realname; 285098c6e87SBrian Somers int conf_length; 2869b50d902SRodney W. Grimes 2879b50d902SRodney W. Grimes if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL || 2889b50d902SRodney W. Grimes (used = calloc(argc, sizeof(int))) == NULL) 289df3f5d9dSPeter Wemm err(1, NULL); 2909b50d902SRodney W. Grimes 2919b50d902SRodney W. Grimes /* Pull out all network requests. */ 2929b50d902SRodney W. Grimes for (ap = p = argv, np = nargv; *p; ++p) 2939b50d902SRodney W. Grimes if (index(*p, '@')) 2949b50d902SRodney W. Grimes *np++ = *p; 2959b50d902SRodney W. Grimes else 2969b50d902SRodney W. Grimes *ap++ = *p; 2979b50d902SRodney W. Grimes 2989b50d902SRodney W. Grimes *np++ = NULL; 2999b50d902SRodney W. Grimes *ap++ = NULL; 3009b50d902SRodney W. Grimes 3019b50d902SRodney W. Grimes if (!*argv) 3029b50d902SRodney W. Grimes goto net; 3039b50d902SRodney W. Grimes 3049b50d902SRodney W. Grimes /* 3057ce8924aSBrian Somers * Mark any arguments beginning with '/' as invalid so that we 3067ce8924aSBrian Somers * don't accidently confuse them with expansions from finger.conf 3077ce8924aSBrian Somers */ 3087ce8924aSBrian Somers for (p = argv, ip = used; *p; ++p, ++ip) 3097ce8924aSBrian Somers if (**p == '/') { 3107ce8924aSBrian Somers *ip = 1; 3117ce8924aSBrian Somers warnx("%s: no such user", *p); 3127ce8924aSBrian Somers } 3137ce8924aSBrian Somers 3147ce8924aSBrian Somers /* 315098c6e87SBrian Somers * Traverse the finger alias configuration file of the form 316098c6e87SBrian Somers * alias:(user|alias), ignoring comment lines beginning '#'. 317098c6e87SBrian Somers */ 318098c6e87SBrian Somers if ((conf_fp = fopen(_PATH_FINGERCONF, "r")) != NULL) { 319098c6e87SBrian Somers while(fgets(conf_alias, sizeof(conf_alias), conf_fp) != NULL) { 320098c6e87SBrian Somers conf_length = strlen(conf_alias); 321098c6e87SBrian Somers if (*conf_alias == '#' || conf_alias[--conf_length] != '\n') 322098c6e87SBrian Somers continue; 323098c6e87SBrian Somers conf_alias[conf_length] = '\0'; /* Remove trailing LF */ 324098c6e87SBrian Somers if ((conf_realname = strchr(conf_alias, ':')) == NULL) 325098c6e87SBrian Somers continue; 326098c6e87SBrian Somers *conf_realname = '\0'; /* Replace : with NUL */ 327098c6e87SBrian Somers for (p = argv; *p; ++p) { 328098c6e87SBrian Somers if (strcmp(*p, conf_alias) == NULL) { 329098c6e87SBrian Somers if ((*p = strdup(conf_realname+1)) == NULL) { 330098c6e87SBrian Somers err(1, NULL); 331098c6e87SBrian Somers } 332098c6e87SBrian Somers } 333098c6e87SBrian Somers } 334098c6e87SBrian Somers } 335098c6e87SBrian Somers (void)fclose(conf_fp); 336098c6e87SBrian Somers } 337098c6e87SBrian Somers 338098c6e87SBrian Somers /* 3399b50d902SRodney W. Grimes * Traverse the list of possible login names and check the login name 340040864acSBrian Somers * and real name against the name specified by the user. If the name 341040864acSBrian Somers * begins with a '/', try to read the file of that name instead of 342040864acSBrian Somers * gathering the traditional finger information. 3439b50d902SRodney W. Grimes */ 3449b50d902SRodney W. Grimes if (mflag) 3450272ef9bSRuslan Ermilov for (p = argv, ip = used; *p; ++p, ++ip) { 3460272ef9bSRuslan Ermilov if (**p != '/' || *ip == 1 || !show_text("", *p, "")) { 347df3f5d9dSPeter Wemm if (((pw = getpwnam(*p)) != NULL) && !hide(pw)) 3489b50d902SRodney W. Grimes enter_person(pw); 3490272ef9bSRuslan Ermilov else if (!*ip) 350b14d8277SPhilippe Charnier warnx("%s: no such user", *p); 351040864acSBrian Somers } 352040864acSBrian Somers } 3539b50d902SRodney W. Grimes else { 3541b57e365SBrian Somers while ((pw = getpwent()) != NULL) { 3559b50d902SRodney W. Grimes for (p = argv, ip = used; *p; ++p, ++ip) 356040864acSBrian Somers if (**p == '/' && *ip != 1 3571b57e365SBrian Somers && show_text("", *p, "")) 358040864acSBrian Somers *ip = 1; 3591b57e365SBrian Somers else if (match(pw, *p) && !hide(pw)) { 3609b50d902SRodney W. Grimes enter_person(pw); 3619b50d902SRodney W. Grimes *ip = 1; 3629b50d902SRodney W. Grimes } 3638829c73eSJordan K. Hubbard } 3649b50d902SRodney W. Grimes for (p = argv, ip = used; *p; ++p, ++ip) 3659b50d902SRodney W. Grimes if (!*ip) 366b14d8277SPhilippe Charnier warnx("%s: no such user", *p); 3679b50d902SRodney W. Grimes } 3689b50d902SRodney W. Grimes 3699b50d902SRodney W. Grimes /* Handle network requests. */ 370a5af661eSPaul Traina net: for (p = nargv; *p;) { 3719b50d902SRodney W. Grimes netfinger(*p++); 372a5af661eSPaul Traina if (*p || entries) 373a5af661eSPaul Traina printf("\n"); 374a5af661eSPaul Traina } 3759b50d902SRodney W. Grimes 3769b50d902SRodney W. Grimes if (entries == 0) 3779b50d902SRodney W. Grimes return; 3789b50d902SRodney W. Grimes 3799b50d902SRodney W. Grimes /* 3809b50d902SRodney W. Grimes * Scan thru the list of users currently logged in, saving 3819b50d902SRodney W. Grimes * appropriate data whenever a match occurs. 3829b50d902SRodney W. Grimes */ 3839b50d902SRodney W. Grimes if (!freopen(_PATH_UTMP, "r", stdin)) 384df3f5d9dSPeter Wemm err(1, "%s", _PATH_UTMP); 3859b50d902SRodney W. Grimes while (fread((char *)&user, sizeof(user), 1, stdin) == 1) { 3869b50d902SRodney W. Grimes if (!user.ut_name[0]) 3879b50d902SRodney W. Grimes continue; 3889b50d902SRodney W. Grimes if ((pn = find_person(user.ut_name)) == NULL) 3899b50d902SRodney W. Grimes continue; 3909b50d902SRodney W. Grimes enter_where(&user, pn); 3919b50d902SRodney W. Grimes } 3929b50d902SRodney W. Grimes if (db) 3934e030ba6SMark Murray for (sflag1 = R_FIRST;; sflag1 = R_NEXT) { 394df3f5d9dSPeter Wemm PERSON *tmp; 395df3f5d9dSPeter Wemm 3964e030ba6SMark Murray r = (*db->seq)(db, &key, &data, sflag1); 3979b50d902SRodney W. Grimes if (r == -1) 398df3f5d9dSPeter Wemm err(1, "db seq"); 3999b50d902SRodney W. Grimes if (r == 1) 4009b50d902SRodney W. Grimes break; 401df3f5d9dSPeter Wemm memmove(&tmp, data.data, sizeof tmp); 402df3f5d9dSPeter Wemm enter_lastlog(tmp); 4039b50d902SRodney W. Grimes } 4049b50d902SRodney W. Grimes } 405