ftpserver.pl: Moved POP3 USER and PASS handlers into own functions

This commit is contained in:
Steve Holme 2013-09-14 20:45:58 +01:00
parent 45e0a661ce
commit 84ad1569e5
2 changed files with 38 additions and 5 deletions

View File

@ -2,6 +2,7 @@
<info>
<keywords>
POP3
LOGIN
FAILURE
</keywords>
</info>
@ -9,9 +10,6 @@ FAILURE
#
# Server-side
<reply>
<servercmd>
REPLY PASS -ERR invalid login
</servercmd>
</reply>
#

View File

@ -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;