1994-05-27 12:33:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 1989, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* Tony Nardo of the Johns Hopkins University/Applied Physics Lab.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2017-02-28 23:42:47 +00:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1994-05-27 12:33:43 +00:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1994-09-07 07:22:41 +00:00
|
|
|
/*
|
|
|
|
* Luke Mewburn <lm@rmit.edu.au> added the following on 940622:
|
|
|
|
* - mail status ("No Mail", "Mail read:...", or "New Mail ...,
|
|
|
|
* Unread since ...".)
|
|
|
|
* - 4 digit phone extensions (3210 is printed as x3210.)
|
|
|
|
* - host/office toggling in short format with -h & -o.
|
|
|
|
* - short day names (`Tue' printed instead of `Jun 21' if the
|
|
|
|
* login time is < 6 days.
|
|
|
|
*/
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
#ifndef lint
|
2000-10-23 12:18:34 +00:00
|
|
|
static const char copyright[] =
|
1994-05-27 12:33:43 +00:00
|
|
|
"@(#) Copyright (c) 1989, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n";
|
|
|
|
#endif /* not lint */
|
|
|
|
|
2001-12-10 21:13:08 +00:00
|
|
|
#if 0
|
1994-05-27 12:33:43 +00:00
|
|
|
#ifndef lint
|
2001-12-10 21:13:08 +00:00
|
|
|
static char sccsid[] = "@(#)finger.c 8.5 (Berkeley) 5/4/95";
|
2001-02-06 20:13:48 +00:00
|
|
|
#endif
|
2001-12-10 21:13:08 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Finger prints out information about users. It is not portable since
|
|
|
|
* certain fields (e.g. the full user name, office, and phone numbers) are
|
|
|
|
* extracted from the gecos field of the passwd file which other UNIXes
|
|
|
|
* may not have or may use for other things.
|
|
|
|
*
|
|
|
|
* There are currently two output formats; the short format is one line
|
|
|
|
* per user and displays login name, tty, login time, real name, idle time,
|
1994-09-07 07:22:41 +00:00
|
|
|
* and either remote host information (default) or office location/phone
|
|
|
|
* number, depending on if -h or -o is used respectively.
|
|
|
|
* The long format gives the same information (in a more legible format) as
|
|
|
|
* well as home directory, shell, mail info, and .plan/.project files.
|
1994-05-27 12:33:43 +00:00
|
|
|
*/
|
|
|
|
|
2002-07-22 17:19:54 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/socket.h>
|
1997-03-11 13:43:33 +00:00
|
|
|
#include <db.h>
|
|
|
|
#include <err.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <pwd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
1997-03-11 13:43:33 +00:00
|
|
|
#include <time.h>
|
|
|
|
#include <unistd.h>
|
2010-01-13 17:50:58 +00:00
|
|
|
#include <utmpx.h>
|
1995-10-24 04:18:45 +00:00
|
|
|
#include <locale.h>
|
1997-03-11 13:43:33 +00:00
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
#include "finger.h"
|
2000-08-17 10:59:17 +00:00
|
|
|
#include "pathnames.h"
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
DB *db;
|
|
|
|
time_t now;
|
2012-10-19 14:49:42 +00:00
|
|
|
static int kflag, mflag, sflag;
|
|
|
|
int entries, gflag, lflag, pplan, oflag;
|
2002-10-31 13:05:56 +00:00
|
|
|
sa_family_t family = PF_UNSPEC;
|
2001-03-21 18:43:49 +00:00
|
|
|
int d_first = -1;
|
1994-05-27 12:33:43 +00:00
|
|
|
char tbuf[1024];
|
2005-09-19 10:11:47 +00:00
|
|
|
int invoker_root = 0;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2002-03-22 01:22:50 +00:00
|
|
|
static void loginlist(void);
|
|
|
|
static int option(int, char **);
|
|
|
|
static void usage(void);
|
|
|
|
static void userlist(int, char **);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2001-12-02 20:13:42 +00:00
|
|
|
static int
|
2002-09-04 23:29:10 +00:00
|
|
|
option(int argc, char **argv)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
|
1994-09-08 19:27:06 +00:00
|
|
|
optind = 1; /* reset getopt */
|
1994-09-07 07:22:41 +00:00
|
|
|
|
2007-04-11 20:32:09 +00:00
|
|
|
while ((ch = getopt(argc, argv, "46gklmpsho")) != -1)
|
1994-05-27 12:33:43 +00:00
|
|
|
switch(ch) {
|
2002-07-22 17:19:54 +00:00
|
|
|
case '4':
|
|
|
|
family = AF_INET;
|
|
|
|
break;
|
|
|
|
case '6':
|
|
|
|
family = AF_INET6;
|
|
|
|
break;
|
2002-07-02 08:00:20 +00:00
|
|
|
case 'g':
|
|
|
|
gflag = 1;
|
|
|
|
break;
|
2003-06-28 23:11:41 +00:00
|
|
|
case 'k':
|
|
|
|
kflag = 1; /* keep going without utmp */
|
|
|
|
break;
|
1994-05-27 12:33:43 +00:00
|
|
|
case 'l':
|
|
|
|
lflag = 1; /* long format */
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
mflag = 1; /* force exact match of names */
|
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
pplan = 1; /* don't show .plan/.project */
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
sflag = 1; /* short format */
|
|
|
|
break;
|
1994-09-07 07:22:41 +00:00
|
|
|
case 'h':
|
|
|
|
oflag = 0; /* remote host info */
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
oflag = 1; /* office info */
|
|
|
|
break;
|
1994-05-27 12:33:43 +00:00
|
|
|
case '?':
|
|
|
|
default:
|
1997-07-02 06:34:51 +00:00
|
|
|
usage();
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
1994-09-08 19:27:06 +00:00
|
|
|
|
|
|
|
return optind;
|
|
|
|
}
|
|
|
|
|
1997-07-02 06:34:51 +00:00
|
|
|
static void
|
2002-09-04 23:29:10 +00:00
|
|
|
usage(void)
|
1997-07-02 06:34:51 +00:00
|
|
|
{
|
2005-05-21 09:55:10 +00:00
|
|
|
(void)fprintf(stderr,
|
2007-04-11 20:32:09 +00:00
|
|
|
"usage: finger [-46gklmpsho] [user ...] [user@host ...]\n");
|
1997-07-02 06:34:51 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2002-09-04 23:29:10 +00:00
|
|
|
main(int argc, char **argv)
|
1994-09-08 19:27:06 +00:00
|
|
|
{
|
1997-07-02 06:34:51 +00:00
|
|
|
int envargc, argcnt;
|
1994-09-08 19:27:06 +00:00
|
|
|
char *envargv[3];
|
1999-05-08 00:46:06 +00:00
|
|
|
struct passwd *pw;
|
2001-12-02 20:13:42 +00:00
|
|
|
static char myname[] = "finger";
|
1999-05-08 00:46:06 +00:00
|
|
|
|
|
|
|
if (getuid() == 0 || geteuid() == 0) {
|
2005-09-19 10:11:47 +00:00
|
|
|
invoker_root = 1;
|
1999-05-08 00:46:06 +00:00
|
|
|
if ((pw = getpwnam(UNPRIV_NAME)) && pw->pw_uid > 0) {
|
2011-04-23 14:19:26 +00:00
|
|
|
if (setgid(pw->pw_gid) != 0)
|
|
|
|
err(1, "setgid()");
|
|
|
|
if (setuid(pw->pw_uid) != 0)
|
|
|
|
err(1, "setuid()");
|
1999-05-08 00:46:06 +00:00
|
|
|
} else {
|
2011-04-23 14:19:26 +00:00
|
|
|
if (setgid(UNPRIV_UGID) != 0)
|
|
|
|
err(1, "setgid()");
|
|
|
|
if (setuid(UNPRIV_UGID) != 0)
|
|
|
|
err(1, "setuid()");
|
1999-05-08 00:46:06 +00:00
|
|
|
}
|
|
|
|
}
|
1994-09-08 19:27:06 +00:00
|
|
|
|
1995-10-26 11:03:08 +00:00
|
|
|
(void) setlocale(LC_ALL, "");
|
1995-10-24 04:18:45 +00:00
|
|
|
|
1994-09-08 19:27:06 +00:00
|
|
|
/* remove this line to get remote host */
|
|
|
|
oflag = 1; /* default to old "office" behavior */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Process environment variables followed by command line arguments.
|
|
|
|
*/
|
|
|
|
if ((envargv[1] = getenv("FINGER"))) {
|
|
|
|
envargc = 2;
|
2001-12-02 20:13:42 +00:00
|
|
|
envargv[0] = myname;
|
1994-09-08 19:27:06 +00:00
|
|
|
envargv[2] = NULL;
|
|
|
|
(void) option(envargc, envargv);
|
|
|
|
}
|
|
|
|
|
|
|
|
argcnt = option(argc, argv);
|
|
|
|
argc -= argcnt;
|
|
|
|
argv += argcnt;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
(void)time(&now);
|
|
|
|
setpassent(1);
|
|
|
|
if (!*argv) {
|
|
|
|
/*
|
|
|
|
* Assign explicit "small" format if no names given and -l
|
|
|
|
* not selected. Force the -s BEFORE we get names so proper
|
|
|
|
* screening will be done.
|
|
|
|
*/
|
|
|
|
if (!lflag)
|
|
|
|
sflag = 1; /* if -l not explicit, force -s */
|
|
|
|
loginlist();
|
|
|
|
if (entries == 0)
|
|
|
|
(void)printf("No one logged on.\n");
|
|
|
|
} else {
|
|
|
|
userlist(argc, argv);
|
|
|
|
/*
|
|
|
|
* Assign explicit "large" format if names given and -s not
|
|
|
|
* explicitly stated. Force the -l AFTER we get names so any
|
|
|
|
* remote finger attempts specified won't be mishandled.
|
|
|
|
*/
|
|
|
|
if (!sflag)
|
|
|
|
lflag = 1; /* if -s not explicit, force -l */
|
|
|
|
}
|
1999-07-04 17:26:16 +00:00
|
|
|
if (entries) {
|
1994-05-27 12:33:43 +00:00
|
|
|
if (lflag)
|
|
|
|
lflag_print();
|
|
|
|
else
|
|
|
|
sflag_print();
|
1999-07-04 17:26:16 +00:00
|
|
|
}
|
1997-03-11 13:43:33 +00:00
|
|
|
return (0);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-09-04 23:29:10 +00:00
|
|
|
loginlist(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-02 20:13:42 +00:00
|
|
|
PERSON *pn;
|
1994-05-27 12:33:43 +00:00
|
|
|
DBT data, key;
|
|
|
|
struct passwd *pw;
|
2009-12-28 20:54:34 +00:00
|
|
|
struct utmpx *user;
|
2001-12-02 20:13:42 +00:00
|
|
|
int r, sflag1;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2003-06-28 23:11:41 +00:00
|
|
|
if (kflag)
|
|
|
|
errx(1, "can't list logins without reading utmp");
|
|
|
|
|
2009-12-28 20:54:34 +00:00
|
|
|
setutxent();
|
|
|
|
while ((user = getutxent()) != NULL) {
|
|
|
|
if (user->ut_type != USER_PROCESS)
|
1994-05-27 12:33:43 +00:00
|
|
|
continue;
|
2009-12-28 20:54:34 +00:00
|
|
|
if ((pn = find_person(user->ut_user)) == NULL) {
|
|
|
|
if ((pw = getpwnam(user->ut_user)) == NULL)
|
1994-05-27 12:33:43 +00:00
|
|
|
continue;
|
1995-01-04 01:02:43 +00:00
|
|
|
if (hide(pw))
|
|
|
|
continue;
|
1994-05-27 12:33:43 +00:00
|
|
|
pn = enter_person(pw);
|
|
|
|
}
|
2009-12-28 20:54:34 +00:00
|
|
|
enter_where(user, pn);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2009-12-28 20:54:34 +00:00
|
|
|
endutxent();
|
1994-05-27 12:33:43 +00:00
|
|
|
if (db && lflag)
|
2001-12-02 20:13:42 +00:00
|
|
|
for (sflag1 = R_FIRST;; sflag1 = R_NEXT) {
|
1997-03-11 13:43:33 +00:00
|
|
|
PERSON *tmp;
|
|
|
|
|
2001-12-02 20:13:42 +00:00
|
|
|
r = (*db->seq)(db, &key, &data, sflag1);
|
1994-05-27 12:33:43 +00:00
|
|
|
if (r == -1)
|
1997-03-11 13:43:33 +00:00
|
|
|
err(1, "db seq");
|
1994-05-27 12:33:43 +00:00
|
|
|
if (r == 1)
|
|
|
|
break;
|
1997-03-11 13:43:33 +00:00
|
|
|
memmove(&tmp, data.data, sizeof tmp);
|
|
|
|
enter_lastlog(tmp);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-09-04 23:29:10 +00:00
|
|
|
userlist(int argc, char **argv)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-02 20:13:42 +00:00
|
|
|
PERSON *pn;
|
1994-05-27 12:33:43 +00:00
|
|
|
DBT data, key;
|
2009-12-28 20:54:34 +00:00
|
|
|
struct utmpx *user;
|
1994-05-27 12:33:43 +00:00
|
|
|
struct passwd *pw;
|
2001-12-02 20:13:42 +00:00
|
|
|
int r, sflag1, *used, *ip;
|
1994-05-27 12:33:43 +00:00
|
|
|
char **ap, **nargv, **np, **p;
|
2000-08-17 10:59:17 +00:00
|
|
|
FILE *conf_fp;
|
|
|
|
char conf_alias[LINE_MAX];
|
|
|
|
char *conf_realname;
|
|
|
|
int conf_length;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL ||
|
|
|
|
(used = calloc(argc, sizeof(int))) == NULL)
|
1997-03-11 13:43:33 +00:00
|
|
|
err(1, NULL);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
/* Pull out all network requests. */
|
|
|
|
for (ap = p = argv, np = nargv; *p; ++p)
|
2012-01-03 18:51:58 +00:00
|
|
|
if (strchr(*p, '@'))
|
1994-05-27 12:33:43 +00:00
|
|
|
*np++ = *p;
|
|
|
|
else
|
|
|
|
*ap++ = *p;
|
|
|
|
|
|
|
|
*np++ = NULL;
|
|
|
|
*ap++ = NULL;
|
|
|
|
|
|
|
|
if (!*argv)
|
|
|
|
goto net;
|
|
|
|
|
2000-10-02 22:27:34 +00:00
|
|
|
/*
|
2011-12-30 11:02:40 +00:00
|
|
|
* Mark any arguments beginning with '/' as invalid so that we
|
|
|
|
* don't accidentally confuse them with expansions from finger.conf
|
2000-10-02 22:27:34 +00:00
|
|
|
*/
|
|
|
|
for (p = argv, ip = used; *p; ++p, ++ip)
|
|
|
|
if (**p == '/') {
|
|
|
|
*ip = 1;
|
|
|
|
warnx("%s: no such user", *p);
|
|
|
|
}
|
|
|
|
|
2000-08-17 10:59:17 +00:00
|
|
|
/*
|
|
|
|
* Traverse the finger alias configuration file of the form
|
|
|
|
* alias:(user|alias), ignoring comment lines beginning '#'.
|
|
|
|
*/
|
|
|
|
if ((conf_fp = fopen(_PATH_FINGERCONF, "r")) != NULL) {
|
|
|
|
while(fgets(conf_alias, sizeof(conf_alias), conf_fp) != NULL) {
|
|
|
|
conf_length = strlen(conf_alias);
|
|
|
|
if (*conf_alias == '#' || conf_alias[--conf_length] != '\n')
|
|
|
|
continue;
|
|
|
|
conf_alias[conf_length] = '\0'; /* Remove trailing LF */
|
|
|
|
if ((conf_realname = strchr(conf_alias, ':')) == NULL)
|
|
|
|
continue;
|
|
|
|
*conf_realname = '\0'; /* Replace : with NUL */
|
|
|
|
for (p = argv; *p; ++p) {
|
2004-03-14 05:51:20 +00:00
|
|
|
if (strcmp(*p, conf_alias) == 0) {
|
2000-08-17 10:59:17 +00:00
|
|
|
if ((*p = strdup(conf_realname+1)) == NULL) {
|
|
|
|
err(1, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
(void)fclose(conf_fp);
|
|
|
|
}
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
/*
|
|
|
|
* Traverse the list of possible login names and check the login name
|
2000-08-25 01:01:07 +00:00
|
|
|
* and real name against the name specified by the user. If the name
|
|
|
|
* begins with a '/', try to read the file of that name instead of
|
|
|
|
* gathering the traditional finger information.
|
1994-05-27 12:33:43 +00:00
|
|
|
*/
|
|
|
|
if (mflag)
|
2000-10-05 15:56:13 +00:00
|
|
|
for (p = argv, ip = used; *p; ++p, ++ip) {
|
|
|
|
if (**p != '/' || *ip == 1 || !show_text("", *p, "")) {
|
2000-08-25 01:01:07 +00:00
|
|
|
if (((pw = getpwnam(*p)) != NULL) && !hide(pw))
|
|
|
|
enter_person(pw);
|
2000-10-05 15:56:13 +00:00
|
|
|
else if (!*ip)
|
2000-08-25 01:01:07 +00:00
|
|
|
warnx("%s: no such user", *p);
|
|
|
|
}
|
|
|
|
}
|
1994-05-27 12:33:43 +00:00
|
|
|
else {
|
2000-09-12 21:58:31 +00:00
|
|
|
while ((pw = getpwent()) != NULL) {
|
1994-05-27 12:33:43 +00:00
|
|
|
for (p = argv, ip = used; *p; ++p, ++ip)
|
2000-08-25 01:01:07 +00:00
|
|
|
if (**p == '/' && *ip != 1
|
2000-09-12 21:58:31 +00:00
|
|
|
&& show_text("", *p, ""))
|
2000-08-25 01:01:07 +00:00
|
|
|
*ip = 1;
|
2000-09-12 21:58:31 +00:00
|
|
|
else if (match(pw, *p) && !hide(pw)) {
|
1994-05-27 12:33:43 +00:00
|
|
|
enter_person(pw);
|
|
|
|
*ip = 1;
|
|
|
|
}
|
1995-01-04 01:02:43 +00:00
|
|
|
}
|
1994-05-27 12:33:43 +00:00
|
|
|
for (p = argv, ip = used; *p; ++p, ++ip)
|
|
|
|
if (!*ip)
|
1997-07-02 06:34:51 +00:00
|
|
|
warnx("%s: no such user", *p);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Handle network requests. */
|
1994-12-05 10:01:39 +00:00
|
|
|
net: for (p = nargv; *p;) {
|
1994-05-27 12:33:43 +00:00
|
|
|
netfinger(*p++);
|
1994-12-05 10:01:39 +00:00
|
|
|
if (*p || entries)
|
|
|
|
printf("\n");
|
|
|
|
}
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2009-12-21 19:15:30 +00:00
|
|
|
free(used);
|
1994-05-27 12:33:43 +00:00
|
|
|
if (entries == 0)
|
|
|
|
return;
|
|
|
|
|
2003-06-28 23:11:41 +00:00
|
|
|
if (kflag)
|
|
|
|
return;
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
/*
|
|
|
|
* Scan thru the list of users currently logged in, saving
|
|
|
|
* appropriate data whenever a match occurs.
|
|
|
|
*/
|
2009-12-28 20:54:34 +00:00
|
|
|
setutxent();
|
|
|
|
while ((user = getutxent()) != NULL) {
|
|
|
|
if (user->ut_type != USER_PROCESS)
|
1994-05-27 12:33:43 +00:00
|
|
|
continue;
|
2009-12-28 20:54:34 +00:00
|
|
|
if ((pn = find_person(user->ut_user)) == NULL)
|
1994-05-27 12:33:43 +00:00
|
|
|
continue;
|
2009-12-28 20:54:34 +00:00
|
|
|
enter_where(user, pn);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2009-12-28 20:54:34 +00:00
|
|
|
endutxent();
|
1994-05-27 12:33:43 +00:00
|
|
|
if (db)
|
2001-12-02 20:13:42 +00:00
|
|
|
for (sflag1 = R_FIRST;; sflag1 = R_NEXT) {
|
1997-03-11 13:43:33 +00:00
|
|
|
PERSON *tmp;
|
|
|
|
|
2001-12-02 20:13:42 +00:00
|
|
|
r = (*db->seq)(db, &key, &data, sflag1);
|
1994-05-27 12:33:43 +00:00
|
|
|
if (r == -1)
|
1997-03-11 13:43:33 +00:00
|
|
|
err(1, "db seq");
|
1994-05-27 12:33:43 +00:00
|
|
|
if (r == 1)
|
|
|
|
break;
|
1997-03-11 13:43:33 +00:00
|
|
|
memmove(&tmp, data.data, sizeof tmp);
|
|
|
|
enter_lastlog(tmp);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|