diff options
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/finger/finger.1 | 6 | ||||
-rw-r--r-- | usr.bin/finger/finger.c | 9 | ||||
-rw-r--r-- | usr.bin/finger/util.c | 28 |
3 files changed, 41 insertions, 2 deletions
diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1 index 74a1a5a..6c64920 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 4421507..3305e9f 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 459c3cf..da1bb40 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; +} |