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>
This commit is contained in:
Brian Somers 2000-08-17 10:59:17 +00:00
parent a948e10a1c
commit 098c6e8747
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=64775
5 changed files with 162 additions and 1 deletions

View File

@ -1,6 +1,9 @@
# @(#)Makefile 8.1 (Berkeley) 6/6/93
# $FreeBSD$
PROG= finger
SRCS= finger.c lprint.c net.c sprint.c util.c
MAN1= finger.1
MAN5= finger.conf.5
.include <bsd.prog.mk>

View File

@ -186,6 +186,17 @@ If the file
exists in the user's home directory,
.Nm finger
behaves as if the user in question does not exist.
.Pp
The optional
.Xr finger.conf 5
configuration file can be used to specify aliases.
This is particularly useful where a user's login name is not their
preferred mail address.
Since
.Xr finger 1
is invoked by
.Xr fingerd 8
these aliases will work for both local and network queries.
.Sh ENVIRONMENT
.Nm Finger
utilizes the following environment variable, if it exists:
@ -196,6 +207,8 @@ This variable may be set with favored options to
.El
.Sh FILES
.Bl -tag -width /var/log/lastlog -compact
.It Pa /etc/finger.conf
alias definition data base
.It Pa /var/log/lastlog
last login data base
.El
@ -203,7 +216,9 @@ last login data base
.Xr chpass 1 ,
.Xr w 1 ,
.Xr who 1 ,
.Xr ttcp 4 .
.Xr ttcp 4 ,
.Xr finger.conf 5 ,
.Xr fingerd 8 .
.Rs
.%A D. Zimmerman
.%T The Finger User Information Protocol

View File

@ -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)
@ -286,6 +292,30 @@ userlist(argc, argv)
if (!*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.

View File

@ -0,0 +1,82 @@
.\"Copyright (c) 2000 Mark Knight <markk@knigma.org>
.\"All rights reserved.
.\"
.\"Redistribution and use in source and binary forms, with or without
.\"modification, are permitted provided that the following conditions
.\"are met:
.\"1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\"2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\"THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\"ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\"IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\"ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
.\"FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\"DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\"OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\"HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\"LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\"OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\"SUCH DAMAGE.
.\"
.\"$FreeBSD$
.\"
.Dd August 16, 2000
.Dt FINGER.CONF 5
.Os FreeBSD
.Sh NAME
.Nm finger.conf
.Nd
.Xr finger 1
alias configuration file
.Sh DESCRIPTION
The optional
.Nm finger.conf
file is used to provide aliases that can be fingered by local
and network users.
This may be useful where a user's login name is not the same
as their preferred mail address.
.Pp
Lines beginning with ``#'' are comments.
Other lines must consist of an
alias name and a target name separated by a colon.
A target name should be either a user, or a forward
reference to another alias.
.Sh EXAMPLES
.Bd -literal
# /etc/finger.conf alias definition file
#
# Format alias:(user|alias)
#
# Individual aliases
#
markk:mkn
john.smith:dev329
john:dev329
#
# Administrative redirects
#
root:admin
postmaster:admin
abuse:admin
#
# For the time being, 'sod' is sysadmin.
#
admin:sod
.Ed
.Sh FILES
.Bl -tag -width /etc/finger.conf -compact
.It Pa /etc/finger.conf
.Xr finger 1
alias definition data base
.El
.Sh SEE ALSO
.Xr finger 1 .
.Sh HISTORY
Support for the
.Nm finger.conf
file was submitted by Mark Knight <markk@knigma.org> and first appeared in
.Fx 5.0 .

View File

@ -0,0 +1,31 @@
/*-
* Copyright (c) 2000 Mark Knight <markk@knigma.org>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef _PATH_FINGERCONF
#define _PATH_FINGERCONF "/etc/finger.conf"
#endif /* _PATH_FINGERCONF */