aboutsummaryrefslogtreecommitdiff
path: root/tests/ftpserver.pl
diff options
context:
space:
mode:
authorSteve Holme <steve_holme@hotmail.com>2013-09-14 20:45:58 +0100
committerSteve Holme <steve_holme@hotmail.com>2013-09-14 20:46:45 +0100
commit84ad1569e5fc939eb8bdac2baf4836806c519579 (patch)
tree872fcf917725ffe750b50910c945aa501304986f /tests/ftpserver.pl
parent45e0a661cece6a2c2af2e946b5ef67b5aac01c68 (diff)
ftpserver.pl: Moved POP3 USER and PASS handlers into own functions
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-xtests/ftpserver.pl39
1 files changed, 37 insertions, 2 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index 78e50c6a5..4f67207cd 100755
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -561,16 +561,16 @@ sub protocolsetup {
'DELE' => \&DELE_pop3,
'LIST' => \&LIST_pop3,
'NOOP' => \&NOOP_pop3,
+ 'PASS' => \&PASS_pop3,
'QUIT' => \&QUIT_pop3,
'RETR' => \&RETR_pop3,
'RSET' => \&RSET_pop3,
'STAT' => \&STAT_pop3,
'TOP' => \&TOP_pop3,
'UIDL' => \&UIDL_pop3,
+ 'USER' => \&USER_pop3,
);
%displaytext = (
- 'USER' => '+OK We are happy you popped in!',
- 'PASS' => '+OK Access granted',
'welcome' => join("",
' _ _ ____ _ '."\r\n",
' ___| | | | _ \| | '."\r\n",
@@ -1366,6 +1366,9 @@ sub LOGOUT_imap {
################ POP3 commands
################
+# Who is attempting to log in
+my $username;
+
sub CAPA_pop3 {
my ($testno) = @_;
@@ -1438,6 +1441,38 @@ sub AUTH_pop3 {
return 0;
}
+sub USER_pop3 {
+ my ($user) = @_;
+
+ logmsg "USER_pop3 got $user\n";
+
+ if (!$user) {
+ sendcontrol "-ERR Protocol error\r\n";
+ }
+ else {
+ $username = $user;
+
+ sendcontrol "+OK\r\n";
+ }
+
+ return 0;
+}
+
+sub PASS_pop3 {
+ my ($password) = @_;
+
+ logmsg "PASS_pop3 got $password\n";
+
+ if (($username ne "user") && ($password ne "secret")) {
+ sendcontrol "-ERR Login failure\r\n";
+ }
+ else {
+ sendcontrol "+OK Login successful\r\n";
+ }
+
+ return 0;
+}
+
sub RETR_pop3 {
my ($testno) = @_;
my @data;