mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-29 20:54:13 +01:00
Add Sean Eric Fagan's support for a ~/.nofinger file for user who prefer
their privacy. Submitted by: sef
This commit is contained in:
parent
e90dae4bf6
commit
9bea03d7a2
@ -173,6 +173,12 @@ style.
|
||||
The
|
||||
.Fl l
|
||||
option is the only option that may be passed to a remote machine.
|
||||
.Pp
|
||||
If the file
|
||||
.Dq Pa .nofinger
|
||||
exists in the user's home directory,
|
||||
.Nm finger
|
||||
behaves as if the user in question does not exist.
|
||||
.Sh ENVIRONMENT
|
||||
.Nm Finger
|
||||
utilizes the following environment variable, if it exists:
|
||||
|
@ -202,6 +202,8 @@ loginlist()
|
||||
bcopy(user.ut_name, name, UT_NAMESIZE);
|
||||
if ((pw = getpwnam(name)) == NULL)
|
||||
continue;
|
||||
if (hide(pw))
|
||||
continue;
|
||||
pn = enter_person(pw);
|
||||
}
|
||||
enter_where(&user, pn);
|
||||
@ -252,18 +254,21 @@ userlist(argc, argv)
|
||||
*/
|
||||
if (mflag)
|
||||
for (p = argv; *p; ++p)
|
||||
if (pw = getpwnam(*p))
|
||||
if ((pw = getpwnam(*p)) && !hide(pw))
|
||||
enter_person(pw);
|
||||
else
|
||||
(void)fprintf(stderr,
|
||||
"finger: %s: no such user\n", *p);
|
||||
else {
|
||||
while (pw = getpwent())
|
||||
while (pw = getpwent()) {
|
||||
if (hide (pw))
|
||||
continue;
|
||||
for (p = argv, ip = used; *p; ++p, ++ip)
|
||||
if (match(pw, *p)) {
|
||||
enter_person(pw);
|
||||
*ip = 1;
|
||||
}
|
||||
}
|
||||
for (p = argv, ip = used; *p; ++p, ++ip)
|
||||
if (!*ip)
|
||||
(void)fprintf(stderr,
|
||||
|
@ -200,6 +200,8 @@ PERSON *
|
||||
find_person(name)
|
||||
char *name;
|
||||
{
|
||||
struct passwd *pw;
|
||||
|
||||
register int cnt;
|
||||
DBT data, key;
|
||||
char buf[UT_NAMESIZE + 1];
|
||||
@ -207,6 +209,9 @@ find_person(name)
|
||||
if (!db)
|
||||
return(NULL);
|
||||
|
||||
if ((pw = getpwnam(name)) && hide(pw))
|
||||
return(NULL);
|
||||
|
||||
/* Name may be only UT_NAMESIZE long and not NUL terminated. */
|
||||
for (cnt = 0; cnt < UT_NAMESIZE && *name; ++name, ++cnt)
|
||||
buf[cnt] = *name;
|
||||
@ -396,3 +401,26 @@ err(fmt, va_alist)
|
||||
exit(1);
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
/*
|
||||
* Is this user hiding from finger?
|
||||
* If ~<user>/.nofinger exists, return 1 (hide), else return 0 (nohide).
|
||||
*/
|
||||
|
||||
int
|
||||
hide(pw)
|
||||
struct passwd *pw;
|
||||
{
|
||||
int fd;
|
||||
char buf[MAXPATHLEN+1];
|
||||
|
||||
if (!pw->pw_dir)
|
||||
return 0;
|
||||
|
||||
sprintf (buf, "%s/.nofinger", pw->pw_dir);
|
||||
|
||||
if (access (buf, F_OK) == 0)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user