aboutsummaryrefslogtreecommitdiff
path: root/tests/ftpserver.pl
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-10-19 10:38:19 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-10-19 10:38:19 +0100
commit4be0af7f7464ba906dfedede53e0eda10d43bbdd (patch)
tree2b27687187004a1b4ab18d91ba88e112e309a3af /tests/ftpserver.pl
parent72f850571d24ae4833c162a0df58fd7ce97ad9b6 (diff)
ftpserver.pl: Added support for APOP POP3 authentication
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-xtests/ftpserver.pl26
1 files changed, 25 insertions, 1 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 77cef42dd..7efc8be04 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -52,6 +52,7 @@ BEGIN {
use strict;
use warnings;
use IPC::Open2;
+use Digest::MD5;
require "getpart.pm";
require "ftp.pm";
@@ -174,6 +175,7 @@ my $exit_signal; # first signal handled in exit_signal_handler
#
my $TEXT_USERNAME = "user";
my $TEXT_PASSWORD = "secret";
+my $POP3_TIMESTAMP = "<1972.987654321\@curl>";
#**********************************************************************
# exit_signal_handler will be triggered to indicate that the program
@@ -562,6 +564,7 @@ sub protocolsetup {
}
elsif($proto eq 'pop3') {
%commandfunc = (
+ 'APOP' => \&APOP_pop3,
'AUTH' => \&AUTH_pop3,
'CAPA' => \&CAPA_pop3,
'DELE' => \&DELE_pop3,
@@ -583,7 +586,7 @@ sub protocolsetup {
' / __| | | | |_) | | '."\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') {
@@ -1633,6 +1636,27 @@ sub CAPA_pop3 {
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 {
my ($testno) = @_;