From alex@prime.bit.ab.ru  Tue Aug 27 22:38:25 2002
Return-Path: <alex@prime.bit.ab.ru>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 68EF437B400
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Aug 2002 22:38:25 -0700 (PDT)
Received: from prime.bit.ab.ru (prime.bit.ab.ru [212.94.98.54])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 6CA4943E65
	for <FreeBSD-gnats-submit@freebsd.org>; Tue, 27 Aug 2002 22:38:21 -0700 (PDT)
	(envelope-from alex@prime.bit.ab.ru)
Received: from prime.bit.ab.ru (localhost [127.0.0.1])
	by prime.bit.ab.ru (8.12.3/8.12.3) with ESMTP id g7S5cFI7051763
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 28 Aug 2002 12:38:15 +0700 (OMSST)
	(envelope-from alex@prime.bit.ab.ru)
Received: (from root@localhost)
	by prime.bit.ab.ru (8.12.3/8.12.3/Submit) id g7S5cEj7051762;
	Wed, 28 Aug 2002 12:38:14 +0700 (OMSST)
	(envelope-from alex)
Message-Id: <200208280538.g7S5cEj7051762@prime.bit.ab.ru>
Date: Wed, 28 Aug 2002 12:38:14 +0700 (OMSST)
From: Alex Masterov <alex@prime.bit.ab.ru>
Reply-To: Alex Masterov <alex@infobit.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: ftpd works wrong if ACCT command was used.
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         42108
>Category:       bin
>Synopsis:       ftpd works wrong if ACCT command was used.
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 27 22:40:01 PDT 2002
>Closed-Date:    Sat Aug 31 06:20:34 PDT 2002
>Last-Modified:  Sat Aug 31 06:20:34 PDT 2002
>Originator:     Alex Masterov
>Release:        FreeBSD 4.6.2-RELEASE i386
>Organization:
Infocom-BIT
>Environment:
System: FreeBSD prime.bit.ab.ru 4.6.2-RELEASE FreeBSD 4.6.2-RELEASE #0: Mon Aug 26 00:19:34 OMSST 2002 alex@prime.bit.ab.ru:/usr/obj/usr/src/sys/FIFTH i386

iP4-1200, 256MB RAM, Adaptec 19160, HDD - IBM IC35L018UWD210-0, Video - Ati Mach64
>Description:
	If client side uses ACCT command, ftpd refuses any command and brokes connection. 
	This problem begins with FreeBSD 4.6.2-RELEASE, when ftpd is changed to ftpd, that was shipped with FreeBSD 4.5-RELEASE, problem disappears.
>How-To-Repeat:
	On FreeBSD 4.6.2 host with enabled ftpd:
# ftp localhost
Connected to localhost.
220 prime.bit.ab.ru FTP server (Version 6.00LS) ready.
Name (localhost:alex): anonymous
331 Guest login ok, send your email address as password.
Password:
230- Welcome to BIT Anonymous FTP site!
230 Guest login ok, access restrictions apply.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> account a
502 ACCT command not implemented.
ftp> ls
229 Entering Extended Passive Mode (|||49204|)
wrong server: return code must be 227
ftp> ls
227 Entering Passive Mode (127,0,0,1,192,53)
ftp: connect: Connection refused
ftp>

	
>Fix:

Don't know :(

>Release-Note:
>Audit-Trail:

From: Maxim Konovalov <maxim@FreeBSD.org>
To: Alex Masterov <alex@infobit.ru>
Cc: bug-followup@FreeBSD.org, <yar@FreeBSD.org>,
	<millert@OpenBSD.org>
Subject: Re: bin/42108: ftpd works wrong if ACCT command was used.
Date: Wed, 28 Aug 2002 17:33:25 +0400 (MSD)

 Please try a patch below. It is for RELENG_4_6_2_RELEASE.
 
 Yar, could you please review/commit the changes? yylex() returns
 NOTIMPL for not implemented commands and only for them. NOTIMPL is
 only user of nack() now and we can move its functionality to NOTIMPL.
 
 As far as I understand, OpenBSD has this bug too, so I CC'ed
 millert@OpenBSD.org, an author of rev. 1.26 ftpcmd.y.
 
 Index: ftpcmd.y
 ===================================================================
 RCS file: /home/ncvs/src/libexec/ftpd/ftpcmd.y,v
 retrieving revision 1.16.2.9
 diff -u -r1.16.2.9 ftpcmd.y
 --- ftpcmd.y	15 Apr 2002 15:41:53 -0000	1.16.2.9
 +++ ftpcmd.y	28 Aug 2002 13:17:03 -0000
 @@ -135,7 +135,7 @@
 
  	UMASK	IDLE	CHMOD	MDFIVE
 
 -	LEXERR
 +	LEXERR	NOTIMPL
 
  %token	<s> STRING
  %token	<u> NUMBER
 @@ -144,7 +144,7 @@
  %type	<u.i> check_login_ro check_login_epsv
  %type	<u.i> struct_code mode_code type_code form_code
  %type	<s> pathstring pathname password username
 -%type	<s> ALL
 +%type	<s> ALL NOTIMPL
 
  %start	cmd_list
 
 @@ -753,6 +753,10 @@
  			reply(221, "Goodbye.");
  			dologout(0);
  		}
 +	| NOTIMPL
 +		{
 +			nack($1);
 +		}
  	| error
  		{
  			yyclearin;		/* discard lookahead data */
 @@ -1294,12 +1298,10 @@
  			p = lookup(cmdtab, cbuf);
  			cbuf[cpos] = c;
  			if (p != 0) {
 -				if (p->implemented == 0) {
 -					nack(p->name);
 -					return (LEXERR);
 -				}
 -				state = p->state;
  				yylval.s = p->name;
 +				if (p->implemented == 0)
 +					return (NOTIMPL);
 +				state = p->state;
  				return (p->token);
  			}
  			break;
 @@ -1318,13 +1320,12 @@
  			p = lookup(sitetab, cp);
  			cbuf[cpos] = c;
  			if (guest == 0 && p != 0) {
 +				yylval.s = p->name;
  				if (p->implemented == 0) {
  					state = CMD;
 -					nack(p->name);
 -					return (LEXERR);
 +					return (NOTIMPL);
  				}
  				state = p->state;
 -				yylval.s = p->name;
  				return (p->token);
  			}
  			state = CMD;
 
 %%%
 
 -- 
 Maxim Konovalov, maxim@FreeBSD.org
 
 
 

From: Yar Tikhiy <yar@FreeBSD.org>
To: Maxim Konovalov <maxim@FreeBSD.org>
Cc: Alex Masterov <alex@infobit.ru>, bug-followup@FreeBSD.org,
	millert@OpenBSD.org
Subject: Re: bin/42108: ftpd works wrong if ACCT command was used.
Date: Thu, 29 Aug 2002 00:32:37 +0400

 On Wed, Aug 28, 2002 at 05:33:25PM +0400, Maxim Konovalov wrote:
 > 
 > Yar, could you please review/commit the changes? yylex() returns
 > NOTIMPL for not implemented commands and only for them. NOTIMPL is
 > only user of nack() now and we can move its functionality to NOTIMPL.
 
 The patch looks good to me.  I'll commit it tomorrow if no objections
 arise till then.
 
 -- 
 Yar
State-Changed-From-To: open->closed 
State-Changed-By: yar 
State-Changed-When: Sat Aug 31 06:19:20 PDT 2002 
State-Changed-Why:  
Fixed in -CURRENT and -STABLE, thanks! 


Responsible-Changed-From-To: freebsd-bugs->yar 
Responsible-Changed-By: yar 
Responsible-Changed-When: Sat Aug 31 06:19:20 PDT 2002 
Responsible-Changed-Why:  
So I can see possible feedback. 

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