aboutsummaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1995-01-04 01:02:43 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1995-01-04 01:02:43 +0000
commit8829c73eb699ec43796e42c8e21246e4b34496b1 (patch)
tree5b6f4838073f5bd352bf7130f1d5900bdfa266cf /usr.bin
parent7c81f71c9c19624026c610d89abe11ac89b69e05 (diff)
downloadsrc-8829c73eb699ec43796e42c8e21246e4b34496b1.tar.gz
src-8829c73eb699ec43796e42c8e21246e4b34496b1.zip
Add Sean Eric Fagan's support for a ~/.nofinger file for user who prefer
their privacy. Submitted by: sef
Notes
Notes: svn path=/head/; revision=5369
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/finger/finger.16
-rw-r--r--usr.bin/finger/finger.c9
-rw-r--r--usr.bin/finger/util.c28
3 files changed, 41 insertions, 2 deletions
diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1
index 74a1a5a2d1b2..6c6492011d07 100644
--- a/usr.bin/finger/finger.1
+++ b/usr.bin/finger/finger.1
@@ -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:
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c
index 4421507b14fc..3305e9f91d75 100644
--- a/usr.bin/finger/finger.c
+++ b/usr.bin/finger/finger.c
@@ -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,
diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c
index 459c3cfda8e5..da1bb40a9171 100644
--- a/usr.bin/finger/util.c
+++ b/usr.bin/finger/util.c
@@ -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;
+}