From Dom.Mitchell@palmerharvey.co.uk Mon Jun  7 06:29:24 1999
Return-Path: <Dom.Mitchell@palmerharvey.co.uk>
Received: from mail.palmerharvey.co.uk (mail.palmerharvey.co.uk [62.172.109.58])
	by hub.freebsd.org (Postfix) with ESMTP
	id D04EF14BD7; Mon,  7 Jun 1999 06:29:11 -0700 (PDT)
	(envelope-from Dom.Mitchell@palmerharvey.co.uk)
Received: from ho-nt-01.pandhm.co.uk (unverified) by mail.palmerharvey.co.uk
 (Content Technologies SMTPRS 2.0.15) with ESMTP id <B0000042598@mail.palmerharvey.co.uk>;
 Mon, 07 Jun 1999 14:28:26 +0100
Received: from voodoo.pandhm.co.uk (VOODOO [10.100.35.12]) by ho-nt-01.pandhm.co.uk with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2448.0)
	id MKM83JVB; Mon, 7 Jun 1999 14:20:35 +0100
Received: from dom by voodoo.pandhm.co.uk with local (Exim 2.10 #1)
	id 10qzX6-000B4p-00; Mon, 7 Jun 1999 14:33:44 +0100
Message-Id: <E10qzX6-000B4p-00@voodoo.pandhm.co.uk>
Date: Mon, 7 Jun 1999 14:33:44 +0100
From: Dom Mitchell <Dom.Mitchell@palmerharvey.co.uk>
Reply-To: Dom.Mitchell@palmerharvey.co.uk
To: FreeBSD-gnats-submit@freebsd.org
Cc: pst@FreeBSD.org, lukem@netbsd.org
Subject: FTP_PASSIVE_MODE exposes bug in ftp(1).
X-Send-Pr-Version: 3.2

>Number:         12070
>Category:       bin
>Synopsis:       FTP_PASSIVE_MODE exposes bug in ftp(1).
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Jun  7 06:30:01 PDT 1999
>Closed-Date:    Thu Jul 1 06:21:04 PDT 1999
>Last-Modified:  Thu Jul  1 06:24:13 PDT 1999
>Originator:     Dominic Mitchell
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
Palmer & Harvey McLane Ltd.
>Environment:

FreeBSD voodoo.pandhm.co.uk 4.0-CURRENT FreeBSD 4.0-CURRENT #15: Thu Jun  3 08:51:09 BST 1999     root@voodoo.pandhm.co.uk:/usr/src/sys/compile/VOODOO  i386

>Description:

Since we have enabled FTP_PASSIVE_MODE in /etc/login.conf, my gate-ftp
no longer works properly.  It starts in non-gate mode even when called
as gate-ftp.

I've CC'd pst@freebsd.org as the last person to check in a change to
ftp(1), and also lukem@netbsd.org as the original author.

>How-To-Repeat:

You can demonstrate the problem fairly easily:

% env FTPSERVER=ftp-gw gate-ftp
ftp> status
Not connected.
No proxy connection.
Gate ftp: off, server ftp-gw, port 21.
          ^^^
Passive mode: on.
Mode: ; Type: ; Form: ; Structure: .
Verbose: on; Bell: off; Prompting: on; Globbing: on.
Store unique: off; Receive unique: off.
Preserve modification times: on.
Case: off; CR stripping: on.
Ntrans: off.
Nmap: off.
Hash mark printing: off; Mark count: 1024; Progress bar: on.
Use of PORT cmds: on.
Command line editing: on.

>Fix:
	
Apply this patch in /usr/src/usr.bin/ftp:

--- main.c.orig	Mon Jun  7 14:20:36 1999
+++ main.c	Mon Jun  7 14:21:19 1999
@@ -131,7 +131,9 @@
 
 	cp = strrchr(argv[0], '/');
 	cp = (cp == NULL) ? argv[0] : cp + 1;
-	if (getenv("FTP_PASSIVE_MODE") || strcmp(cp, "pftp") == 0)
+	if (getenv("FTP_PASSIVE_MODE"))
+		passivemode = 1;
+	if (strcmp(cp, "pftp") == 0)
 		passivemode = 1;
 	else if (strcmp(cp, "gate-ftp") == 0)
 		gatemode = 1;
-- 
**********************************************************************
This email and any files transmitted with it are confidential and 
intended solely for the use of the individual or entity to whom they   
are addressed. If you have received this email in error please notify 
the system manager.

This footnote also confirms that this email message has been swept by 
MIMEsweeper for the presence of computer viruses.
**********************************************************************

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: des 
State-Changed-When: Mon Jun 7 09:37:08 PDT 1999 
State-Changed-Why:  
Fixed in -current. 


Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Mon Jun 7 09:37:08 PDT 1999 
Responsible-Changed-Why:  
So I remember to MFC. 
State-Changed-From-To: feedback->closed 
State-Changed-By: ru 
State-Changed-When: Thu Jul 1 06:21:04 PDT 1999 
State-Changed-Why:  
Fixed in -stable as well. 
>Unformatted:
