From owner-freebsd-ports Wed Jun 25 14:40:05 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id OAA15895 for ports-outgoing; Wed, 25 Jun 1997 14:40:05 -0700 (PDT) Received: (from gnats@localhost) by hub.freebsd.org (8.8.5/8.8.5) id OAA15867; Wed, 25 Jun 1997 14:40:02 -0700 (PDT) Resent-Date: Wed, 25 Jun 1997 14:40:02 -0700 (PDT) Resent-Message-Id: <199706252140.OAA15867@hub.freebsd.org> Resent-From: gnats (GNATS Management) Resent-To: freebsd-ports Resent-Reply-To: FreeBSD-gnats@FreeBSD.ORG, hua@chromatic.com Received: from chromatic.com ([204.182.30.9]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id OAA15707 for ; Wed, 25 Jun 1997 14:36:34 -0700 (PDT) Received: from ohio.chromatic.com (ohio [172.16.82.5]) by chromatic.com (8.8.5/8.8.5) with ESMTP id OAA05088 for ; Wed, 25 Jun 1997 14:34:46 -0700 (PDT) Received: (from hua@localhost) by ohio.chromatic.com (8.8.5/8.8.5) id OAA07491; Wed, 25 Jun 1997 14:36:04 -0700 (PDT) Message-Id: <199706252136.OAA07491@ohio.chromatic.com> Date: Wed, 25 Jun 1997 14:36:04 -0700 (PDT) From: Ernest Hua Reply-To: hua@chromatic.com To: FreeBSD-gnats-submit@FreeBSD.ORG X-Send-Pr-Version: 3.2 Subject: ports/3955: BUG REPORT + FIX: Mirror 2.8 passive mode does not work Sender: owner-ports@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk >Number: 3955 >Category: ports >Synopsis: -kpassive_ftp=true fails on socket connection >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports >State: open >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Jun 25 14:40:01 PDT 1997 >Last-Modified: >Originator: Ernest Hua >Organization: Chromatic Research >Release: FreeBSD 2.2.2-RELEASE i386 >Environment: FreeBSD 2.2.2-RELEASE on generic P133 PC clone. >Description: The socket connection when attempting to transition over to passive mode ftp fails to connect. >How-To-Repeat: Set passive_ftp to true. >Fix: This is a patch of mirror-2.8 in /usr/local/lib/mirror. The bottom line is that the original code used $var instead of var where a file handle was necessary, and it presumed a particular textual annotation where no one particular annotation was required in the protocol. diff -bwrc mirror/ftp.pl mirror.dist/ftp.pl *** mirror/ftp.pl Tue Jun 24 17:00:20 1997 --- mirror.dist/ftp.pl Sun May 18 00:07:38 1997 *************** *** 430,436 **** return 0; } if( $ret == 1 ) { ! $response =~ m/^227 .* \((\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\)$/; $newhost = sprintf( "%d.%d.%d.%d", $1, $2, $3, $4 ); $newport = $5 * 256 + $6; } --- 430,436 ---- return 0; } if( $ret == 1 ) { ! $response =~ m/^227 Entering Passive Mode \((\d+),(\d+),(\d+),(\d+),(\d+),(\d+)\)$/; $newhost = sprintf( "%d.%d.%d.%d", $1, $2, $3, $4 ); $newport = $5 * 256 + $6; } diff -bwrc mirror/lchat.pl mirror.dist/lchat.pl *** mirror/lchat.pl Tue Jun 24 17:21:27 1997 --- mirror.dist/lchat.pl Sun May 18 00:07:38 1997 *************** *** 123,129 **** # Similar to open_port, but does less. Used for PASV code with ftp.pl # -Erez Zadok. sub open_newport { ## public ! local($server, $port, *newsock) = @_; local($serveraddr,$serverproc); --- 123,129 ---- # Similar to open_port, but does less. Used for PASV code with ftp.pl # -Erez Zadok. sub open_newport { ## public ! local($server, $port, $newsock) = @_; local($serveraddr,$serverproc); *************** *** 142,159 **** } $serverproc = pack($sockaddr, 2, $port, $serveraddr); ! unless (connect(newsock, $serverproc)) { ! ($!) = ($!, close(newsock)); # close newsock while saving $! return undef; } # We opened with the local address set to ANY, at this stage we know # which interface we are using. This is critical if our machine is # multi-homed, with IP forwarding off, so fix-up. local($fam,$lport); ! ($fam,$lport,$thisaddr) = unpack($sockaddr, getsockname(newsock)); $thisproc = pack($sockaddr, 2, 0, $thisaddr); # end of post-connect fixup ! select((select(newsock), $| = 1)[0]); return 1; } ############################################################################## --- 142,159 ---- } $serverproc = pack($sockaddr, 2, $port, $serveraddr); ! unless (connect($newsock, $serverproc)) { ! ($!) = ($!, close($newsock)); # close newsock while saving $! return undef; } # We opened with the local address set to ANY, at this stage we know # which interface we are using. This is critical if our machine is # multi-homed, with IP forwarding off, so fix-up. local($fam,$lport); ! ($fam,$lport,$thisaddr) = unpack($sockaddr, getsockname($newsock)); $thisproc = pack($sockaddr, 2, 0, $thisaddr); # end of post-connect fixup ! select((select($newsock), $| = 1)[0]); return 1; } ############################################################################## >Audit-Trail: >Unformatted: