18a16b7a1SPedro F. Giffuni /*-
28a16b7a1SPedro F. Giffuni * SPDX-License-Identifier: BSD-3-Clause
38a16b7a1SPedro F. Giffuni *
49b50d902SRodney W. Grimes * Copyright (c) 1989, 1993
59b50d902SRodney W. Grimes * The Regents of the University of California. All rights reserved.
69b50d902SRodney W. Grimes *
79b50d902SRodney W. Grimes * This code is derived from software contributed to Berkeley by
89b50d902SRodney W. Grimes * Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
99b50d902SRodney W. Grimes *
109b50d902SRodney W. Grimes * Redistribution and use in source and binary forms, with or without
119b50d902SRodney W. Grimes * modification, are permitted provided that the following conditions
129b50d902SRodney W. Grimes * are met:
139b50d902SRodney W. Grimes * 1. Redistributions of source code must retain the above copyright
149b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer.
159b50d902SRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright
169b50d902SRodney W. Grimes * notice, this list of conditions and the following disclaimer in the
179b50d902SRodney W. Grimes * documentation and/or other materials provided with the distribution.
18fbbd9655SWarner Losh * 3. Neither the name of the University nor the names of its contributors
199b50d902SRodney W. Grimes * may be used to endorse or promote products derived from this software
209b50d902SRodney W. Grimes * without specific prior written permission.
219b50d902SRodney W. Grimes *
229b50d902SRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
239b50d902SRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
249b50d902SRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
259b50d902SRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
269b50d902SRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
279b50d902SRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
289b50d902SRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
299b50d902SRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
309b50d902SRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
319b50d902SRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
329b50d902SRodney W. Grimes * SUCH DAMAGE.
339b50d902SRodney W. Grimes */
349b50d902SRodney W. Grimes
3586641d8fSPaul Traina /*
3686641d8fSPaul Traina * Luke Mewburn <lm@rmit.edu.au> added the following on 940622:
3786641d8fSPaul Traina * - mail status ("No Mail", "Mail read:...", or "New Mail ...,
3886641d8fSPaul Traina * Unread since ...".)
3986641d8fSPaul Traina * - 4 digit phone extensions (3210 is printed as x3210.)
4086641d8fSPaul Traina * - host/office toggling in short format with -h & -o.
4186641d8fSPaul Traina * - short day names (`Tue' printed instead of `Jun 21' if the
4286641d8fSPaul Traina * login time is < 6 days.
4386641d8fSPaul Traina */
4486641d8fSPaul Traina
459b50d902SRodney W. Grimes /*
469b50d902SRodney W. Grimes * Finger prints out information about users. It is not portable since
479b50d902SRodney W. Grimes * certain fields (e.g. the full user name, office, and phone numbers) are
489b50d902SRodney W. Grimes * extracted from the gecos field of the passwd file which other UNIXes
499b50d902SRodney W. Grimes * may not have or may use for other things.
509b50d902SRodney W. Grimes *
519b50d902SRodney W. Grimes * There are currently two output formats; the short format is one line
529b50d902SRodney W. Grimes * per user and displays login name, tty, login time, real name, idle time,
5386641d8fSPaul Traina * and either remote host information (default) or office location/phone
5486641d8fSPaul Traina * number, depending on if -h or -o is used respectively.
5586641d8fSPaul Traina * The long format gives the same information (in a more legible format) as
5686641d8fSPaul Traina * well as home directory, shell, mail info, and .plan/.project files.
579b50d902SRodney W. Grimes */
589b50d902SRodney W. Grimes
593daa8471SHajimu UMEMOTO #include <sys/types.h>
603daa8471SHajimu UMEMOTO #include <sys/socket.h>
61df3f5d9dSPeter Wemm #include <db.h>
62df3f5d9dSPeter Wemm #include <err.h>
63df3f5d9dSPeter Wemm #include <pwd.h>
649b50d902SRodney W. Grimes #include <stdio.h>
659b50d902SRodney W. Grimes #include <stdlib.h>
669b50d902SRodney W. Grimes #include <string.h>
67df3f5d9dSPeter Wemm #include <time.h>
68df3f5d9dSPeter Wemm #include <unistd.h>
69550dcc59SEd Schouten #include <utmpx.h>
70dc675fc2SAndrey A. Chernov #include <locale.h>
71df3f5d9dSPeter Wemm
729b50d902SRodney W. Grimes #include "finger.h"
73098c6e87SBrian Somers #include "pathnames.h"
749b50d902SRodney W. Grimes
759b50d902SRodney W. Grimes DB *db;
769b50d902SRodney W. Grimes time_t now;
77bf70beceSEd Schouten static int kflag, mflag, sflag;
78bf70beceSEd Schouten int entries, gflag, lflag, pplan, oflag;
791acb5329SMaxim Sobolev sa_family_t family = PF_UNSPEC;
80f4d292b7SAndrey A. Chernov int d_first = -1;
819b50d902SRodney W. Grimes char tbuf[1024];
82d2e4ea2aSDiomidis Spinellis int invoker_root = 0;
839b50d902SRodney W. Grimes
84f1bb2cd2SWarner Losh static void loginlist(void);
85f1bb2cd2SWarner Losh static int option(int, char **);
86*a1b6427aSAlfonso Gregory static void usage(void) __dead2;
87f1bb2cd2SWarner Losh static void userlist(int, char **);
889b50d902SRodney W. Grimes
894e030ba6SMark Murray static int
option(int argc,char ** argv)90f4ac32deSDavid Malone option(int argc, char **argv)
919b50d902SRodney W. Grimes {
929b50d902SRodney W. Grimes int ch;
939b50d902SRodney W. Grimes
9459be6088SPaul Traina optind = 1; /* reset getopt */
9586641d8fSPaul Traina
96b49339d7SDag-Erling Smørgrav while ((ch = getopt(argc, argv, "46gklmpsho")) != -1)
979b50d902SRodney W. Grimes switch(ch) {
983daa8471SHajimu UMEMOTO case '4':
993daa8471SHajimu UMEMOTO family = AF_INET;
1003daa8471SHajimu UMEMOTO break;
1013daa8471SHajimu UMEMOTO case '6':
1023daa8471SHajimu UMEMOTO family = AF_INET6;
1033daa8471SHajimu UMEMOTO break;
1040830bd13SJonathan Mini case 'g':
1050830bd13SJonathan Mini gflag = 1;
1060830bd13SJonathan Mini break;
107ad468669SJuli Mallett case 'k':
108ad468669SJuli Mallett kflag = 1; /* keep going without utmp */
109ad468669SJuli Mallett break;
1109b50d902SRodney W. Grimes case 'l':
1119b50d902SRodney W. Grimes lflag = 1; /* long format */
1129b50d902SRodney W. Grimes break;
1139b50d902SRodney W. Grimes case 'm':
1149b50d902SRodney W. Grimes mflag = 1; /* force exact match of names */
1159b50d902SRodney W. Grimes break;
1169b50d902SRodney W. Grimes case 'p':
1179b50d902SRodney W. Grimes pplan = 1; /* don't show .plan/.project */
1189b50d902SRodney W. Grimes break;
1199b50d902SRodney W. Grimes case 's':
1209b50d902SRodney W. Grimes sflag = 1; /* short format */
1219b50d902SRodney W. Grimes break;
12286641d8fSPaul Traina case 'h':
12386641d8fSPaul Traina oflag = 0; /* remote host info */
12486641d8fSPaul Traina break;
12586641d8fSPaul Traina case 'o':
12686641d8fSPaul Traina oflag = 1; /* office info */
12786641d8fSPaul Traina break;
1289b50d902SRodney W. Grimes case '?':
1299b50d902SRodney W. Grimes default:
130b14d8277SPhilippe Charnier usage();
1319b50d902SRodney W. Grimes }
13259be6088SPaul Traina
13359be6088SPaul Traina return optind;
13459be6088SPaul Traina }
13559be6088SPaul Traina
136b14d8277SPhilippe Charnier static void
usage(void)137f4ac32deSDavid Malone usage(void)
138b14d8277SPhilippe Charnier {
139f682f10cSRuslan Ermilov (void)fprintf(stderr,
140b49339d7SDag-Erling Smørgrav "usage: finger [-46gklmpsho] [user ...] [user@host ...]\n");
141b14d8277SPhilippe Charnier exit(1);
142b14d8277SPhilippe Charnier }
143b14d8277SPhilippe Charnier
144b14d8277SPhilippe Charnier int
main(int argc,char ** argv)145f4ac32deSDavid Malone main(int argc, char **argv)
14659be6088SPaul Traina {
147b14d8277SPhilippe Charnier int envargc, argcnt;
14859be6088SPaul Traina char *envargv[3];
149dd5288f3SDavid E. O'Brien struct passwd *pw;
1504e030ba6SMark Murray static char myname[] = "finger";
151dd5288f3SDavid E. O'Brien
152dd5288f3SDavid E. O'Brien if (getuid() == 0 || geteuid() == 0) {
153d2e4ea2aSDiomidis Spinellis invoker_root = 1;
154dd5288f3SDavid E. O'Brien if ((pw = getpwnam(UNPRIV_NAME)) && pw->pw_uid > 0) {
1556e46c1ccSSimon L. B. Nielsen if (setgid(pw->pw_gid) != 0)
1566e46c1ccSSimon L. B. Nielsen err(1, "setgid()");
1576e46c1ccSSimon L. B. Nielsen if (setuid(pw->pw_uid) != 0)
1586e46c1ccSSimon L. B. Nielsen err(1, "setuid()");
159dd5288f3SDavid E. O'Brien } else {
1606e46c1ccSSimon L. B. Nielsen if (setgid(UNPRIV_UGID) != 0)
1616e46c1ccSSimon L. B. Nielsen err(1, "setgid()");
1626e46c1ccSSimon L. B. Nielsen if (setuid(UNPRIV_UGID) != 0)
1636e46c1ccSSimon L. B. Nielsen err(1, "setuid()");
164dd5288f3SDavid E. O'Brien }
165dd5288f3SDavid E. O'Brien }
16659be6088SPaul Traina
167d1b2ad1aSAndrey A. Chernov (void) setlocale(LC_ALL, "");
168dc675fc2SAndrey A. Chernov
16959be6088SPaul Traina /* remove this line to get remote host */
17059be6088SPaul Traina oflag = 1; /* default to old "office" behavior */
17159be6088SPaul Traina
17259be6088SPaul Traina /*
17359be6088SPaul Traina * Process environment variables followed by command line arguments.
17459be6088SPaul Traina */
17559be6088SPaul Traina if ((envargv[1] = getenv("FINGER"))) {
17659be6088SPaul Traina envargc = 2;
1774e030ba6SMark Murray envargv[0] = myname;
17859be6088SPaul Traina envargv[2] = NULL;
17959be6088SPaul Traina (void) option(envargc, envargv);
18059be6088SPaul Traina }
18159be6088SPaul Traina
18259be6088SPaul Traina argcnt = option(argc, argv);
18359be6088SPaul Traina argc -= argcnt;
18459be6088SPaul Traina argv += argcnt;
1859b50d902SRodney W. Grimes
1869b50d902SRodney W. Grimes (void)time(&now);
1879b50d902SRodney W. Grimes setpassent(1);
1889b50d902SRodney W. Grimes if (!*argv) {
1899b50d902SRodney W. Grimes /*
1909b50d902SRodney W. Grimes * Assign explicit "small" format if no names given and -l
1919b50d902SRodney W. Grimes * not selected. Force the -s BEFORE we get names so proper
1929b50d902SRodney W. Grimes * screening will be done.
1939b50d902SRodney W. Grimes */
1949b50d902SRodney W. Grimes if (!lflag)
1959b50d902SRodney W. Grimes sflag = 1; /* if -l not explicit, force -s */
1969b50d902SRodney W. Grimes loginlist();
1979b50d902SRodney W. Grimes if (entries == 0)
1989b50d902SRodney W. Grimes (void)printf("No one logged on.\n");
1999b50d902SRodney W. Grimes } else {
2009b50d902SRodney W. Grimes userlist(argc, argv);
2019b50d902SRodney W. Grimes /*
2029b50d902SRodney W. Grimes * Assign explicit "large" format if names given and -s not
2039b50d902SRodney W. Grimes * explicitly stated. Force the -l AFTER we get names so any
2049b50d902SRodney W. Grimes * remote finger attempts specified won't be mishandled.
2059b50d902SRodney W. Grimes */
2069b50d902SRodney W. Grimes if (!sflag)
2079b50d902SRodney W. Grimes lflag = 1; /* if -s not explicit, force -l */
2089b50d902SRodney W. Grimes }
2099ef5c48bSBill Fumerola if (entries) {
2109b50d902SRodney W. Grimes if (lflag)
2119b50d902SRodney W. Grimes lflag_print();
2129b50d902SRodney W. Grimes else
2139b50d902SRodney W. Grimes sflag_print();
2149ef5c48bSBill Fumerola }
215df3f5d9dSPeter Wemm return (0);
2169b50d902SRodney W. Grimes }
2179b50d902SRodney W. Grimes
2189b50d902SRodney W. Grimes static void
loginlist(void)219f4ac32deSDavid Malone loginlist(void)
2209b50d902SRodney W. Grimes {
2214e030ba6SMark Murray PERSON *pn;
2229b50d902SRodney W. Grimes DBT data, key;
2239b50d902SRodney W. Grimes struct passwd *pw;
22470ad88f3SEd Schouten struct utmpx *user;
2254e030ba6SMark Murray int r, sflag1;
2269b50d902SRodney W. Grimes
227ad468669SJuli Mallett if (kflag)
228ad468669SJuli Mallett errx(1, "can't list logins without reading utmp");
229ad468669SJuli Mallett
23070ad88f3SEd Schouten setutxent();
23170ad88f3SEd Schouten while ((user = getutxent()) != NULL) {
23270ad88f3SEd Schouten if (user->ut_type != USER_PROCESS)
2339b50d902SRodney W. Grimes continue;
23470ad88f3SEd Schouten if ((pn = find_person(user->ut_user)) == NULL) {
23570ad88f3SEd Schouten if ((pw = getpwnam(user->ut_user)) == NULL)
2369b50d902SRodney W. Grimes continue;
2378829c73eSJordan K. Hubbard if (hide(pw))
2388829c73eSJordan K. Hubbard continue;
2399b50d902SRodney W. Grimes pn = enter_person(pw);
2409b50d902SRodney W. Grimes }
24170ad88f3SEd Schouten enter_where(user, pn);
2429b50d902SRodney W. Grimes }
24370ad88f3SEd Schouten endutxent();
2449b50d902SRodney W. Grimes if (db && lflag)
2454e030ba6SMark Murray for (sflag1 = R_FIRST;; sflag1 = R_NEXT) {
246df3f5d9dSPeter Wemm PERSON *tmp;
247df3f5d9dSPeter Wemm
2484e030ba6SMark Murray r = (*db->seq)(db, &key, &data, sflag1);
2499b50d902SRodney W. Grimes if (r == -1)
250df3f5d9dSPeter Wemm err(1, "db seq");
2519b50d902SRodney W. Grimes if (r == 1)
2529b50d902SRodney W. Grimes break;
253df3f5d9dSPeter Wemm memmove(&tmp, data.data, sizeof tmp);
254df3f5d9dSPeter Wemm enter_lastlog(tmp);
2559b50d902SRodney W. Grimes }
2569b50d902SRodney W. Grimes }
2579b50d902SRodney W. Grimes
2589b50d902SRodney W. Grimes static void
userlist(int argc,char ** argv)259f4ac32deSDavid Malone userlist(int argc, char **argv)
2609b50d902SRodney W. Grimes {
2614e030ba6SMark Murray PERSON *pn;
2629b50d902SRodney W. Grimes DBT data, key;
26370ad88f3SEd Schouten struct utmpx *user;
2649b50d902SRodney W. Grimes struct passwd *pw;
2654e030ba6SMark Murray int r, sflag1, *used, *ip;
2669b50d902SRodney W. Grimes char **ap, **nargv, **np, **p;
267098c6e87SBrian Somers FILE *conf_fp;
268098c6e87SBrian Somers char conf_alias[LINE_MAX];
269098c6e87SBrian Somers char *conf_realname;
270098c6e87SBrian Somers int conf_length;
2719b50d902SRodney W. Grimes
2729b50d902SRodney W. Grimes if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL ||
2739b50d902SRodney W. Grimes (used = calloc(argc, sizeof(int))) == NULL)
274df3f5d9dSPeter Wemm err(1, NULL);
2759b50d902SRodney W. Grimes
2769b50d902SRodney W. Grimes /* Pull out all network requests. */
2779b50d902SRodney W. Grimes for (ap = p = argv, np = nargv; *p; ++p)
278b3608ae1SEd Schouten if (strchr(*p, '@'))
2799b50d902SRodney W. Grimes *np++ = *p;
2809b50d902SRodney W. Grimes else
2819b50d902SRodney W. Grimes *ap++ = *p;
2829b50d902SRodney W. Grimes
2839b50d902SRodney W. Grimes *np++ = NULL;
2849b50d902SRodney W. Grimes *ap++ = NULL;
2859b50d902SRodney W. Grimes
2869b50d902SRodney W. Grimes if (!*argv)
2879b50d902SRodney W. Grimes goto net;
2889b50d902SRodney W. Grimes
2899b50d902SRodney W. Grimes /*
2907ce8924aSBrian Somers * Mark any arguments beginning with '/' as invalid so that we
291487ac9acSUlrich Spörlein * don't accidentally confuse them with expansions from finger.conf
2927ce8924aSBrian Somers */
2937ce8924aSBrian Somers for (p = argv, ip = used; *p; ++p, ++ip)
2947ce8924aSBrian Somers if (**p == '/') {
2957ce8924aSBrian Somers *ip = 1;
2967ce8924aSBrian Somers warnx("%s: no such user", *p);
2977ce8924aSBrian Somers }
2987ce8924aSBrian Somers
2997ce8924aSBrian Somers /*
300098c6e87SBrian Somers * Traverse the finger alias configuration file of the form
301098c6e87SBrian Somers * alias:(user|alias), ignoring comment lines beginning '#'.
302098c6e87SBrian Somers */
303098c6e87SBrian Somers if ((conf_fp = fopen(_PATH_FINGERCONF, "r")) != NULL) {
304098c6e87SBrian Somers while(fgets(conf_alias, sizeof(conf_alias), conf_fp) != NULL) {
305098c6e87SBrian Somers conf_length = strlen(conf_alias);
306098c6e87SBrian Somers if (*conf_alias == '#' || conf_alias[--conf_length] != '\n')
307098c6e87SBrian Somers continue;
308098c6e87SBrian Somers conf_alias[conf_length] = '\0'; /* Remove trailing LF */
309098c6e87SBrian Somers if ((conf_realname = strchr(conf_alias, ':')) == NULL)
310098c6e87SBrian Somers continue;
311098c6e87SBrian Somers *conf_realname = '\0'; /* Replace : with NUL */
312098c6e87SBrian Somers for (p = argv; *p; ++p) {
313f342fec6SBruce Evans if (strcmp(*p, conf_alias) == 0) {
314098c6e87SBrian Somers if ((*p = strdup(conf_realname+1)) == NULL) {
315098c6e87SBrian Somers err(1, NULL);
316098c6e87SBrian Somers }
317098c6e87SBrian Somers }
318098c6e87SBrian Somers }
319098c6e87SBrian Somers }
320098c6e87SBrian Somers (void)fclose(conf_fp);
321098c6e87SBrian Somers }
322098c6e87SBrian Somers
323098c6e87SBrian Somers /*
3249b50d902SRodney W. Grimes * Traverse the list of possible login names and check the login name
325040864acSBrian Somers * and real name against the name specified by the user. If the name
326040864acSBrian Somers * begins with a '/', try to read the file of that name instead of
327040864acSBrian Somers * gathering the traditional finger information.
3289b50d902SRodney W. Grimes */
3299b50d902SRodney W. Grimes if (mflag)
3300272ef9bSRuslan Ermilov for (p = argv, ip = used; *p; ++p, ++ip) {
3310272ef9bSRuslan Ermilov if (**p != '/' || *ip == 1 || !show_text("", *p, "")) {
332df3f5d9dSPeter Wemm if (((pw = getpwnam(*p)) != NULL) && !hide(pw))
3339b50d902SRodney W. Grimes enter_person(pw);
3340272ef9bSRuslan Ermilov else if (!*ip)
335b14d8277SPhilippe Charnier warnx("%s: no such user", *p);
336040864acSBrian Somers }
337040864acSBrian Somers }
3389b50d902SRodney W. Grimes else {
3391b57e365SBrian Somers while ((pw = getpwent()) != NULL) {
3409b50d902SRodney W. Grimes for (p = argv, ip = used; *p; ++p, ++ip)
341040864acSBrian Somers if (**p == '/' && *ip != 1
3421b57e365SBrian Somers && show_text("", *p, ""))
343040864acSBrian Somers *ip = 1;
3441b57e365SBrian Somers else if (match(pw, *p) && !hide(pw)) {
3459b50d902SRodney W. Grimes enter_person(pw);
3469b50d902SRodney W. Grimes *ip = 1;
3479b50d902SRodney W. Grimes }
3488829c73eSJordan K. Hubbard }
3499b50d902SRodney W. Grimes for (p = argv, ip = used; *p; ++p, ++ip)
3509b50d902SRodney W. Grimes if (!*ip)
351b14d8277SPhilippe Charnier warnx("%s: no such user", *p);
3529b50d902SRodney W. Grimes }
3539b50d902SRodney W. Grimes
3549b50d902SRodney W. Grimes /* Handle network requests. */
355a5af661eSPaul Traina net: for (p = nargv; *p;) {
3569b50d902SRodney W. Grimes netfinger(*p++);
357a5af661eSPaul Traina if (*p || entries)
358a5af661eSPaul Traina printf("\n");
359a5af661eSPaul Traina }
3609b50d902SRodney W. Grimes
361ee27b3cdSStephen J. Kiernan free(nargv);
36213cf266eSXin LI free(used);
3639b50d902SRodney W. Grimes if (entries == 0)
3649b50d902SRodney W. Grimes return;
3659b50d902SRodney W. Grimes
366ad468669SJuli Mallett if (kflag)
367ad468669SJuli Mallett return;
368ad468669SJuli Mallett
3699b50d902SRodney W. Grimes /*
3709b50d902SRodney W. Grimes * Scan thru the list of users currently logged in, saving
3719b50d902SRodney W. Grimes * appropriate data whenever a match occurs.
3729b50d902SRodney W. Grimes */
37370ad88f3SEd Schouten setutxent();
37470ad88f3SEd Schouten while ((user = getutxent()) != NULL) {
37570ad88f3SEd Schouten if (user->ut_type != USER_PROCESS)
3769b50d902SRodney W. Grimes continue;
37770ad88f3SEd Schouten if ((pn = find_person(user->ut_user)) == NULL)
3789b50d902SRodney W. Grimes continue;
37970ad88f3SEd Schouten enter_where(user, pn);
3809b50d902SRodney W. Grimes }
38170ad88f3SEd Schouten endutxent();
3829b50d902SRodney W. Grimes if (db)
3834e030ba6SMark Murray for (sflag1 = R_FIRST;; sflag1 = R_NEXT) {
384df3f5d9dSPeter Wemm PERSON *tmp;
385df3f5d9dSPeter Wemm
3864e030ba6SMark Murray r = (*db->seq)(db, &key, &data, sflag1);
3879b50d902SRodney W. Grimes if (r == -1)
388df3f5d9dSPeter Wemm err(1, "db seq");
3899b50d902SRodney W. Grimes if (r == 1)
3909b50d902SRodney W. Grimes break;
391df3f5d9dSPeter Wemm memmove(&tmp, data.data, sizeof tmp);
392df3f5d9dSPeter Wemm enter_lastlog(tmp);
3939b50d902SRodney W. Grimes }
3949b50d902SRodney W. Grimes }
395