Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Jun 2002 04:34:40 -0700 (PDT)
From:      Mike Makonnen <makonnen@pacbell.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   bin/39463: [PATCH] Add several options to fingerd
Message-ID:  <200206181134.g5IBYeD0008313@kokeb.ambesa.net>

next in thread | raw e-mail | index | archive | help

>Number:         39463
>Category:       bin
>Synopsis:       [PATCH] Add several options to fingerd
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Tue Jun 18 04:30:06 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Mike Makonnen
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
>Environment:
FreeBSD kokeb.ambesa.net 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Mon Jun 17 04:15:41 PDT 2002     mikem@kokeb.ambesa.net:/FreeBSD/builds/current/obj/FreeBSD/builds/current/src.orig/sys/GENERIC  i386

	
>Description:
The following patch adds several options to fingerd that are obtained
from NetBSD.
	o -g : Restricts output of the gecos field
	o -h : Displays name of remote host in short mode
	o -m : Prevent matching of user names (i.e. from gecos)
	o -P : Restricts output of .plan .forward .pubkey .project files
	o -S : Prints information in short mode, one line per user

All the options behave the same as in NetBSD, except for the -P option.
It's actually supposed to be -p (small case) but that's already used.

Note that the -g option depends on finger(1) having a -g option, which 
it currently doesn't. I have submitted a separate pr for that in
bin/39462.
	
>How-To-Repeat:
	
>Fix:

	



--- fingerd.patch begins here ---
Index: libexec/fingerd/fingerd.8
===================================================================
RCS file: /home/ncvs/src/libexec/fingerd/fingerd.8,v
retrieving revision 1.8
diff -u -r1.8 fingerd.8
--- libexec/fingerd/fingerd.8	10 Aug 2001 13:45:21 -0000	1.8
+++ libexec/fingerd/fingerd.8	18 Jun 2002 11:19:13 -0000
@@ -32,7 +32,7 @@
 .\"     @(#)fingerd.8	8.1 (Berkeley) 6/4/93
 .\" $FreeBSD: src/libexec/fingerd/fingerd.8,v 1.8 2001/08/10 13:45:21 ru Exp $
 .\"
-.Dd June 4, 1993
+.Dd June 18, 2002
 .Dt FINGERD 8
 .Os
 .Sh NAME
@@ -42,6 +42,11 @@
 .Nm
 .Op Fl s
 .Op Fl l
+.Op Fl h
+.Op Fl m
+.Op Fl P
+.Op Fl S
+.Op Fl g
 .Op Fl p Ar filename
 .Sh DESCRIPTION
 .Nm Fingerd
@@ -97,15 +102,27 @@
 as server program arguments in
 .Pa /etc/inetd.conf :
 .Bl -tag -width indent
-.It Fl s
-Enable secure mode.
-Queries without a user name are rejected and
-forwarding of queries to other remote hosts is denied.
+.It Fl g
+Do not show any gecos information besides the users' real names. When
+used in conjunction with the
+.Fl h
+option, it also has the side-effect of restricting output of the
+host name from which the user is connected.
+.It Fl h
+Display the name of the remote host in short mode,
+instead of the office location and office phone.
 .It Fl l
 Enable logging.
 The name of the host originating the query is reported via
 .Xr syslog 3
 at LOG_NOTICE priority.
+.It Fl m
+Prevent matching of
+.Ar user
+names.
+.Ar User
+is usually a login name; however, matching will also be done on the
+users' real names, unless this option is supplied.
 .It Fl p
 Use an alternate program as the local information provider.
 The default local program
@@ -117,6 +134,25 @@
 this option allows a system manager
 to have more control over what information is
 provided to remote sites.
+.It Fl s
+Enable secure mode.
+Queries without a user name are rejected and
+forwarding of queries to other remote hosts is denied.
+.It Fl P
+Prevents
+.Xr finger 1
+from displaying the contents of the
+.Dq Pa .plan ,
+.Dq Pa .project ,
+.Dq Pa .pubkey 
+and
+.Dq Pa .forward
+files.
+.It Fl S
+Prints user information in short mode, one line per user.
+This overrides the
+.Dq Pa Whois switch
+that may be passed in from the remote client.
 .El
 .Sh SEE ALSO
 .Xr finger 1 ,
Index: libexec/fingerd/fingerd.c
===================================================================
RCS file: /home/ncvs/src/libexec/fingerd/fingerd.c,v
retrieving revision 1.21
diff -u -r1.21 fingerd.c
--- libexec/fingerd/fingerd.c	30 May 2002 21:35:39 -0000	1.21
+++ libexec/fingerd/fingerd.c	18 Jun 2002 10:08:48 -0000
@@ -68,29 +68,47 @@
 main(int argc, char *argv[])
 {
 	FILE *fp;
-	int ch;
+	int ch, ac;
 	char *lp;
 	struct sockaddr_storage ss;
-	int p[2], logging, secure, sval;
+	int p[2], logging, secure, short_list, sval;
 #define	ENTRIES	50
 	char **ap, *av[ENTRIES + 1], **comp, line[1024], *prog;
 	char rhost[MAXHOSTNAMELEN];
 
+	ac = 2;
+	short_list = 0;
 	prog = _PATH_FINGER;
 	logging = secure = 0;
 	openlog("fingerd", LOG_PID | LOG_CONS, LOG_DAEMON);
 	opterr = 0;
-	while ((ch = getopt(argc, argv, "slp:")) != -1)
+	while ((ch = getopt(argc, argv, "slghmPSp:")) != -1)
 		switch (ch) {
+		case 'g':
+			av[ac++] = "-g";
+			break;
+		case 'h':
+			av[ac++] = "-h";
+			break;
 		case 'l':
 			logging = 1;
 			break;
+		case 'm':
+			av[ac++] = "-m";
+			break;
 		case 'p':
 			prog = optarg;
 			break;
 		case 's':
 			secure = 1;
 			break;
+		case 'P':
+			av[ac++] = "-p";
+			break;
+		case 'S':
+			short_list = 1;
+			av[ac++] = "-s";
+			break;
 		case '?':
 		default:
 			logerr("illegal option -- %c", optopt);
@@ -137,11 +155,11 @@
 	}
 
 	comp = &av[1];
-	av[2] = "--";
-	for (lp = line, ap = &av[3];;) {
+	av[ac++] = "--";
+	for (lp = line, ap = &av[ac];;) {
 		*ap = strtok(lp, " \t\r\n");
 		if (!*ap) {
-			if (secure && ap == &av[3]) {
+			if (secure && (strcmp("--", av[ac - 1]) == 0)) {
 				puts("must provide username\r\n");
 				exit(1);
 			}
@@ -154,12 +172,17 @@
 
 		/* RFC742: "/[Ww]" == "-l" */
 		if ((*ap)[0] == '/' && ((*ap)[1] == 'W' || (*ap)[1] == 'w')) {
-			av[1] = "-l";
-			comp = &av[0];
+			if (!short_list) {
+				av[1] = "-l";
+				comp = &av[0];
+			}
 		}
-		else if (++ap == av + ENTRIES) {
-			*ap = NULL;
-			break;
+		else {
+			ac++;
+			if (++ap == av + ENTRIES) {
+				*ap = NULL;
+				break;
+			}
 		}
 		lp = NULL;
 	}
--- fingerd.patch ends here ---

>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206181134.g5IBYeD0008313>