Skip Menu |

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

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

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

Bug Information
Severity: Wishlist
Broken in: 0.21
Fixed in: 0.22



Subject: automatic pret support ?
automatic pret support ? See the example (little hack with goto) but it works.
Subject: ftp.pl
#!/usr/bin/perl use Net::FTPSSL; my $host = 'localhost'; my $port = '33333'; my $user = 'test'; my $pass = 'test'; my $pfad = '/'; my $ftppret1 = 0; FTPPRET1: if(my $ftp = Net::FTPSSL->new($host, Timeout => 10, Pret => $ftppret1, Port => $port, Debug => 0)){ $ftp->login($user,$pass); $ftp->binary(); $ftp->cwd($pfad); my @ftpdataLIST = $ftp->list($pfad); if($ftp->last_message() =~ /You need to use a client supporting PRET/i){ $ftp->abort; $ftp->quit; $ftppret1 = 1; goto FTPPRET1; } # Code $ftp->quit; } exit;
Hi Stefanos, I saw your hack, but of course it's a wrapper to my class instead of modifying my code to implement. The problem with this option to FTPSSL is that I can't tell if you need it until after you log in and actually do something. And that something is completely different with each user. And I bet the error message is different per server as well. Off the top of my head, the solution may be in the _pasv() function. Can you try out this patch for me? (Modify FTPSSL.pm) I don't have a PRET server to test against. But if this patch works, I'll put it into my code base for the next release. Original code in _pasv(). unless ( $self->command ("PASV")->response () == CMD_OK ) { $self->_croak_or_return (); return ($host, $port); } becomes unless ( $self->command ("PASV")->response () == CMD_OK ) { if ($self->last_message() =~ /(^|\s)PRET($|[\s.!?])/i) { ${*$self}{Pret} = 1; # Turns PRET on for all future calls to _pasv(). $self->_print_DBG ("<<+ Auto-adding PRET option!\n"); $self->_pasv( @_); } else { $self->_croak_or_return (); } return ($host, $port); } I didn't put in your more expansive test string to match against since I'm betting the error message is different for different servers. All I'm requiring is that PRET appears as it's own word and not part of another word such as "pretty" and that the call to PASV failed. So in your test, leave off the Pret option entirely and no need for a goto at all. But be sure to add Debug=>1, DebugLogFile => "myLog.txt" so that you get a log file. And then send me the log file generated so I know there are no issues with my patch. Curtis On Wed May 09 02:30:09 2012, STEFANOS wrote: Show quoted text
> automatic pret support ? > > See the example (little hack with goto) but it works.
I think is it not enough? With force pret => 1 works good but auto pret with your code not, see the log.
Subject: myLog.txt
Net-FTPSSL Version: 0.21 Perl: 5.010001 [5.10.1], OS: MSWin32 Server (port): localhost (33333) Keys: (Debug), (Port), (Timeout), (DebugLogFile) Values: (1), (33333), (10), (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. >>> TYPE I <<< 2 <<< 00 Command okay >>> CWD / <<< 2 <<< 50 Directory changed to / >>> 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 <<+ Auto-adding PRET option! >>> PRET LIST <<< 2 <<< 00 OK, will use master for upcoming transfer >>> PASV <<< 2 <<< 27 Entering Passive Mode (87,98,244,138,191,14). --- Host () Port () >>> QUIT <<< 2 <<< 21 Goodbye! Attempted to read past end of response! (421 Connection closing)
Thanks for the log file. I immediately saw the bug in my suggested patch. Can you try it again with the patch below and return the log file again? This should fix the Auto PRET bug. unless ( $self->command ("PASV")->response () == CMD_OK ) { if ($self->last_message() =~ /(^|\s)PRET($|[\s.!?])/i) { ${*$self}{Pret} = 1; # Turns PRET on for all future calls to _pasv() even if it fails! $self->_print_DBG ("<<+ Auto-adding PRET option!\n"); return ($self->_pasv( @_)); } else { $self->_croak_or_return (); return ($host, $port); } } I had forgotten return to the caller what the recursive call to _pasv() returned! Curtis On Thu May 10 00:11:44 2012, STEFANOS wrote: Show quoted text
> I think is it not enough? > > With force pret => 1 works good but auto pret with your code not, see > the log. >
Wonderful! The patch is good, thanks.
Subject: mylog.txt
Net-FTPSSL Version: 0.21 Perl: 5.010001 [5.10.1], OS: MSWin32 Server (port): localhost (33333) Keys: (Debug), (Port), (Timeout), (DebugLogFile) Values: (1), (33333), (10), (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. >>> TYPE I <<< 2 <<< 00 Command okay >>> CWD / <<< 2 <<< 50 Directory changed to / >>> 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 <<+ Auto-adding PRET option! >>> PRET LIST <<< 2 <<< 00 OK, will use master for upcoming transfer >>> PASV <<< 2 <<< 27 Entering Passive Mode (87,98,244,138,236,32). --- Host (87.98.244.138) Port (60448) >>> LIST / <<< 1 <<< 50 File status okay; about to open data connection. <<< 226 Closing data connection >>> QUIT <<< 2 <<< 21 Goodbye! Attempted to read past end of response! (421 Connection closing)