From freebsd@snark.ratmir.ru  Mon Apr  7 11:42:00 2003
Return-Path: <freebsd@snark.ratmir.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 40FFF37B401
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Apr 2003 11:42:00 -0700 (PDT)
Received: from snark.ratmir.ru (snark.ratmir.ru [213.24.248.177])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 00F7543FA3
	for <FreeBSD-gnats-submit@freebsd.org>; Mon,  7 Apr 2003 11:41:59 -0700 (PDT)
	(envelope-from freebsd@snark.ratmir.ru)
Received: from snark.ratmir.ru (freebsd@localhost [127.0.0.1])
	by snark.ratmir.ru (8.12.9/8.12.9) with ESMTP id h37IfvDR016084
	for <FreeBSD-gnats-submit@freebsd.org>; Mon, 7 Apr 2003 22:41:57 +0400 (MSD)
	(envelope-from freebsd@snark.ratmir.ru)
Received: (from freebsd@localhost)
	by snark.ratmir.ru (8.12.9/8.12.9/Submit) id h37IfugY016083;
	Mon, 7 Apr 2003 22:41:56 +0400 (MSD)
Message-Id: <200304071841.h37IfugY016083@snark.ratmir.ru>
Date: Mon, 7 Apr 2003 22:41:56 +0400 (MSD)
From: Alex Semenyaka <alexs@snark.ratmir.ru>
Reply-To: Alex Semenyaka <alexs@snark.ratmir.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: ftpd -h does not work for the SYST command (patch included)
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         50690
>Category:       bin
>Synopsis:       ftpd -h does not work for the SYST command (patch included)
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Apr 07 11:50:15 PDT 2003
>Closed-Date:    Mon Jun 23 02:47:11 PDT 2003
>Last-Modified:  Mon Jun 23 02:47:11 PDT 2003
>Originator:     Alex Semenyaka
>Release:        FreeBSD 4.8-RC i386
>Organization:
Ratmir
>Environment:

System: FreeBSD snark.ratmir.ru 4.8-RC FreeBSD 4.8-RC #7: Sun Mar 30 07:23:48 MSD 2003 root@snark.ratmir.ru:/usr/obj/usr/src/sys/SNARK i386

Same problem exists also in the -CURRENT branch.

>Description:

When you run ftpd with the switch -h, which hould prevent obtaining the
information about system you can still have such info with SYST command

>How-To-Repeat:

Tell to inetd to run ftpd with -h like this:

ftp	stream	tcp	nowait	root	/usr/libexec/ftpd	ftpd -l -h

Then do telnet to the port 21, log in and issue SYST command:

/tmp> telnet 0 21
Trying 0.0.0.0...
Connected to 0.
Escape character is '^]'.
220 FTP server ready.
user ftp
331 Guest login ok, send your email address as password.
pass a@
230 Guest login ok, access restrictions apply.
syst
215 UNIX Type: L8 Version: BSD-199506
quit
221 Goodbye.
Connection closed by foreign host.

>Fix:

Here is the patch for -CURRENT. In the case when ftpd has been run with
the -h switch the variable hostinfo is set to TRUE. In this case we
should report only CHAR_BIT for our system and hide all other information
as we do when this ftpd is built for the unknown platform:

Index: ftpcmd.y
===================================================================
RCS file: /usr/local/FreeBSD/src/libexec/ftpd/ftpcmd.y,v
retrieving revision 1.50
diff -u -U1 -r1.50 ftpcmd.y
--- ftpcmd.y	5 Feb 2003 11:11:32 -0000	1.50
+++ ftpcmd.y	5 Apr 2003 00:11:58 -0000
@@ -690,13 +690,17 @@
 		{
-			if ($2)
+			if ($2) {
+				if (hostinfo)
 #ifdef unix
 #ifdef BSD
-			reply(215, "UNIX Type: L%d Version: BSD-%d",
-				CHAR_BIT, BSD);
+					reply(215, "UNIX Type: L%d Version: BSD-%d",
+					CHAR_BIT, BSD);
 #else /* BSD */
-			reply(215, "UNIX Type: L%d", CHAR_BIT);
+					reply(215, "UNIX Type: L%d", CHAR_BIT);
 #endif /* BSD */
 #else /* unix */
-			reply(215, "UNKNOWN Type: L%d", CHAR_BIT);
+					reply(215, "UNKNOWN Type: L%d", CHAR_BIT);
 #endif /* unix */
+				else
+					reply(215, "UNKNOWN Type: L%d", CHAR_BIT);
+				}
 		}
>Release-Note:
>Audit-Trail:

From: Yar Tikhiy <yar@FreeBSD.org>
To: freebsd-gnats-submit@FreeBSD.org, alexs@snark.ratmir.ru
Cc:  
Subject: Re: bin/50690: ftpd -h does not work for the SYST command (patch included)
Date: Tue, 8 Apr 2003 18:14:48 +0400

 I'm afraid this is likely to break GUI FTP clients,
 particularly with respect to parsing /bin/ls output.
 Could you please dispel (or confirm) my apprehension?
 
 -- 
 Yar

From: Alex Semenyaka <alexs@ratmir.ru>
To: Yar Tikhiy <yar@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org, alexs@snark.ratmir.ru
Subject: Re: bin/50690: ftpd -h does not work for the SYST command (patch included)
Date: Tue, 8 Apr 2003 20:08:40 +0400

 On Tue, Apr 08, 2003 at 06:14:48PM +0400, Yar Tikhiy wrote:
 > I'm afraid this is likely to break GUI FTP clients,
 > particularly with respect to parsing /bin/ls output.
 > Could you please dispel (or confirm) my apprehension?
 
 Sure. Checked with FAR, Microsoft Internet Explorer, WS FTP, Cute FTP,
 FTP Commander. Both binary and text transfers were ok. Macintosh clients
 will check tomorrow.
 
 								SY, ALex

From: Alex Semenyaka <alexs@ratmir.ru>
To: Yar Tikhiy <yar@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org, alexs@snark.ratmir.ru
Subject: Re: bin/50690: ftpd -h does not work for the SYST command (patch included)
Date: Thu, 17 Apr 2003 15:41:12 +0400

 On Tue, Apr 08, 2003 at 06:14:48PM +0400, Yar Tikhiy wrote:
 > I'm afraid this is likely to break GUI FTP clients,
 > particularly with respect to parsing /bin/ls output.
 > Could you please dispel (or confirm) my apprehension?
 
 I've checked the following ftp-clients:
 
 Cute FTP (Windows)
 FAR filemanager (Windows)
 FTP Commander (Windows)
 MS Internet Explorer (Windows)
 WS FTP (Windows)
 Fetch (MacOS)
 Anarchie (MacOS)
 
 No problem with listing or such was occured. So I thing we can consider those
 changes harmless. Or, if we want to be double-sure, we can introduce "-h"
 for turning on current behaviour and "-h -h" for the new one (do you need the
 corresponding fetch if this way is more preferable?).
 
 								SY, Alex
 
State-Changed-From-To: open->patched 
State-Changed-By: yar 
State-Changed-When: Mon Jun 16 04:32:07 PDT 2003 
State-Changed-Why:  
Fixed in CURRENT, thanks. 


Responsible-Changed-From-To: freebsd-bugs->yar 
Responsible-Changed-By: yar 
Responsible-Changed-When: Mon Jun 16 04:32:07 PDT 2003 
Responsible-Changed-Why:  
MFC reminder 

http://www.freebsd.org/cgi/query-pr.cgi?pr=50690 
State-Changed-From-To: patched->closed 
State-Changed-By: yar 
State-Changed-When: Mon Jun 23 02:45:59 PDT 2003 
State-Changed-Why:  
Fix has been merged to STABLE as well.  Thanks! 

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