From admin@citylink.dinoex.sub.org  Wed May  4 17:02:13 2005
Return-Path: <admin@citylink.dinoex.sub.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 52AA316A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  4 May 2005 17:02:13 +0000 (GMT)
Received: from uucp.dinoex.sub.de (uucp.dinoex.sub.de [194.45.71.2])
	by mx1.FreeBSD.org (Postfix) with ESMTP id B783343D6D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  4 May 2005 17:02:11 +0000 (GMT)
	(envelope-from admin@citylink.dinoex.sub.org)
Received: from uucp.dinoex.sub.de (uucp@uucp.dinoex.sub.de [194.45.71.2] (may be forged))
	by uucp.dinoex.sub.de (8.13.3/8.13.3) with ESMTP id j44H0gYq028814
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 4 May 2005 19:00:42 +0200 (CEST)
	(envelope-from admin@citylink.dinoex.sub.org)
Received: from citylink.dinoex.sub.org (uucp@localhost)
	by uucp.dinoex.sub.de (8.13.3/8.13.3/Submit) with UUCP id j44H0gTd028813
	for FreeBSD-gnats-submit@freebsd.org; Wed, 4 May 2005 19:00:42 +0200 (CEST)
	(envelope-from admin@citylink.dinoex.sub.org)
Received: from gate.oper.dinoex.org (gate-e [192.168.98.2])
	by citylink.dinoex.sub.de (8.13.1/8.13.1) with ESMTP id j44GdLuU003394
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 4 May 2005 18:39:21 +0200 (CEST)
	(envelope-from admin@edge.oper.dinoex.org)
Received: from edge.oper.dinoex.org (gate-e [192.168.98.2])
	by gate.oper.dinoex.org (8.13.1/8.13.1) with ESMTP id j44GdE7U003391
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 4 May 2005 18:39:14 +0200 (CEST)
	(envelope-from admin@edge.oper.dinoex.org)
Received: from edge.oper.dinoex.org (edge-e.oper.dinoex.org [192.168.98.6])
	by edge.oper.dinoex.org (8.13.1/8.13.1) with ESMTP id j44GbASF003259
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 4 May 2005 18:37:11 +0200 (CEST)
	(envelope-from admin@edge.oper.dinoex.org)
Received: (from admin@localhost)
	by edge.oper.dinoex.org (8.13.1/8.13.1/Submit) id j44GbAGm003258;
	Wed, 4 May 2005 18:37:10 +0200 (CEST)
	(envelope-from admin)
Message-Id: <200505041637.j44GbAGm003258@edge.oper.dinoex.org>
Date: Wed, 4 May 2005 18:37:10 +0200 (CEST)
From: Peter Much <pmc@citylink.dinoex.sub.org>
Reply-To: Peter Much <pmc@citylink.dinoex.sub.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: fetch -U does not work
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         80620
>Category:       bin
>Synopsis:       [patch] fetch -U does not work
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    des
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed May 04 17:10:02 GMT 2005
>Closed-Date:    Fri May 13 06:52:03 UTC 2011
>Last-Modified:  Fri May 13 06:52:03 UTC 2011
>Originator:     Peter Much
>Release:        FreeBSD 5.3-RELEASE-p5 i386
>Organization:
n/a
>Environment:
System: FreeBSD edge.oper.dinoex.org 5.3-RELEASE-p5 FreeBSD 5.3-RELEASE-p5 #5: Sun Feb 6 23:26:49 CET 2005 root@edge.oper.dinoex.org:/usr/src/sys/i386/compile/E1R53V1 i386


>Description:

The -U option to fetch command does not have the effect as
described in the fetch manpage (using a low port in passive mode ftp).
Actually it has no effect at all.

  (Background: This feature allows to workarund IP-providers that use
  "port priority" to slow down filesharing programs, so that connections
  using an unpriviledged port on each end get a very low throughput.
  But this slows not only filesharing, but also other services, like
  ftp in passive mode. But since the client can freely choose the local 
  port for connecting to the provided server port for the data
  connection, this one can be made a low, priviledged port.)

Tracking the flaw leads to lib/libfetch/ftp.c:_ftp_transfer(). Here the
option arrives as flag 'l', and this is not even used in passive
mode. It does something when *NOT* using passive mode, but I'm not
sure what could be the intended use of that.

Actually it looks like the implementation has simply been forgotten.



>How-To-Repeat:

disp53# echo $FTP_PASSIVE_MODE
yes
disp53# sysctl -a | grep  net.inet.ip.portrange.low
net.inet.ip.portrange.lowfirst: 1023
net.inet.ip.portrange.lowlast: 600
disp53# fetch -U ftp://ftp3.de.freebsd.org/pub/FreeBSD/ports/distfiles/openoffice1.1/OOo_1.1.2_source.tar.gz &
[1] 94876
disp53# netstat -afinet
Active Internet connections (including servers)
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4       0      0  192.168.98.7.51777     ftp.plusline.net.30545 ESTABLISHED
tcp4       0      0  192.168.98.7.51976     ftp.plusline.net.ftp   ESTABLISHED



>Fix:

*** lib/libfetch/ftp.c.orig     Fri Aug 29 17:56:52 2003
--- lib/libfetch/ftp.c  Wed May  4 18:17:14 2005
***************
*** 27,33 ****
   */
  
  #include <sys/cdefs.h>
! __FBSDID("$FreeBSD: src/lib/libfetch/ftp.c,v 1.90 2003/08/29 15:56:52 des Exp $");
  
  /*
   * Portions of this code were taken from or based on ftpio.c:
--- 27,33 ----
   */
  
  #include <sys/cdefs.h>
! __FBSDID("$FreeBSD: $");
  
  /*
   * Portions of this code were taken from or based on ftpio.c:
***************
*** 489,495 ****
                u_char addr[64];
                char *ln, *p;
                unsigned int i;
!               int port;
  
                /* send PASV command */
                if (verbose)
--- 489,514 ----
                u_char addr[64];
                char *ln, *p;
                unsigned int i;
!               int arg, port;
! 
!               switch (sa.ss_family) {
!               case AF_INET6:
!                       ((struct sockaddr_in6 *)&sa)->sin6_port = 0;
! #ifdef IPV6_PORTRANGE
!                       arg = low ? IPV6_PORTRANGE_LOW : IPV6_PORTRANGE_DEFAULT;
!                       if (setsockopt(sd, IPPROTO_IPV6, IPV6_PORTRANGE,
!                               (char *)&arg, sizeof(arg)) == -1)
!                               goto sysouch;
! #endif
!                       break;
!               case AF_INET:
!                       ((struct sockaddr_in *)&sa)->sin_port = 0;
!                       arg = low ? IP_PORTRANGE_LOW : IP_PORTRANGE_DEFAULT;
!                       if (setsockopt(sd, IPPROTO_IP, IP_PORTRANGE,
!                               (char *)&arg, sizeof(arg)) == -1)
!                               goto sysouch;
!                       break;
!               }
  
                /* send PASV command */
                if (verbose)



After adding this piece of code, the session looks this way:

disp53# netstat -afinet
Active Internet connections (including servers)
Proto Recv-Q Send-Q  Local Address          Foreign Address        (state)
tcp4       0      0  192.168.98.7.984       ftp.plusline.net.43094 ESTABLISHED
tcp4       0      0  192.168.98.7.52402     ftp.plusline.net.ftp   ESTABLISHED
>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->des 
Responsible-Changed-By: pjd 
Responsible-Changed-When: Sat May 28 21:03:53 GMT 2005 
Responsible-Changed-Why:  
Assign to fetch(1) maintainer. 

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

From: des@des.no (=?iso-8859-1?q?Dag-Erling_Sm=F8rgrav?=)
To: freebsd-gnats-submit@freebsd.org
Cc:  
Subject: bin/80620
Date: Sun, 29 May 2005 20:39:54 +0200

 The code performs as intended; the bug is in the documentation.  I
 don't see much point in the behaviour you propose except completeness;
 the behaviour that is in fact implemented (but not documented) allows
 the port numbers used for incoming data connections (which need to be
 let through the firewall) to be restricted to a small range.
 
 DES
 --=20
 Dag-Erling Sm=F8rgrav - des@des.no
State-Changed-From-To: open->closed 
State-Changed-By: des 
State-Changed-When: Fri May 13 06:52:02 UTC 2011 
State-Changed-Why:  
not a bug 

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