From stolz@i2.informatik.rwth-aachen.de  Thu Mar 13 04:44:38 2003
Return-Path: <stolz@i2.informatik.rwth-aachen.de>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 6AE8437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Mar 2003 04:44:38 -0800 (PST)
Received: from atlas.informatik.rwth-aachen.de (atlas.Informatik.RWTH-Aachen.DE [137.226.194.2])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E9A1F43FA3
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Mar 2003 04:44:36 -0800 (PST)
	(envelope-from stolz@i2.informatik.rwth-aachen.de)
Received: from menelaos.informatik.rwth-aachen.de (menelaos.Informatik.RWTH-Aachen.DE [137.226.194.73])
	by atlas.informatik.rwth-aachen.de (8.11.3/8.11.3/SuSE Linux 8.11.1-0.5) with ESMTP id h2DCiaa32382
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 13 Mar 2003 13:44:36 +0100
Received: (from stolz@localhost)
	by menelaos.informatik.rwth-aachen.de (8.12.6/8.12.6/Submit) id h2DCktHb086268;
	Thu, 13 Mar 2003 13:46:55 +0100 (CET)
	(envelope-from stolz)
Message-Id: <200303131246.h2DCktHb086268@menelaos.informatik.rwth-aachen.de>
Date: Thu, 13 Mar 2003 13:46:55 +0100 (CET)
From: Volker Stolz <stolz@i2.informatik.rwth-aachen.de>
Reply-To: Volker Stolz <stolz@i2.informatik.rwth-aachen.de>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [patch] Fix bug & improve telnet status ouput on unix domain sockets
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         49983
>Category:       bin
>Synopsis:       [patch] Fix bug & improve telnet status ouput on unix domain sockets
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    maxim
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Mar 13 04:50:14 PST 2003
>Closed-Date:    Sun Feb 13 12:57:17 GMT 2005
>Last-Modified:  Sun Feb 13 12:57:17 GMT 2005
>Originator:     Volker Stolz
>Release:        FreeBSD 4.7-STABLE i386
>Organization:
Lehrstuhl fr Informatik II
>Environment:
System: FreeBSD menelaos.informatik.rwth-aachen.de 4.7-STABLE FreeBSD 4.7-STABLE #2: Fri Feb 7 12:48:00 CET 2003 root@menelaos.informatik.rwth-aachen.de:/usr/src/sys/compile/MENELAOS i386


>Description:
Telnet prints incorrect status output for unix domain socket and 
leaves command mode after the first command because the connection
counter isn't increased correctly.

menelaos [13:33:03]> telnet -u /tmp/hws 
Trying /tmp/hws...
No connection.
Escape character is '^]'.
^]
telnet> status
No connection.
Escape character is '^]'.
menelaos [13:41:27]>

The attached patch correctly counts the connection and improves
telnet status output:

Trying /tmp/hws...
Connected to /tmp/hws.
Escape character is '^]'.
^]
telnet> status
Connected to /tmp/hws.
Operating in obsolete linemode
Local character echo
Escape character is '^]'.
 (still connected)

>How-To-Repeat:
Cf. description, connect to unix domain socket, query
connection status.
>Fix:
- set 'hostname' to unix domain socket path
- increase connection counter

--- telnet begins here ---
diff -urN telnet.orig/commands.c telnet/commands.c
--- telnet.orig/commands.c	Sat Nov 30 06:35:13 2002
+++ telnet/commands.c	Thu Mar 13 13:17:31 2003
@@ -2005,6 +2005,7 @@
 		    hostp);
 		goto fail;
 	}
+	hostname = hostp;
 	memset(&su, 0, sizeof su);
 	su.sun_family = AF_UNIX;
 	strncpy(su.sun_path, hostp, sizeof su.sun_path);
@@ -2207,6 +2208,7 @@
         freeaddrinfo(src_res0);
     cmdrc(hostp, hostname);
  af_unix:    
+    connected++;
     if (autologin && user == NULL) {
 	struct passwd *pw;
 
--- telnet ends here ---
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->markm 
Responsible-Changed-By: kris 
Responsible-Changed-When: Fri Jul 18 15:02:39 PDT 2003 
Responsible-Changed-Why:  
Assign to telnet maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=49983 
State-Changed-From-To: open->patched 
State-Changed-By: maxim 
State-Changed-When: Tue Jan 4 21:22:55 GMT 2005 
State-Changed-Why:  
Fixed in -CURRENT, thanks! 


Responsible-Changed-From-To: markm->maxim 
Responsible-Changed-By: maxim 
Responsible-Changed-When: Tue Jan 4 21:22:55 GMT 2005 
Responsible-Changed-Why:  
MFC reminder. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=49983 
State-Changed-From-To: patched->closed 
State-Changed-By: maxim 
State-Changed-When: Sun Feb 13 12:56:43 GMT 2005 
State-Changed-Why:  
Fixed in RELENG_4 and RELENG_5, thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=49983 
>Unformatted:
