From nobody@FreeBSD.org  Tue Dec  7 21:21:51 2004
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 412BA16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  7 Dec 2004 21:21:51 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 285A043D48
	for <freebsd-gnats-submit@FreeBSD.org>; Tue,  7 Dec 2004 21:21:51 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id iB7LLoG0047972
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 7 Dec 2004 21:21:50 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id iB7LLo7Y047971;
	Tue, 7 Dec 2004 21:21:50 GMT
	(envelope-from nobody)
Message-Id: <200412072121.iB7LLo7Y047971@www.freebsd.org>
Date: Tue, 7 Dec 2004 21:21:50 GMT
From: Alexander Melkov <melkov@comptek.ru>
To: freebsd-gnats-submit@FreeBSD.org
Subject: ftpd should not use warn(x) more carefully when used from inetd [patch]
X-Send-Pr-Version: www-2.3

>Number:         74823
>Category:       bin
>Synopsis:       ftpd should not use warn(x) more carefully when used from inetd [patch]
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    yar
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 07 21:30:13 GMT 2004
>Closed-Date:    Tue Dec 21 12:57:33 GMT 2004
>Last-Modified:  Tue Dec 21 12:57:33 GMT 2004
>Originator:     Alexander Melkov
>Release:        5.3
>Organization:
>Environment:
FreeBSD melkov.ru 5.3-RELEASE FreeBSD 5.3-RELEASE #1: Tue Nov  9 14:59:22 MSK 2004     spamtrap@melkov.ru:/usr/obj/usr/src/sys/MELKOV  i386
>Description:
When ftpd is invoked from inetd, every call to warn(x), err(x) functions produces an output that is not compliant with rfc959, etc.

This particularly happens when incorrect start-up parameters specified (that's silly, yet my internet service provider's ftp server is configured that way right now ;) ).
>How-To-Repeat:
Write
ftp    stream  tcp     nowait  root    /usr/libexec/ftpd ftpd -AWK
into /etc/inetd.conf and restart inetd

Run
ftp localhost
'ftp' program will fail to establish connection
Run
nc localhost 21
see
ftpd: illegal option -- K
ftpd: unknown flag -K ignored
220 ...... FTP server (Version 6.00LS) ready.

>Fix:
ftpd.c is 1.163
diff ftpd.c.1.163 ftpd.c
286a287
>       struct stat st;
290a292,296
>
>       if (fstat(0, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
>               extern char *__progname;
>               __progname = "220-";
>       }

- this is not a graceful solution, yet a warnx call from getopt function should be covered somehow.

>Release-Note:
>Audit-Trail:

From: "Alexander Melkov" <melkov@comptek.ru>
To: <freebsd-gnats-submit@FreeBSD.org>,
	"Alexander Melkov" <melkov@comptek.ru>
Cc:  
Subject: Re: bin/74823: ftpd should not use warn(x) more carefully when used from inetd [patch]
Date: Wed, 8 Dec 2004 01:04:39 +0300

 I'm sorry, my previous patch was slightly inaccurate.
 Because ftpd uses compiled-in ls, which in turn uses warn(x) in correct way,
 __progname should be restored
 
 Correct patch:
 diff ftpd.c.1.163 ftpd.c
 286a287,288
 >       struct stat st;
 >       char *old_progname = NULL;
 291a294,299
 >       if (fstat(0, &st) == 0 && (st.st_mode & S_IFMT) == S_IFSOCK) {
 >               extern char *__progname;
 >               old_progname = __progname;
 >               __progname = "220-";
 >       }
 >
 422a431,434
 >       if (old_progname) {
 >               extern char *__progname;
 >               __progname = old_progname;
 >       }
 
Responsible-Changed-From-To: freebsd-bugs->yar 
Responsible-Changed-By: dwmalone 
Responsible-Changed-When: Wed Dec 8 13:42:32 GMT 2004 
Responsible-Changed-Why:  
Yar will probably be interested in ftpd patches. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74823 

From: Yar Tikhiy <yar@comp.chem.msu.su>
To: freebsd-gnats-submit@FreeBSD.org, melkov@comptek.ru
Cc:  
Subject: Re: bin/74823: ftpd should not use warn(x) more carefully when used from inetd [patch]
Date: Fri, 10 Dec 2004 19:22:58 +0300

 By the way, there is a more clean and standard-compliant way to
 disable messages from getopt(3)--by setting opterr to 0.
 Please refer to the manpage for details.
 
 -- 
 Yar
State-Changed-From-To: open->patched 
State-Changed-By: yar 
State-Changed-When: Sun Dec 12 17:33:45 GMT 2004 
State-Changed-Why:  
Fixed in CURRENT using a different approach.  Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=74823 
State-Changed-From-To: patched->closed 
State-Changed-By: yar 
State-Changed-When: Tue Dec 21 12:56:35 GMT 2004 
State-Changed-Why:  
Fixed in RELENG_5 and RELENG_4, too.  Thanks! 

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