mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 16:18:48 -05:00
ftpserver.pl: Added support for APOP POP3 authentication
This commit is contained in:
parent
72f850571d
commit
4be0af7f74
@ -52,6 +52,7 @@ BEGIN {
|
|||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use IPC::Open2;
|
use IPC::Open2;
|
||||||
|
use Digest::MD5;
|
||||||
|
|
||||||
require "getpart.pm";
|
require "getpart.pm";
|
||||||
require "ftp.pm";
|
require "ftp.pm";
|
||||||
@ -174,6 +175,7 @@ my $exit_signal; # first signal handled in exit_signal_handler
|
|||||||
#
|
#
|
||||||
my $TEXT_USERNAME = "user";
|
my $TEXT_USERNAME = "user";
|
||||||
my $TEXT_PASSWORD = "secret";
|
my $TEXT_PASSWORD = "secret";
|
||||||
|
my $POP3_TIMESTAMP = "<1972.987654321\@curl>";
|
||||||
|
|
||||||
#**********************************************************************
|
#**********************************************************************
|
||||||
# exit_signal_handler will be triggered to indicate that the program
|
# exit_signal_handler will be triggered to indicate that the program
|
||||||
@ -562,6 +564,7 @@ sub protocolsetup {
|
|||||||
}
|
}
|
||||||
elsif($proto eq 'pop3') {
|
elsif($proto eq 'pop3') {
|
||||||
%commandfunc = (
|
%commandfunc = (
|
||||||
|
'APOP' => \&APOP_pop3,
|
||||||
'AUTH' => \&AUTH_pop3,
|
'AUTH' => \&AUTH_pop3,
|
||||||
'CAPA' => \&CAPA_pop3,
|
'CAPA' => \&CAPA_pop3,
|
||||||
'DELE' => \&DELE_pop3,
|
'DELE' => \&DELE_pop3,
|
||||||
@ -583,7 +586,7 @@ sub protocolsetup {
|
|||||||
' / __| | | | |_) | | '."\r\n",
|
' / __| | | | |_) | | '."\r\n",
|
||||||
' | (__| |_| | _ <| |___ '."\r\n",
|
' | (__| |_| | _ <| |___ '."\r\n",
|
||||||
' \___|\___/|_| \_\_____|'."\r\n",
|
' \___|\___/|_| \_\_____|'."\r\n",
|
||||||
'+OK cURL POP3 server ready to serve'."\r\n")
|
'+OK cURL POP3 server ready to serve '.$POP3_TIMESTAMP."\r\n")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
elsif($proto eq 'imap') {
|
elsif($proto eq 'imap') {
|
||||||
@ -1633,6 +1636,27 @@ sub CAPA_pop3 {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub APOP_pop3 {
|
||||||
|
my ($args) = @_;
|
||||||
|
my ($user, $secret) = split(/ /, $args, 2);
|
||||||
|
|
||||||
|
if (($user eq "") || ($secret eq "")) {
|
||||||
|
sendcontrol "-ERR Protocol error\r\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my $digest = Digest::MD5::md5_hex($POP3_TIMESTAMP, $TEXT_PASSWORD);
|
||||||
|
|
||||||
|
if (($user ne $TEXT_USERNAME) || ($secret ne $digest)) {
|
||||||
|
sendcontrol "-ERR Login failure\r\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendcontrol "+OK Login successful\r\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
sub AUTH_pop3 {
|
sub AUTH_pop3 {
|
||||||
my ($testno) = @_;
|
my ($testno) = @_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user