Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 17 Jan 2002 12:07:28 +1100 (EST)
From:      "Tim J. Robbins" <tim@robbins.dropbear.id.au>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/33971: finger could check if T/TCP is disabled and imply -T
Message-ID:  <200201170107.g0H17So50756@raven.robbins.dropbear.id.au>

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

>Number:         33971
>Category:       bin
>Synopsis:       finger could check if T/TCP is disabled and imply -T
>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:   Wed Jan 16 17:20:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Tim J. Robbins
>Release:        FreeBSD 4.5-RC i386
>Organization:
>Environment:
System: FreeBSD raven.robbins.dropbear.id.au 4.5-RC FreeBSD 4.5-RC #3: Sat Jan 12 17:11:56 EST 2002 tim@raven.robbins.dropbear.id.au:/usr/obj/usr/src/sys/RAVEN i386


	
>Description:
/usr/bin/finger supports T/TCP, and this support may be disabled with the
-T option. The way the T/TCP support is implemented in `finger' causes
strange error messages ("read: Connection refused") and makes it take
longer than usual to give these errors on what the source code terms
"broken hosts".
>How-To-Repeat:
	
>Fix:
Use net.inet.tcp.rfc1644 sysctl to determine whether T/TCP has been enabled.
Imply the -T option if it has.


--- net.c.old	Thu Jan 17 11:50:17 2002
+++ net.c	Thu Jan 17 11:57:23 2002
@@ -46,6 +46,7 @@
 #include <sys/types.h>
 #include <sys/param.h>
 #include <sys/socket.h>
+#include <sys/sysctl.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
 #include <netdb.h>
@@ -88,6 +89,8 @@
 	char *alist[1], *host;
 	struct iovec iov[3];
 	struct msghdr msg;
+	int ttcp;
+	size_t ttcp_len;
 
 	if (!(host = rindex(name, '@')))
 		return;
@@ -140,8 +143,16 @@
 	iov[msg.msg_iovlen].iov_base = "\r\n";
 	iov[msg.msg_iovlen++].iov_len = 2;
 
+	/* Determine whether we can use T/TCP (RFC 1644) */
+	ttcp_len = sizeof (ttcp);
+	if (sysctlbyname("net.inet.tcp.rfc1644", &ttcp, &ttcp_len, NULL, 0))
+		ttcp = 0;
+
 	/* -T disables T/TCP: compatibility option to finger broken hosts */
-	if (Tflag && connect(s, (struct sockaddr *)&sin, sizeof (sin))) {
+	if (Tflag)
+		ttcp = 0;
+
+	if (!ttcp && connect(s, (struct sockaddr *)&sin, sizeof (sin))) {
 		perror("finger: connect");
 		return;
 	}
>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?200201170107.g0H17So50756>