summaryrefslogtreecommitdiffstats
path: root/usr.bin/finger
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2000-08-25 01:01:07 +0000
committerbrian <brian@FreeBSD.org>2000-08-25 01:01:07 +0000
commit4dcf00026aaae753bf32fad240e4299b3ba402d2 (patch)
tree143fea435ceadf8708a385282ea8d122e9aa2042 /usr.bin/finger
parent841b54e275fef021259a25a34650c6cfd02a3faa (diff)
downloadFreeBSD-src-4dcf00026aaae753bf32fad240e4299b3ba402d2.zip
FreeBSD-src-4dcf00026aaae753bf32fad240e4299b3ba402d2.tar.gz
Allow finger.conf to contain aliases for files that will be displayed
when fingered. Submitted by: Mark Knight <markk@knigma.org>
Diffstat (limited to 'usr.bin/finger')
-rw-r--r--usr.bin/finger/extern.h2
-rw-r--r--usr.bin/finger/finger.14
-rw-r--r--usr.bin/finger/finger.c28
-rw-r--r--usr.bin/finger/finger.conf.515
-rw-r--r--usr.bin/finger/lprint.c14
-rw-r--r--usr.bin/finger/pathnames.h8
6 files changed, 50 insertions, 21 deletions
diff --git a/usr.bin/finger/extern.h b/usr.bin/finger/extern.h
index e9abd72..69b8531 100644
--- a/usr.bin/finger/extern.h
+++ b/usr.bin/finger/extern.h
@@ -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 *));
diff --git a/usr.bin/finger/finger.1 b/usr.bin/finger/finger.1
index 87ebe0b..f794e0b 100644
--- a/usr.bin/finger/finger.1
+++ b/usr.bin/finger/finger.1
@@ -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:
diff --git a/usr.bin/finger/finger.c b/usr.bin/finger/finger.c
index e4269e4..ff9dd3c 100644
--- a/usr.bin/finger/finger.c
+++ b/usr.bin/finger/finger.c
@@ -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)
diff --git a/usr.bin/finger/finger.conf.5 b/usr.bin/finger/finger.conf.5
index a339b0c..38220a8 100644
--- a/usr.bin/finger/finger.conf.5
+++ b/usr.bin/finger/finger.conf.5
@@ -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
#
diff --git a/usr.bin/finger/lprint.c b/usr.bin/finger/lprint.c
index 3d0a409..688f16e 100644
--- a/usr.bin/finger/lprint.c
+++ b/usr.bin/finger/lprint.c
@@ -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);
diff --git a/usr.bin/finger/pathnames.h b/usr.bin/finger/pathnames.h
index 6839159..334d499 100644
--- a/usr.bin/finger/pathnames.h
+++ b/usr.bin/finger/pathnames.h
@@ -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 */
OpenPOWER on IntegriCloud