2017-11-20 19:49:47 +00:00
|
|
|
/*-
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*
|
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.
|
|
|
|
*/
|
|
|
|
|
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[] = "@(#)util.c 8.3 (Berkeley) 4/28/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
|
|
|
|
|
|
|
#include <sys/param.h>
|
2002-09-04 23:29:10 +00:00
|
|
|
#include <sys/socket.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <sys/stat.h>
|
2001-02-06 20:13:48 +00:00
|
|
|
#include <ctype.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <db.h>
|
1997-03-11 13:43:33 +00:00
|
|
|
#include <err.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <errno.h>
|
2001-02-06 20:13:48 +00:00
|
|
|
#include <fcntl.h>
|
|
|
|
#include <paths.h>
|
|
|
|
#include <pwd.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2001-02-06 20:13:48 +00:00
|
|
|
#include <unistd.h>
|
2010-01-13 17:50:58 +00:00
|
|
|
#include <utmpx.h>
|
1994-05-27 12:33:43 +00:00
|
|
|
#include "finger.h"
|
2001-07-30 16:50:47 +00:00
|
|
|
#include "pathnames.h"
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2002-03-22 01:22:50 +00:00
|
|
|
static void find_idle_and_ttywrite(WHERE *);
|
|
|
|
static void userinfo(PERSON *, struct passwd *);
|
|
|
|
static WHERE *walloc(PERSON *);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
int
|
2002-09-04 23:29:10 +00:00
|
|
|
match(struct passwd *pw, const char *user)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-02 20:13:42 +00:00
|
|
|
char *p, *t;
|
1994-05-27 12:33:43 +00:00
|
|
|
char name[1024];
|
|
|
|
|
|
|
|
if (!strcasecmp(pw->pw_name, user))
|
|
|
|
return(1);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XXX
|
|
|
|
* Why do we skip asterisks!?!?
|
|
|
|
*/
|
1999-08-21 18:25:38 +00:00
|
|
|
(void)strncpy(p = tbuf, pw->pw_gecos, sizeof(tbuf));
|
1999-08-22 17:24:25 +00:00
|
|
|
tbuf[sizeof(tbuf) - 1] = '\0';
|
1994-05-27 12:33:43 +00:00
|
|
|
if (*p == '*')
|
|
|
|
++p;
|
|
|
|
|
|
|
|
/* Ampersands get replaced by the login name. */
|
|
|
|
if ((p = strtok(p, ",")) == NULL)
|
|
|
|
return(0);
|
|
|
|
|
1999-08-22 17:24:25 +00:00
|
|
|
for (t = name; t < &name[sizeof(name) - 1] && (*t = *p) != '\0'; ++p) {
|
1999-08-21 18:25:38 +00:00
|
|
|
if (*t == '&') {
|
|
|
|
(void)strncpy(t, pw->pw_name,
|
|
|
|
sizeof(name) - (t - name));
|
|
|
|
name[sizeof(name) - 1] = '\0';
|
1999-08-22 17:24:25 +00:00
|
|
|
while (t < &name[sizeof(name) - 1] && *++t)
|
|
|
|
continue;
|
1999-08-21 18:25:38 +00:00
|
|
|
} else {
|
1994-05-27 12:33:43 +00:00
|
|
|
++t;
|
1999-08-21 18:25:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*t = '\0';
|
1997-03-11 13:43:33 +00:00
|
|
|
for (t = name; (p = strtok(t, "\t ")) != NULL; t = NULL)
|
1994-05-27 12:33:43 +00:00
|
|
|
if (!strcasecmp(p, user))
|
|
|
|
return(1);
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2002-09-04 23:29:10 +00:00
|
|
|
enter_lastlog(PERSON *pn)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-02 20:13:42 +00:00
|
|
|
WHERE *w;
|
2010-01-13 17:50:58 +00:00
|
|
|
struct utmpx *ut = NULL;
|
1994-05-27 12:33:43 +00:00
|
|
|
char doit = 0;
|
|
|
|
|
2010-01-13 17:50:58 +00:00
|
|
|
if (setutxdb(UTXDB_LASTLOGIN, NULL) == 0)
|
|
|
|
ut = getutxuser(pn->name);
|
1994-05-27 12:33:43 +00:00
|
|
|
if ((w = pn->whead) == NULL)
|
|
|
|
doit = 1;
|
2009-12-28 20:54:34 +00:00
|
|
|
else if (ut != NULL && ut->ut_type == USER_PROCESS) {
|
1994-05-27 12:33:43 +00:00
|
|
|
/* if last login is earlier than some current login */
|
|
|
|
for (; !doit && w != NULL; w = w->next)
|
2009-12-28 20:54:34 +00:00
|
|
|
if (w->info == LOGGEDIN &&
|
|
|
|
w->loginat < ut->ut_tv.tv_sec)
|
1994-05-27 12:33:43 +00:00
|
|
|
doit = 1;
|
|
|
|
/*
|
|
|
|
* and if it's not any of the current logins
|
|
|
|
* can't use time comparison because there may be a small
|
2001-02-06 20:13:48 +00:00
|
|
|
* discrepancy since login calls time() twice
|
1994-05-27 12:33:43 +00:00
|
|
|
*/
|
|
|
|
for (w = pn->whead; doit && w != NULL; w = w->next)
|
|
|
|
if (w->info == LOGGEDIN &&
|
2009-12-28 20:54:34 +00:00
|
|
|
strcmp(w->tty, ut->ut_line) == 0)
|
1994-05-27 12:33:43 +00:00
|
|
|
doit = 0;
|
|
|
|
}
|
2009-12-28 20:54:34 +00:00
|
|
|
if (ut != NULL && doit) {
|
1994-05-27 12:33:43 +00:00
|
|
|
w = walloc(pn);
|
|
|
|
w->info = LASTLOG;
|
2009-12-28 20:54:34 +00:00
|
|
|
strcpy(w->tty, ut->ut_line);
|
|
|
|
strcpy(w->host, ut->ut_host);
|
|
|
|
w->loginat = ut->ut_tv.tv_sec;
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
2010-01-13 17:50:58 +00:00
|
|
|
endutxent();
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2009-12-28 20:54:34 +00:00
|
|
|
enter_where(struct utmpx *ut, PERSON *pn)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-02 20:13:42 +00:00
|
|
|
WHERE *w;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
w = walloc(pn);
|
|
|
|
w->info = LOGGEDIN;
|
2009-12-28 20:54:34 +00:00
|
|
|
strcpy(w->tty, ut->ut_line);
|
|
|
|
strcpy(w->host, ut->ut_host);
|
|
|
|
w->loginat = ut->ut_tv.tv_sec;
|
1994-05-27 12:33:43 +00:00
|
|
|
find_idle_and_ttywrite(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
PERSON *
|
2002-09-04 23:29:10 +00:00
|
|
|
enter_person(struct passwd *pw)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
DBT data, key;
|
|
|
|
PERSON *pn;
|
|
|
|
|
|
|
|
if (db == NULL &&
|
|
|
|
(db = dbopen(NULL, O_RDWR, 0, DB_BTREE, NULL)) == NULL)
|
1997-03-11 13:43:33 +00:00
|
|
|
err(1, NULL);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
key.data = pw->pw_name;
|
|
|
|
key.size = strlen(pw->pw_name);
|
|
|
|
|
1997-03-11 13:43:33 +00:00
|
|
|
switch ((*db->get)(db, &key, &data, 0)) {
|
1994-05-27 12:33:43 +00:00
|
|
|
case 0:
|
1997-03-11 13:43:33 +00:00
|
|
|
memmove(&pn, data.data, sizeof pn);
|
|
|
|
return (pn);
|
1994-05-27 12:33:43 +00:00
|
|
|
default:
|
|
|
|
case -1:
|
1997-03-11 13:43:33 +00:00
|
|
|
err(1, "db get");
|
1994-05-27 12:33:43 +00:00
|
|
|
/* NOTREACHED */
|
|
|
|
case 1:
|
|
|
|
++entries;
|
|
|
|
pn = palloc();
|
|
|
|
userinfo(pn, pw);
|
|
|
|
pn->whead = NULL;
|
|
|
|
|
|
|
|
data.size = sizeof(PERSON *);
|
|
|
|
data.data = &pn;
|
|
|
|
if ((*db->put)(db, &key, &data, 0))
|
1997-03-11 13:43:33 +00:00
|
|
|
err(1, "db put");
|
|
|
|
return (pn);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PERSON *
|
2009-12-28 20:54:34 +00:00
|
|
|
find_person(char *name)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
1995-01-04 01:02:43 +00:00
|
|
|
struct passwd *pw;
|
|
|
|
|
1994-05-27 12:33:43 +00:00
|
|
|
DBT data, key;
|
1997-03-11 13:43:33 +00:00
|
|
|
PERSON *p;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
if (!db)
|
|
|
|
return(NULL);
|
|
|
|
|
1995-01-04 01:02:43 +00:00
|
|
|
if ((pw = getpwnam(name)) && hide(pw))
|
|
|
|
return(NULL);
|
|
|
|
|
2009-12-28 20:54:34 +00:00
|
|
|
key.data = name;
|
|
|
|
key.size = strlen(name);
|
1994-05-27 12:33:43 +00:00
|
|
|
|
1997-03-11 13:43:33 +00:00
|
|
|
if ((*db->get)(db, &key, &data, 0))
|
|
|
|
return (NULL);
|
|
|
|
memmove(&p, data.data, sizeof p);
|
|
|
|
return (p);
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PERSON *
|
2002-09-04 23:29:10 +00:00
|
|
|
palloc(void)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
PERSON *p;
|
|
|
|
|
2002-05-17 05:11:07 +00:00
|
|
|
if ((p = malloc(sizeof(PERSON))) == NULL)
|
1997-03-11 13:43:33 +00:00
|
|
|
err(1, NULL);
|
1994-05-27 12:33:43 +00:00
|
|
|
return(p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static WHERE *
|
2002-09-04 23:29:10 +00:00
|
|
|
walloc(PERSON *pn)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-02 20:13:42 +00:00
|
|
|
WHERE *w;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
2002-05-17 05:11:07 +00:00
|
|
|
if ((w = malloc(sizeof(WHERE))) == NULL)
|
1997-03-11 13:43:33 +00:00
|
|
|
err(1, NULL);
|
1994-05-27 12:33:43 +00:00
|
|
|
if (pn->whead == NULL)
|
|
|
|
pn->whead = pn->wtail = w;
|
|
|
|
else {
|
|
|
|
pn->wtail->next = w;
|
|
|
|
pn->wtail = w;
|
|
|
|
}
|
|
|
|
w->next = NULL;
|
|
|
|
return(w);
|
|
|
|
}
|
|
|
|
|
|
|
|
char *
|
2002-09-04 23:29:10 +00:00
|
|
|
prphone(char *num)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-02 20:13:42 +00:00
|
|
|
char *p;
|
1994-05-27 12:33:43 +00:00
|
|
|
int len;
|
1999-08-21 18:25:38 +00:00
|
|
|
static char pbuf[20];
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
/* don't touch anything if the user has their own formatting */
|
|
|
|
for (p = num; *p; ++p)
|
|
|
|
if (!isdigit(*p))
|
|
|
|
return(num);
|
|
|
|
len = p - num;
|
|
|
|
p = pbuf;
|
|
|
|
switch(len) {
|
|
|
|
case 11: /* +0-123-456-7890 */
|
|
|
|
*p++ = '+';
|
|
|
|
*p++ = *num++;
|
|
|
|
*p++ = '-';
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case 10: /* 012-345-6789 */
|
|
|
|
*p++ = *num++;
|
|
|
|
*p++ = *num++;
|
|
|
|
*p++ = *num++;
|
|
|
|
*p++ = '-';
|
|
|
|
/* FALLTHROUGH */
|
|
|
|
case 7: /* 012-3456 */
|
|
|
|
*p++ = *num++;
|
|
|
|
*p++ = *num++;
|
|
|
|
*p++ = *num++;
|
|
|
|
break;
|
|
|
|
case 5: /* x0-1234 */
|
1994-09-07 07:22:41 +00:00
|
|
|
case 4: /* x1234 */
|
1994-05-27 12:33:43 +00:00
|
|
|
*p++ = 'x';
|
|
|
|
*p++ = *num++;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return(num);
|
|
|
|
}
|
1994-09-07 07:22:41 +00:00
|
|
|
if (len != 4) {
|
|
|
|
*p++ = '-';
|
|
|
|
*p++ = *num++;
|
|
|
|
}
|
1994-05-27 12:33:43 +00:00
|
|
|
*p++ = *num++;
|
|
|
|
*p++ = *num++;
|
|
|
|
*p++ = *num++;
|
|
|
|
*p = '\0';
|
|
|
|
return(pbuf);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-09-04 23:29:10 +00:00
|
|
|
find_idle_and_ttywrite(WHERE *w)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
|
|
|
struct stat sb;
|
2000-12-21 01:30:47 +00:00
|
|
|
time_t touched;
|
2003-04-02 20:22:29 +00:00
|
|
|
int error;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
(void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_DEV, w->tty);
|
2003-04-02 20:22:29 +00:00
|
|
|
|
|
|
|
error = stat(tbuf, &sb);
|
|
|
|
if (error < 0 && errno == ENOENT) {
|
|
|
|
/*
|
|
|
|
* The terminal listed is not actually a terminal (i.e.,
|
|
|
|
* ":0"). This is a failure, so we'll skip printing
|
|
|
|
* out the idle time, which is non-ideal but better
|
|
|
|
* than a bogus warning and idle time.
|
|
|
|
*/
|
|
|
|
w->idletime = -1;
|
|
|
|
return;
|
|
|
|
} else if (error < 0) {
|
2000-07-10 08:49:28 +00:00
|
|
|
warn("%s", tbuf);
|
2003-04-02 20:22:29 +00:00
|
|
|
w->idletime = -1;
|
1994-05-27 12:33:43 +00:00
|
|
|
return;
|
|
|
|
}
|
2000-12-21 01:30:47 +00:00
|
|
|
touched = sb.st_atime;
|
|
|
|
if (touched < w->loginat) {
|
|
|
|
/* tty untouched since before login */
|
|
|
|
touched = w->loginat;
|
|
|
|
}
|
|
|
|
w->idletime = now < touched ? 0 : now - touched;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
#define TALKABLE 0220 /* tty is writable if 220 mode */
|
|
|
|
w->writable = ((sb.st_mode & TALKABLE) == TALKABLE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2002-09-04 23:29:10 +00:00
|
|
|
userinfo(PERSON *pn, struct passwd *pw)
|
1994-05-27 12:33:43 +00:00
|
|
|
{
|
2001-12-02 20:13:42 +00:00
|
|
|
char *p, *t;
|
1994-05-27 12:33:43 +00:00
|
|
|
char *bp, name[1024];
|
1994-09-07 07:22:41 +00:00
|
|
|
struct stat sb;
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
pn->realname = pn->office = pn->officephone = pn->homephone = NULL;
|
|
|
|
|
|
|
|
pn->uid = pw->pw_uid;
|
2001-01-20 00:26:32 +00:00
|
|
|
if ((pn->name = strdup(pw->pw_name)) == NULL)
|
|
|
|
err(1, "strdup failed");
|
|
|
|
if ((pn->dir = strdup(pw->pw_dir)) == NULL)
|
|
|
|
err(1, "strdup failed");
|
|
|
|
if ((pn->shell = strdup(pw->pw_shell)) == NULL)
|
|
|
|
err(1, "strdup failed");
|
1994-05-27 12:33:43 +00:00
|
|
|
|
|
|
|
/* why do we skip asterisks!?!? */
|
1999-08-21 18:25:38 +00:00
|
|
|
(void)strncpy(bp = tbuf, pw->pw_gecos, sizeof(tbuf));
|
1999-08-22 17:24:25 +00:00
|
|
|
tbuf[sizeof(tbuf) - 1] = '\0';
|
1994-05-27 12:33:43 +00:00
|
|
|
if (*bp == '*')
|
|
|
|
++bp;
|
|
|
|
|
|
|
|
/* ampersands get replaced by the login name */
|
|
|
|
if (!(p = strsep(&bp, ",")))
|
|
|
|
return;
|
1999-08-22 17:24:25 +00:00
|
|
|
for (t = name; t < &name[sizeof(name) - 1] && (*t = *p) != '\0'; ++p) {
|
1994-05-27 12:33:43 +00:00
|
|
|
if (*t == '&') {
|
1999-08-21 18:25:38 +00:00
|
|
|
(void)strncpy(t, pw->pw_name,
|
|
|
|
sizeof(name) - (t - name));
|
|
|
|
name[sizeof(name) - 1] = '\0';
|
1994-05-27 12:33:43 +00:00
|
|
|
if (islower(*t))
|
|
|
|
*t = toupper(*t);
|
1999-08-22 17:24:25 +00:00
|
|
|
while (t < &name[sizeof(name) - 1] && *++t)
|
|
|
|
continue;
|
1999-08-21 18:25:38 +00:00
|
|
|
} else {
|
1994-05-27 12:33:43 +00:00
|
|
|
++t;
|
1999-08-21 18:25:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
*t = '\0';
|
2001-01-20 00:26:32 +00:00
|
|
|
if ((pn->realname = strdup(name)) == NULL)
|
|
|
|
err(1, "strdup failed");
|
1994-05-27 12:33:43 +00:00
|
|
|
pn->office = ((p = strsep(&bp, ",")) && *p) ?
|
|
|
|
strdup(p) : NULL;
|
|
|
|
pn->officephone = ((p = strsep(&bp, ",")) && *p) ?
|
|
|
|
strdup(p) : NULL;
|
|
|
|
pn->homephone = ((p = strsep(&bp, ",")) && *p) ?
|
|
|
|
strdup(p) : NULL;
|
1999-08-21 18:25:38 +00:00
|
|
|
(void)snprintf(tbuf, sizeof(tbuf), "%s/%s", _PATH_MAILDIR, pw->pw_name);
|
1994-09-07 07:22:41 +00:00
|
|
|
pn->mailrecv = -1; /* -1 == not_valid */
|
|
|
|
if (stat(tbuf, &sb) < 0) {
|
|
|
|
if (errno != ENOENT) {
|
1997-07-02 06:34:51 +00:00
|
|
|
warn("%s", tbuf);
|
1994-09-07 07:22:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else if (sb.st_size != 0) {
|
|
|
|
pn->mailrecv = sb.st_mtime;
|
|
|
|
pn->mailread = sb.st_atime;
|
|
|
|
}
|
1994-05-27 12:33:43 +00:00
|
|
|
}
|
|
|
|
|
1995-01-04 01:02:43 +00:00
|
|
|
/*
|
|
|
|
* Is this user hiding from finger?
|
|
|
|
* If ~<user>/.nofinger exists, return 1 (hide), else return 0 (nohide).
|
2005-09-19 10:11:47 +00:00
|
|
|
* Nobody can hide from root.
|
1995-01-04 01:02:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
int
|
2002-09-04 23:29:10 +00:00
|
|
|
hide(struct passwd *pw)
|
1995-01-04 01:02:43 +00:00
|
|
|
{
|
2001-08-08 21:22:48 +00:00
|
|
|
struct stat st;
|
2001-03-01 05:52:38 +00:00
|
|
|
char buf[MAXPATHLEN];
|
1995-01-04 01:02:43 +00:00
|
|
|
|
2005-09-19 10:11:47 +00:00
|
|
|
if (invoker_root || !pw->pw_dir)
|
1995-01-04 01:02:43 +00:00
|
|
|
return 0;
|
|
|
|
|
2001-07-30 16:50:47 +00:00
|
|
|
snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir, _PATH_NOFINGER);
|
1995-01-04 01:02:43 +00:00
|
|
|
|
2001-08-08 21:22:48 +00:00
|
|
|
if (stat(buf, &st) == 0)
|
1995-01-04 01:02:43 +00:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|