From sem@FreeBSD.org  Wed Jan 18 21:37:34 2006
Return-Path: <sem@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CD06616A41F
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Jan 2006 21:37:34 +0000 (GMT)
	(envelope-from sem@FreeBSD.org)
Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 79BDC43D53
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Jan 2006 21:37:34 +0000 (GMT)
	(envelope-from sem@FreeBSD.org)
Received: from freefall.freebsd.org (sem@localhost [127.0.0.1])
	by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id k0ILbYdN028182
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Jan 2006 21:37:34 GMT
	(envelope-from sem@freefall.freebsd.org)
Received: (from sem@localhost)
	by freefall.freebsd.org (8.13.4/8.13.4/Submit) id k0ILbYdm028181;
	Wed, 18 Jan 2006 21:37:34 GMT
	(envelope-from sem)
Message-Id: <200601182137.k0ILbYdm028181@freefall.freebsd.org>
Date: Wed, 18 Jan 2006 21:37:34 GMT
From: Sergey Matveychuk <sem@freebsd.org>
Reply-To: Sergey Matveychuk <sem@freebsd.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: libfetch: relax fetch(1) reaction on a MODE command absence
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         91973
>Category:       bin
>Synopsis:       [libfetch] [patch] relax fetch(1) reaction on a MODE command absence
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 18 21:40:02 GMT 2006
>Closed-Date:    Fri Nov 10 23:44:42 GMT 2006
>Last-Modified:  Fri Nov 10 23:44:42 GMT 2006
>Originator:     Sergey Matveychuk
>Release:        FreeBSD 6.0-STABLE i386
>Organization:
>Environment:
System: FreeBSD freefall.freebsd.org 6.0-STABLE FreeBSD 6.0-STABLE #0: Sat Dec 10 03:18:20 UTC 2005 kensmith@freefall.freebsd.org:/usr/obj/usr/src/sys/FREEFALL i386


	
>Description:
	
I've found a problem with a new CWD implementation. The problem is with
the URL: ftp://ftp.ac-grenoble.fr/ge/geosciences/xrmap/xrmap-2.33.tar.bz2.
It's fetchable on <=6.0 and is not on -CURRENT.

As I can see the site returns 500 code for MODE S command. An old
libfetch implementation does not use the command so there was no
problem. But a new `Change directory one level at a time' implementation
send the command before a file transmitting and exits when fails.

Well, looks like STD0009 requires a minimal implementation of ftp site
must have a MODE command. But as I can see our ftp(1) treats an absence
of the command as `only stream mode support'.

I think we could be not so strict to the MODE command?
Don't exit, just put a warning.
>How-To-Repeat:
	
>Fix:

	

--- ftp.c.diff begins here ---
--- lib/libfetch/ftp.c.orig	Wed Jan 18 21:05:22 2006
+++ lib/libfetch/ftp.c	Wed Jan 18 23:21:50 2006
@@ -366,10 +366,8 @@
 
 	filename = _ftp_filename(file, &filenamelen, &type);
 
-	if ((e = _ftp_mode_type(conn, 0, type)) != FTP_OK) {
-		_ftp_seterr(e);
-		return (-1);
-	}
+	if ((e = _ftp_mode_type(conn, 0, type)) != FTP_OK)
+		warnx("The site does not support a MODE command");
 
 	e = _ftp_cmd(conn, "SIZE %.*s", filenamelen, filename);
 	if (e != FTP_FILE_STATUS) {
@@ -601,7 +599,7 @@
 
 	/* set transfer mode and data type */
 	if ((e = _ftp_mode_type(conn, 0, type)) != FTP_OK)
-		goto ouch;
+		warnx("The site does not support a MODE command");
 
 	/* find our own address, bind, and listen */
 	l = sizeof(sa);
--- ftp.c.diff ends here ---


>Release-Note:
>Audit-Trail:

From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=)
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: Re: bin/91973
Date: Thu, 19 Jan 2006 09:19:47 +0100

 The patch in the PR is incorrect.  A MODE failure should not be
 ignored, as it may result in the wrong data being transferred; and it
 is bad form to use warn() or warnx() in a library.
 
 However, as a compromise, it may be acceptable to ignore a MODE
 failure if and only if the mode we tried to set was "s".
 
 DES
 --=20
 Dag-Erling Sm=F8rgrav - des@des.no
 
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: des 
Responsible-Changed-When: Thu Jan 19 08:32:52 UTC 2006 
Responsible-Changed-Why:  
libfetch is mine. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=91973 
State-Changed-From-To: open->patched 
State-Changed-By: des 
State-Changed-When: Thu Jan 19 08:33:10 UTC 2006 
State-Changed-Why:  
patch committed, please test. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=91973 
State-Changed-From-To: patched->closed 
State-Changed-By: des 
State-Changed-When: Fri Nov 10 23:44:40 UTC 2006 
State-Changed-Why:  
MFCed on 2006-07-22 

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