[mirrorbrain-commits] r7944 - /trunk/tools/scanner.pl

From: <poeml_at_mirrorbrain.org>
Date: Tue, 26 Jan 2010 23:46:57 -0000
Author: poeml
Date: Wed Jan 27 00:46:55 2010
New Revision: 7944

URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain?rev=7944&view=rev
Log:
mb scan:
- make FTP authentication work (URLs in the format ftp://user:pass_at_hostname/path)
  Note that these URLs might end up in public mirror lists, if those are generated somehow.

Modified:
    trunk/tools/scanner.pl

Modified: trunk/tools/scanner.pl
URL: http://svn.mirrorbrain.org/viewvc/mirrorbrain/trunk/tools/scanner.pl?rev=7944&r1=7943&r2=7944&view=diff
==============================================================================
--- trunk/tools/scanner.pl (original)
+++ trunk/tools/scanner.pl Wed Jan 27 00:46:55 2010
_at_@ -1183,9 +1183,6 @@
 sub ftp_connect
 {
   my ($identifier, $url) = _at__;
-  my $port = 21;
-  my $user ||= 'anonymous';
-  my $pass ||= "$0_at_" . Net::Domain::hostfqdn;
 
   if($url =~ s{^(\w+)://}{}) {	# no protocol prefix please
     if(lc $1 ne 'ftp') {
_at_@ -1194,7 +1191,15 @@
     }
   }
   $url =~ s{/.*$}{};  # no path components please
+  my $port = 21;
   $port = $1 if $url =~ s{:(\d+)$}{};	# port number?
+
+  my $auth = $1 if $url =~ s{^([^:]*:[^_at_]*)@}{};	# auth data?
+  my $user = $1 if $auth =~ s{^([^:]*):}{};
+  my $pass = $auth;
+  $user ||= 'anonymous';
+  $pass ||= "$0_at_" . Net::Domain::hostfqdn;
+
   my $ftp = Net::FTP->new($url, Timeout => 360, Port => $port, Debug => (($verbose||0)>2)?1:0, Passive => 1, Hash => 0);
   unless (defined $ftp) {
     warn "$identifier: ftp_connect($identifier, $url, $port) failed: $! $_at_\n";




_______________________________________________
mirrorbrain-commits mailing list
Archive: http://mirrorbrain.org/archive/mirrorbrain-commits/

Note: To remove yourself from this list, send a mail with the content
 	unsubscribe
to the address mirrorbrain-commits-request_at_mirrorbrain.org
Received on Tue Jan 26 2010 - 23:47:01 GMT

This archive was generated by hypermail 2.3.0 : Mon Feb 20 2012 - 23:47:04 GMT