Skip Menu |

This queue is for tickets about the Net-FTPSSL CPAN distribution.

Report information
The Basics
Id: 74547
Status: resolved
Priority: 0/
Queue: Net-FTPSSL

People
Owner: Nobody in particular
Requestors: stefanos [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: 0.21



Hi Stefanos, FTP PRET is an interesting concept from a quick glance at the links you provided. It just looks like an automated PRET command before my code issues any PASV commands. So I don't see why I couldn't add support for it. Do you have such a server I could test against? It would make fully testing my code much easier. If you do, you don't have to post this information to this ticket, send the info directly to me at cleach@cpan.org. This way your server info isn't made public. If you can't provide me access to such a server, then things are going to be a bit more difficult to implement. I'll need some logs from you to help me get started. And you'll have to volunteer to be a beta tester for the next release and return the necessary log files. Add the following options to your call to new() and send me the logs. Be sure your test program does a nlst and a get so that I can see what type of errors the server is currently throwing. Net::FTPSSL->new(server, PreserveTimestamp=>1, Debug=>1,DebugLogFile=>"myLog.txt") What I'm trying to determine is if there is a way for me to dynamically detect this type of server or if it must be added as another option to new(). Curtis On Tue Jan 31 01:26:33 2012, STEFANOS wrote: Show quoted text
It is simple: http://www.drftpd.org/index.php/Pftp_pret_patch See my patch for add ftp pret support but without support for pret stor.
Subject: FTPSSL.pm

Message body is not shown because it is too large.

Subject: myLog.txt
Net-FTPSSL Version: 0.20 Perl: 5.010001 [5.10.1], OS: MSWin32 Server (port): localhost (33333) Keys: (Debug), (Encryption), (PreserveTimestamp), (Pret), (Port), (DebugLogFile) Values: (1), (E), (1), (1), (33333), (myLog.txt) SKT <<< 220 OFFLiNE SKT >>> AUTH TLS SKT <<< 234 AUTH TLS successful >>> USER +++++++ <<< 331 Password required for <++++++>. >>> PASS ******* <<< 2 <<< 30- <<< 230- Welcome to the future of FXP:ing <<< 230- ___ _____________ ___ <<< 230- / _ \____/ __/_ __/ _ \/ _ \ <<< 230- / // / __/ _/ / / / ___/ // / <<< 230- /____/_/ /_/ /_/ /_/ /____/ <<< 230- DistRibuted FTP Daemon <<< 230- http://drftpd.org <<< 230 <++++++> logged in successfully. >>> HELP <<< 5 <<< 00 No command handler for HELP <<+ 502 Unknown command MFMT. <<+ 502 Unknown command MDTM. >>> CWD /XVID/ <<< 250 Directory changed to /XVID/ >>> PBSZ 0 <<< 2 <<< 00 Command okay >>> PROT P <<< 2 <<< 00 Command okay >>> PASV <<< 5 <<< 00 You need to use a client supporting PRET (PRE Transfer) to use PASV --- Host () Port () >>> LIST /XVID/ <<< 5 <<< 03 Bad sequence of commands.
Subject: FTPSSL.diff
--- /usr/local/share/perl/5.12.4/Net/FTPSSL.pm 2012-01-01 18:48:03.000000000 +0100 +++ /root/FTPSSL.pm 2012-02-03 10:14:10.000000000 +0100 @@ -105,6 +105,7 @@ my $use_ssl = $arg->{useSSL} || 0; my $die = $arg->{Croak} || $arg->{Die}; my $pres_ts = $arg->{PreserveTimestamp} || 0; + my $pret = $arg->{Pret} || 0; my $use_logfile = $debug && (defined $arg->{DebugLogFile} && $arg->{DebugLogFile} ne ""); my $localaddr = $ssl_args{LocalAddr} || $arg->{LocalAddr}; @@ -273,6 +274,7 @@ ${*$obj}{buf_size} = $buf_size; ${*$obj}{type} = MODE_ASCII; ${*$obj}{data_prot} = $data_prot; + ${*$obj}{pret} = $pret; ${*$obj}{Croak} = $die; ${*$obj}{FixPutTs} = ${*$obj}{FixGetTs} = $pres_ts; ${*$obj}{OverridePASV} = $pasvHost; @@ -370,9 +372,15 @@ sub _pasv { my $self = shift; - unless ( $self->command ("PASV")->response () == CMD_OK ) { - return $self->_croak_or_return (); + if ( ${*$self}{pret} ) { + unless ( $self->command ("PRET LIST")->response () == CMD_OK ) { + return $self->_croak_or_return (); + } } + unless ( $self->command ("PASV")->response () == CMD_OK ) { + return $self->_croak_or_return (); + } + # [227] [Entering Passive Mode] ([h1,h2,h3,h4,p1,p2]). my $msg = $self->last_message (); @@ -490,7 +498,6 @@ if ( ${*$self}{data_prot} eq DATA_PROT_PRIVATE && exists (${*$self}{myContext}) ) { my %ssl_opts = %{${*$self}{myContext}}; my $mode = $ssl_opts{SSL_version}; - $io = IO::Socket::SSL->start_SSL ( ${*$self}{data_ch}, \%ssl_opts ) or return _croak_or_return ( $io, undef, "$mode: " . IO::Socket::SSL::errstr () ); @@ -843,12 +850,17 @@ return undef; # Already decided not to call croak if you get here! } + if ( ${*$self}{pret} ) { + $self->_pret_retr($file_rem); + $self->_pret_pasv($file_rem); + } + + # "(caller(1))[3]" returns undef if not called by another Net::FTPSSL method! my $c = (caller(1))[3]; my $cb_idx = ( defined $c && $c eq "Net::FTPSSL::xget" ) ? 2 : 1; my $func = ( $cb_idx == 1 ) ? "get" : "xget"; - # Check if the "get" failed ... my $rest = ($offset) ? $self->_rest ($offset) : 1; unless ( $rest && $self->_retr($file_rem) ) { @@ -1685,6 +1697,33 @@ return ( $self->command ( "RETR", @_ )->response () == CMD_INFO ); } +sub _pret_retr { + my $self = shift; + return ( $self->command ( "PRET RETR", @_ )->response () == CMD_INFO ); +} + +sub _pret_pasv { + my $self = shift; + + unless ( $self->command ("PASV")->response () == CMD_OK ) { + return $self->_croak_or_return (); + } + + my $msg = $self->last_message (); + unless ($msg =~ m/(\d+)\s(.*)\(((\d+,?)+)\)\.?/) { + return $self->_croak_or_return (0, "Can't parse the PASV response."); + } + + my @address = split( /,/, $3 ); + + my $host = join( '.', @address[ 0 .. 3 ] ); + my $port = $address[4] * 256 + $address[5]; + + $self->_print_DBG ("--- Host ($host) Port ($port) - PRET PASV\n"); + + return ( $self->_open_data_channel ($host, $port) ); +} + sub _stor { my $self = shift; return ( $self->command ( "STOR", @_ )->response () == CMD_INFO );
Stefan, Can you please run another test for me? I've been working on your patch to Net::FTPSSL, but I need to know a bit more about the behavior of your server to fully implement it before I provide you a beta to test out. $ftp = Net::FTPSSL->new(server, PreserveTimestamp=>1, Debug=>1,DebugLogFile=>"myLog.txt"); $ftp->login ($usr, $pwd); $ftp->force_epsv(); $ftp->list(); The links you gave me were a bit vague on what to do in EPSV mode and I'd just like to see what your server does with it. I'm tempted to just do the PRET for EPSV as well, but from the logs you sent last time your server's response should tell me if that's the correct approach to take or not. Curtis On Fri Feb 03 04:24:44 2012, STEFANOS wrote: Show quoted text
> It is simple: http://www.drftpd.org/index.php/Pftp_pret_patch > > See my patch for add ftp pret support but without support for pret stor.
with force_epsv: 500 No command handler for EPSV
Subject: myLog.txt
Net-FTPSSL Version: 0.20 Perl: 5.010001 [5.10.1], OS: MSWin32 Server (port): localhost (33333) Keys: (Debug), (PreserveTimestamp), (Port), (DebugLogFile) Values: (1), (1), (33333), (myLog.txt) SKT <<< 220 OFFLiNE SKT >>> AUTH TLS SKT <<< 234 AUTH TLS successful >>> USER +++++++ <<< 331 Password required for <++++++>. >>> PASS ******* <<< 2 <<< 30- <<< 230- Welcome to the future of FXP:ing <<< 230- ___ _____________ ___ <<< 230- / _ \____/ __/_ __/ _ \/ _ \ <<< 230- / // / __/ _/ / / / ___/ // / <<< 230- /____/_/ /_/ /_/ /_/ /____/ <<< 230- DistRibuted FTP Daemon <<< 230- http://drftpd.org <<< 230 <++++++> logged in successfully. >>> HELP <<< 5 <<< 00 No command handler for HELP <<+ 502 Unknown command MFMT. <<+ 502 Unknown command MDTM. >>> EPSV ALL <<< 5 <<< 00 No command handler for EPSV >>> PBSZ 0 <<< 2 <<< 00 Command okay >>> PROT P <<< 2 <<< 00 Command okay >>> PASV <<< 5 <<< 00 You need to use a client supporting PRET (PRE Transfer) to use PASV --- Host () Port () >>> LIST <<< 5 <<< 03 Bad sequence of commands.
Hi Stefan, Thanks for letting me know what happens with EPSV, I see now why it doesn't work with distributed systems. But it was nice to have it confirmed in the logs you provided. I have a beta for you to try out. Can you please give it a whirl and return the log files to me? I think I have all the various combinations covered in my beta now. You can turn the feature on by adding "Pret => 1" to your list of options in new(). Curtis On Tue Feb 07 19:54:03 2012, STEFANOS wrote: Show quoted text
> with force_epsv: 500 No command handler for EPSV
Subject: FTPSSL.pm

Message body is not shown because it is too large.

The test is good. See the log with login+cwd+get
Subject: zmynewlog.txt
Net-FTPSSL Version: 0.20 Perl: 5.010001 [5.10.1], OS: MSWin32 Server (port): localhost (33333) Keys: (Debug), (PreserveTimestamp), (Pret), (Port), (DebugLogFile) Values: (1), (1), (1), (33333), (zmynewlog.txt) SKT <<< 220 OFFLiNE SKT >>> AUTH TLS SKT <<< 234 AUTH TLS successful >>> USER +++++++ <<< 331 Password required for <++++++>. >>> PASS ******* <<< 2 <<< 30- <<< 230- Welcome to the future of FXP:ing <<< 230- ___ _____________ ___ <<< 230- / _ \____/ __/_ __/ _ \/ _ \ <<< 230- / // / __/ _/ / / / ___/ // / <<< 230- /____/_/ /_/ /_/ /_/ /____/ <<< 230- DistRibuted FTP Daemon <<< 230- http://drftpd.org <<< 230 <++++++> logged in successfully. >>> HELP <<< 5 <<< 00 No command handler for HELP <<+ 502 Unknown command MFMT. <<+ 502 Unknown command MDTM. >>> CWD /XVID/testdir/ <<< 250 Directory changed to /XVID/testdir >>> PBSZ 0 <<< 2 <<< 00 Command okay >>> PROT P <<< 2 <<< 00 Command okay >>> PRET LIST <<< 2 <<< 00 OK, will use master for upcoming transfer >>> PASV <<< 2 <<< 27 Entering Passive Mode (87,98,244,108,236,253). --- Host (87.98.244.108) Port (60669) >>> PRET RETR test.rar <<< 2 <<< 00 OK, will use OFF-03 for upcoming transfer >>> PASV <<< 2 <<< 27 Entering Passive Mode (108,33,36,81,207,103). --- Host (108.33.36.81) Port (53095) - PRET PASV >>> RETR test.rar <<< 1 <<< 50 File status okay; about to open data connection from OFF-03. <<< 2 <<< 26- Checksum from transfer: eca9f99c <<< 226- checksum from transfer matched checksum in .sfv <<< 226 Transfer complete, 20.0MB in 3.502 seconds (5.7MB/s)
Stefan, Thanks for testing out my beta. I'm glad it's working for you. I'm finishing up with some other changes that will also go in v0.21 and once I'm done with them I'll make an official release with these changes. Curtis On Tue Feb 14 16:56:48 2012, STEFANOS wrote: Show quoted text
> The test is good. See the log with login+cwd+get
Hi Stefan, I just uploaded the official v0.21 release of Net::FTPSSL to CPAN. It should be available for download in a few hours. Please let me know if you have any issues with it. Thanks again for your help in testing out the beta. Curtis On Wed Feb 15 20:11:16 2012, CLEACH wrote: Show quoted text
> Stefan, > > Thanks for testing out my beta. I'm glad it's working for you. > > I'm finishing up with some other changes that will also go in v0.21 and > once I'm done with them I'll make an official release with these changes. > > Curtis > > > On Tue Feb 14 16:56:48 2012, STEFANOS wrote:
> > The test is good. See the log with login+cwd+get
>
Version 0.21 is good. Thanks!