Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jun 1997 14:36:04 -0700 (PDT)
From:      Ernest Hua <hua@chromatic.com>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   ports/3955: BUG REPORT + FIX: Mirror 2.8 passive mode does not work
Message-ID:  <199706252136.OAA07491@ohio.chromatic.com>
Resent-Message-ID: <199706252140.OAA15867@hub.freebsd.org>

next in thread | raw e-mail | index | archive | help

>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:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706252136.OAA07491>