mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-29 17:32:43 +00:00
Allow finger.conf to contain aliases for files that will be displayed
when fingered. Submitted by: Mark Knight <markk@knigma.org>
This commit is contained in:
parent
6bd9abd49a
commit
040864ac7a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=65064
@ -31,6 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)extern.h 8.2 (Berkeley) 4/28/95
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
extern char tbuf[1024]; /* Temp buffer for anybody. */
|
||||
@ -48,3 +49,4 @@ void netfinger __P((char *));
|
||||
PERSON *palloc __P((void));
|
||||
char *prphone __P((char *));
|
||||
void sflag_print __P((void));
|
||||
int show_text __P((char *, char *, char *));
|
||||
|
@ -190,13 +190,11 @@ behaves as if the user in question does not exist.
|
||||
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.
|
||||
aliases will work for both local and network queries.
|
||||
.Sh ENVIRONMENT
|
||||
.Nm Finger
|
||||
utilizes the following environment variable, if it exists:
|
||||
|
@ -274,6 +274,7 @@ userlist(argc, argv)
|
||||
char conf_alias[LINE_MAX];
|
||||
char *conf_realname;
|
||||
int conf_length;
|
||||
int nip;
|
||||
|
||||
if ((nargv = malloc((argc+1) * sizeof(char *))) == NULL ||
|
||||
(used = calloc(argc, sizeof(int))) == NULL)
|
||||
@ -318,20 +319,31 @@ userlist(argc, argv)
|
||||
|
||||
/*
|
||||
* Traverse the list of possible login names and check the login name
|
||||
* and real name against the name specified by the user.
|
||||
* and real name against the name specified by the user. If the name
|
||||
* begins with a '/', try to read the file of that name instead of
|
||||
* gathering the traditional finger information.
|
||||
*/
|
||||
if (mflag)
|
||||
for (p = argv; *p; ++p)
|
||||
if (((pw = getpwnam(*p)) != NULL) && !hide(pw))
|
||||
enter_person(pw);
|
||||
else
|
||||
warnx("%s: no such user", *p);
|
||||
for (p = argv; *p; ++p) {
|
||||
if (**p == '/' && !show_text("", *p, "")) {
|
||||
if (((pw = getpwnam(*p)) != NULL) && !hide(pw))
|
||||
enter_person(pw);
|
||||
else
|
||||
warnx("%s: no such user", *p);
|
||||
}
|
||||
}
|
||||
else {
|
||||
while ((pw = getpwent()) != NULL) {
|
||||
nip = 0;
|
||||
while (nip < argc && (pw = getpwent()) != NULL) {
|
||||
for (p = argv, ip = used; *p; ++p, ++ip)
|
||||
if (match(pw, *p) && !hide(pw)) {
|
||||
if (**p == '/' && *ip != 1
|
||||
&& show_text("", *p, "")) {
|
||||
*ip = 1;
|
||||
nip++;
|
||||
} else if (match(pw, *p) && !hide(pw)) {
|
||||
enter_person(pw);
|
||||
*ip = 1;
|
||||
nip++;
|
||||
}
|
||||
}
|
||||
for (p = argv, ip = used; *p; ++p, ++ip)
|
||||
|
@ -38,13 +38,17 @@ The optional
|
||||
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.
|
||||
as their preferred mail address, or for providing virtual login names
|
||||
than can be fingered.
|
||||
.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.
|
||||
A target name should be either a user, a forward
|
||||
reference to another alias or the path of a world readable file.
|
||||
.Pp
|
||||
Where an alias points to a file, the contents of that file will be displayed
|
||||
when the alias is fingered.
|
||||
.Sh EXAMPLES
|
||||
.Bd -literal
|
||||
# /etc/finger.conf alias definition file
|
||||
@ -56,6 +60,11 @@ reference to another alias.
|
||||
markk:mkn
|
||||
john.smith:dev329
|
||||
john:dev329
|
||||
sue:/etc/finger/sue.txt
|
||||
#
|
||||
# Network status message
|
||||
#
|
||||
status:/usr/local/etc/status.txt
|
||||
#
|
||||
# Administrative redirects
|
||||
#
|
||||
|
@ -59,16 +59,14 @@ static const char rcsid[] =
|
||||
#include <string.h>
|
||||
#include <paths.h>
|
||||
#include "finger.h"
|
||||
#include "pathnames.h"
|
||||
#include "extern.h"
|
||||
|
||||
#define LINE_LEN 80
|
||||
#define TAB_LEN 8 /* 8 spaces between tabs */
|
||||
#define _PATH_FORWARD ".forward"
|
||||
#define _PATH_PLAN ".plan"
|
||||
#define _PATH_PROJECT ".project"
|
||||
|
||||
static int demi_print __P((char *, int));
|
||||
static void lprint __P((PERSON *));
|
||||
static int show_text __P((char *, char *, char *));
|
||||
static void vputc __P((unsigned char));
|
||||
|
||||
void
|
||||
@ -290,7 +288,7 @@ demi_print(str, oddfield)
|
||||
return(oddfield);
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
show_text(directory, file_name, header)
|
||||
char *directory, *file_name, *header;
|
||||
{
|
||||
@ -316,7 +314,8 @@ show_text(directory, file_name, header)
|
||||
if (*p == '\n')
|
||||
break;
|
||||
if (cnt <= 1) {
|
||||
(void)printf("%s: ", header);
|
||||
if (*header != '\0')
|
||||
(void)printf("%s: ", header);
|
||||
for (p = tbuf, cnt = nr; cnt--; ++p)
|
||||
if (*p != '\r')
|
||||
vputc(lastc = *p);
|
||||
@ -330,7 +329,8 @@ show_text(directory, file_name, header)
|
||||
}
|
||||
if ((fp = fdopen(fd, "r")) == NULL)
|
||||
return(0);
|
||||
(void)printf("%s:\n", header);
|
||||
if (*header != '\0')
|
||||
(void)printf("%s:\n", header);
|
||||
while ((ch = getc(fp)) != EOF)
|
||||
if (ch != '\r')
|
||||
vputc(lastc = ch);
|
||||
|
@ -26,6 +26,14 @@
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef PATHNAMES_H
|
||||
|
||||
#define _PATH_FORWARD ".forward"
|
||||
#define _PATH_PLAN ".plan"
|
||||
#define _PATH_PROJECT ".project"
|
||||
|
||||
#ifndef _PATH_FINGERCONF
|
||||
#define _PATH_FINGERCONF "/etc/finger.conf"
|
||||
#endif /* _PATH_FINGERCONF */
|
||||
|
||||
#endif /* PATHNAMES_H */
|
||||
|
Loading…
Reference in New Issue
Block a user