about summary refs log tree commit
diff options
context:
space:
mode:
authorGraham Barr <gbarr@pobox.com>1997-11-30 17:33:38 +0000
committerGraham Barr <gbarr@pobox.com>1997-11-30 17:33:38 +0000
commit9d75234483b2b04f80fc0e3ea67d4189236136f1 (patch)
tree1469738f80e1f0e62ddc6da2406a0981310a7aa0
parent9d833c91a7a480fc63e354ff9e99a304b57827b9 (diff)
downloadperl-libnet-9d75234483b2b04f80fc0e3ea67d4189236136f1.tar.gz
Net::FTP
- Fix to login() and authorize() for OS/2 which does not
  support getpw*()

-rw-r--r--Net/FTP.pm37
1 files changed, 12 insertions, 25 deletions
diff --git a/Net/FTP.pm b/Net/FTP.pm
index de402cb..b59c17c 100644
--- a/Net/FTP.pm
+++ b/Net/FTP.pm
@@ -21,7 +21,7 @@ use Net::Cmd;
 use Net::Config;
 use AutoLoader qw(AUTOLOAD);
 
-$VERSION = "2.28"; # $Id: //depot/libnet/Net/FTP.pm#12 $
+$VERSION = "2.29"; # $Id: //depot/libnet/Net/FTP.pm#13 $
 @ISA     = qw(Exporter Net::Cmd IO::Socket::INET);
 
 # Someday I will "use constant", when I am not bothered to much about
@@ -30,6 +30,12 @@ $VERSION = "2.28"; # $Id: //depot/libnet/Net/FTP.pm#12 $
 use vars qw($TELNET_IAC $TELNET_IP $TELNET_DM);
 ($TELNET_IAC,$TELNET_IP,$TELNET_DM) = (255,244,242);
 
+# Name is too long for AutoLoad, it clashes with pasv_xfer
+sub pasv_xfer_unique {
+    my($sftp,$sfile,$dftp,$dfile) = @_;
+    $sftp->pasv_xfer($sfile,$dftp,$dfile,1);
+}
+
 1;
 
 __END__
@@ -198,7 +204,7 @@ sub login
      ($ruser,$pass,$acct) = $rc->lpa()
         if ($rc);
 
-     $pass = "-" . (getpwuid($>))[0] . "@"
+     $pass = eval { "-" . (getpwuid($>))[0] . "@" }
         if (!defined $pass && (!defined($ruser) || $ruser =~ /^anonymous/o));
     }
 
@@ -232,7 +238,7 @@ sub authorize
   {
    require Net::Netrc;
 
-   $auth ||= (getpwuid($>))[0];
+   $auth ||= eval { (getpwuid($>))[0] };
 
    my $rc = Net::Netrc->lookup(${*$ftp}{'net_ftp_firewall'}, $auth)
         || Net::Netrc->lookup(${*$ftp}{'net_ftp_firewall'});
@@ -803,27 +809,7 @@ sub parse_response
 
 sub pasv_xfer
 {
- my($sftp,$sfile,$dftp,$dfile) = @_;
-
- ($dfile = $sfile) =~ s#.*/##
-    unless(defined $dfile);
-
- my $port = $sftp->pasv or
-    return undef;
-
- unless($dftp->port($port) && $sftp->retr($sfile) && $dftp->stor($dfile))
-  {
-   $sftp->abort;
-   $dftp->abort;
-   return undef;
-  }
-
- $dftp->pasv_wait($sftp);
-}
-
-sub pasv_xfer_unique
-{
- my($sftp,$sfile,$dftp,$dfile) = @_;
+ my($sftp,$sfile,$dftp,$dfile,$unique) = @_;
 
  ($dfile = $sfile) =~ s#.*/##
     unless(defined $dfile);
@@ -831,7 +817,8 @@ sub pasv_xfer_unique
  my $port = $sftp->pasv or
     return undef;
 
- unless($dftp->port($port) && $sftp->retr($sfile) && $dftp->stou($dfile))
+ unless($dftp->port($port) && $sftp->retr($sfile) &&
+        ($unique ? $dftp->stou($dfile) : $dftp->stor($dfile)))
   {
    $sftp->abort;
    $dftp->abort;