diff options
author | Brian Somers <brian@FreeBSD.org> | 2000-08-17 10:59:17 +0000 |
---|---|---|
committer | Brian Somers <brian@FreeBSD.org> | 2000-08-17 10:59:17 +0000 |
commit | 098c6e87478ebfc9143d65e1aa648af5c0152db3 (patch) | |
tree | 4a7e93da22cd0f0a51f8755f8684f34f86dabbcd /usr.bin/finger/finger.c | |
parent | a948e10a1c00519d0aef7ce7612b9fecb4eb4f0f (diff) |
Allow a /etc/finger.conf file that contains finger aliases
This allows people who's email address differs from their account name
to be fingerable.
Submitted by: Mark Knight <markk@knigma.org>
Notes
Notes:
svn path=/head/; revision=64775
Diffstat (limited to 'usr.bin/finger/finger.c')
-rw-r--r-- | usr.bin/finger/finger.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index 77f365a537a1..e4269e4384ae 100644 --- a/usr.bin/finger/finger.c +++ b/usr.bin/finger/finger.c @@ -88,8 +88,10 @@ static const char rcsid[] = #include <utmp.h> #include <db.h> #include <locale.h> +#include <sys/syslimits.h> #include "finger.h" +#include "pathnames.h" DB *db; time_t now; @@ -268,6 +270,10 @@ userlist(argc, argv) struct passwd *pw; int r, sflag, *used, *ip; char **ap, **nargv, **np, **p; + FILE *conf_fp; + char conf_alias[LINE_MAX]; + char *conf_realname; + int conf_length; if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL || (used = calloc(argc, sizeof(int))) == NULL) @@ -287,6 +293,30 @@ userlist(argc, argv) goto net; /* + * Traverse the finger alias configuration file of the form + * alias:(user|alias), ignoring comment lines beginning '#'. + */ + if ((conf_fp = fopen(_PATH_FINGERCONF, "r")) != NULL) { + while(fgets(conf_alias, sizeof(conf_alias), conf_fp) != NULL) { + conf_length = strlen(conf_alias); + if (*conf_alias == '#' || conf_alias[--conf_length] != '\n') + continue; + conf_alias[conf_length] = '\0'; /* Remove trailing LF */ + if ((conf_realname = strchr(conf_alias, ':')) == NULL) + continue; + *conf_realname = '\0'; /* Replace : with NUL */ + for (p = argv; *p; ++p) { + if (strcmp(*p, conf_alias) == NULL) { + if ((*p = strdup(conf_realname+1)) == NULL) { + err(1, NULL); + } + } + } + } + (void)fclose(conf_fp); + } + + /* * Traverse the list of possible login names and check the login name * and real name against the name specified by the user. */ |