Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
1.2 KiB

  1. package URI::ftp;
  2. require URI::_server;
  3. require URI::_userpass;
  4. @ISA=qw(URI::_server URI::_userpass);
  5. use strict;
  6. use vars qw($whoami $fqdn);
  7. use URI::Escape qw(uri_unescape);
  8. sub default_port { 21 }
  9. sub path { shift->path_query(@_) } # XXX
  10. sub _user { shift->SUPER::user(@_); }
  11. sub _password { shift->SUPER::password(@_); }
  12. sub user
  13. {
  14. my $self = shift;
  15. my $user = $self->_user(@_);
  16. $user = "anonymous" unless defined $user;
  17. $user;
  18. }
  19. sub password
  20. {
  21. my $self = shift;
  22. my $pass = $self->_password(@_);
  23. unless (defined $pass) {
  24. my $user = $self->user;
  25. if ($user eq 'anonymous' || $user eq 'ftp') {
  26. # anonymous ftp login password
  27. unless (defined $fqdn) {
  28. eval {
  29. require Net::Domain;
  30. $fqdn = Net::Domain::hostfqdn();
  31. };
  32. if ($@) {
  33. $fqdn = '';
  34. }
  35. }
  36. unless (defined $whoami) {
  37. $whoami = $ENV{USER} || $ENV{LOGNAME} || $ENV{USERNAME};
  38. unless ($whoami) {
  39. if ($^O eq 'MSWin32') { $whoami = Win32::LoginName() }
  40. else {
  41. $whoami = getlogin || getpwuid($<) || 'unknown';
  42. }
  43. }
  44. }
  45. $pass = "$whoami\@$fqdn";
  46. }
  47. }
  48. $pass;
  49. }
  50. 1;