diff options
author | brian <brian@FreeBSD.org> | 2000-08-17 10:59:17 +0000 |
---|---|---|
committer | brian <brian@FreeBSD.org> | 2000-08-17 10:59:17 +0000 |
commit | 395771585c2aca7ec6d0a59b0a95b19012b3f890 (patch) | |
tree | 2194b4a78edc1212e333bce425b643d24e98a8ca /usr.bin | |
parent | 01355e8af4a3105c282b454994af85f7f3ebda2c (diff) | |
download | FreeBSD-src-395771585c2aca7ec6d0a59b0a95b19012b3f890.zip FreeBSD-src-395771585c2aca7ec6d0a59b0a95b19012b3f890.tar.gz |
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>
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/finger/Makefile | 3 | ||||
-rw-r--r-- | usr.bin/finger/finger.1 | 17 | ||||
-rw-r--r-- | usr.bin/finger/finger.c | 30 | ||||
-rw-r--r-- | usr.bin/finger/finger.conf.5 | 82 | ||||
-rw-r--r-- | usr.bin/finger/pathnames.h | 31 |
5 files changed, 162 insertions, 1 deletions
diff --git a/usr.bin/finger/Makefile b/usr.bin/finger/Makefile index 944f1d0..7562aa0 100644 --- a/usr.bin/finger/Makefile +++ b/usr.bin/finger/Makefile @@ -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> diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1 index 68306b8..87ebe0b 100644 --- a/usr.bin/finger/finger.1 +++ b/usr.bin/finger/finger.1 @@ -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 diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c index 77f365a..e4269e4 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. */ diff --git a/usr.bin/finger/finger.conf.5 b/usr.bin/finger/finger.conf.5 new file mode 100644 index 0000000..5f492db --- /dev/null +++ b/usr.bin/finger/finger.conf.5 @@ -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 . diff --git a/usr.bin/finger/pathnames.h b/usr.bin/finger/pathnames.h new file mode 100644 index 0000000..6839159 --- /dev/null +++ b/usr.bin/finger/pathnames.h @@ -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 */ |