svn commit: r256380 - stable/8/libexec/fingerd

Dag-Erling Smørgrav des at FreeBSD.org
Sat Oct 12 14:54:26 UTC 2013


Author: des
Date: Sat Oct 12 14:54:25 2013
New Revision: 256380
URL: http://svnweb.freebsd.org/changeset/base/256380

Log:
  MFH (206038,206040): add a -k option which is passed through to finger(1).
  Almost to the day three and a half years after the original MFC date...

Modified:
  stable/8/libexec/fingerd/fingerd.8
  stable/8/libexec/fingerd/fingerd.c
Directory Properties:
  stable/8/libexec/fingerd/   (props changed)

Modified: stable/8/libexec/fingerd/fingerd.8
==============================================================================
--- stable/8/libexec/fingerd/fingerd.8	Sat Oct 12 14:23:33 2013	(r256379)
+++ stable/8/libexec/fingerd/fingerd.8	Sat Oct 12 14:54:25 2013	(r256380)
@@ -32,7 +32,7 @@
 .\"     @(#)fingerd.8	8.1 (Berkeley) 6/4/93
 .\" $FreeBSD$
 .\"
-.Dd June 4, 1993
+.Dd April 1, 2010
 .Dt FINGERD 8
 .Os
 .Sh NAME
@@ -40,6 +40,8 @@
 .Nd remote user information server
 .Sh SYNOPSIS
 .Nm
+.Op Fl d
+.Op Fl k
 .Op Fl s
 .Op Fl l
 .Op Fl p Ar filename
@@ -106,6 +108,25 @@ The following options may be passed to
 as server program arguments in
 .Pa /etc/inetd.conf :
 .Bl -tag -width indent
+.It Fl d
+Enable debugging mode.
+In debugging mode,
+.Nm
+will not attempt any network-related operations on
+.Va stdin ,
+and it will print the full
+.Nm finger
+command line
+to
+.Va stderr
+before executing it.
+.It Fl k
+Suppress login information.
+See the description of the
+.Fl k
+option in
+.Xr finger 1
+for details.
 .It Fl s
 Enable secure mode.
 Queries without a user name are rejected and

Modified: stable/8/libexec/fingerd/fingerd.c
==============================================================================
--- stable/8/libexec/fingerd/fingerd.c	Sat Oct 12 14:23:33 2013	(r256379)
+++ stable/8/libexec/fingerd/fingerd.c	Sat Oct 12 14:54:25 2013	(r256380)
@@ -72,17 +72,23 @@ main(int argc, char *argv[])
 	char *lp;
 	struct sockaddr_storage ss;
 	socklen_t sval;
-	int p[2], logging, pflag, secure;
+	int p[2], debug, kflag, logging, pflag, secure;
 #define	ENTRIES	50
 	char **ap, *av[ENTRIES + 1], **comp, line[1024], *prog;
 	char rhost[MAXHOSTNAMELEN];
 
 	prog = _PATH_FINGER;
-	logging = pflag = secure = 0;
+	debug = logging = kflag = pflag = secure = 0;
 	openlog("fingerd", LOG_PID | LOG_CONS, LOG_DAEMON);
 	opterr = 0;
-	while ((ch = getopt(argc, argv, "lp:s")) != -1)
+	while ((ch = getopt(argc, argv, "dklp:s")) != -1)
 		switch (ch) {
+		case 'd':
+			debug = 1;
+			break;
+		case 'k':
+			kflag = 1;
+			break;
 		case 'l':
 			logging = 1;
 			break;
@@ -101,7 +107,7 @@ main(int argc, char *argv[])
 	/*
 	 * Enable server-side Transaction TCP.
 	 */
-	{
+	if (!debug) {
 		int one = 1;
 		if (setsockopt(STDOUT_FILENO, IPPROTO_TCP, TCP_NOPUSH, &one, 
 			       sizeof one) < 0) {
@@ -112,7 +118,7 @@ main(int argc, char *argv[])
 	if (!fgets(line, sizeof(line), stdin))
 		exit(1);
 
-	if (logging || pflag) {
+	if (!debug && (logging || pflag)) {
 		sval = sizeof(ss);
 		if (getpeername(0, (struct sockaddr *)&ss, &sval) < 0)
 			logerr("getpeername: %s", strerror(errno));
@@ -143,12 +149,14 @@ main(int argc, char *argv[])
 		syslog(LOG_NOTICE, "query from %s: `%s'", rhost, t);
 	}
 
-	comp = &av[1];
-	av[2] = "--";
-	for (lp = line, ap = &av[3];;) {
+	comp = &av[2];
+	av[3] = "--";
+	if (kflag)
+		*comp-- = "-k";
+	for (lp = line, ap = &av[4];;) {
 		*ap = strtok(lp, " \t\r\n");
 		if (!*ap) {
-			if (secure && ap == &av[3]) {
+			if (secure && ap == &av[4]) {
 				puts("must provide username\r\n");
 				exit(1);
 			}
@@ -161,8 +169,7 @@ main(int argc, char *argv[])
 
 		/* RFC742: "/[Ww]" == "-l" */
 		if ((*ap)[0] == '/' && ((*ap)[1] == 'W' || (*ap)[1] == 'w')) {
-			av[1] = "-l";
-			comp = &av[0];
+			*comp-- = "-l";
 		}
 		else if (++ap == av + ENTRIES) {
 			*ap = NULL;
@@ -178,6 +185,13 @@ main(int argc, char *argv[])
 	if (pipe(p) < 0)
 		logerr("pipe: %s", strerror(errno));
 
+	if (debug) {
+		fprintf(stderr, "%s", prog);
+		for (ap = comp; *ap != NULL; ++ap)
+			fprintf(stderr, " %s", *ap);
+		fprintf(stderr, "\n");
+	}
+
 	switch(vfork()) {
 	case 0:
 		(void)close(p[0]);


More information about the svn-src-all mailing list