diff options
Diffstat (limited to 'usr.bin/finger/util.c')
-rw-r--r-- | usr.bin/finger/util.c | 28 |
1 files changed, 28 insertions, 0 deletions
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; +} |