diff options
author | Steve Holme <steve_holme@hotmail.com> | 2013-09-15 16:53:20 +0100 |
---|---|---|
committer | Steve Holme <steve_holme@hotmail.com> | 2013-09-15 16:53:20 +0100 |
commit | 33c1f2876b90294c9a1e96e86bb687687a1bb03e (patch) | |
tree | f6f5722d5bd59c81aa69e8d43d8aca762073a139 /tests/ftpserver.pl | |
parent | 00ee5c5cf19be6a26ca7dffa9086ee106d81f706 (diff) |
ftpserver.pl: Added CAPA & AUTH directive support to the SMTP EHLO handler
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-x | tests/ftpserver.pl | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index ab8d069b2..1e58eee41 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -689,6 +689,55 @@ sub close_dataconn { # what set by "RCPT" my $smtp_rcpt; +sub EHLO_smtp { + my ($client) = @_; + my @data; + + # TODO: Get the IP address of the client connection to use in the EHLO + # response when the client doesn't specify one but for now use 127.0.0.1 + if (!$client) { + $client = "[127.0.0.1]"; + } + + # Calculate the EHLO response + push @data, "ESMTP pingpong test server Hello $client"; + + if((@capabilities) || (@auth_mechs)) { + my $mechs; + + for my $c (@capabilities) { + push @data, $c; + } + + for my $am (@auth_mechs) { + if(!$mechs) { + $mechs = "$am"; + } + else { + $mechs .= " $am"; + } + } + + if($mechs) { + push @data, "AUTH $mechs"; + } + } + + # Send the EHLO response + for (my $i = 0; $i < @data; i++) { + my $d = $data[$i]; + + if($i < @data - 1) { + sendcontrol "250-$d\r\n"; + } + else { + sendcontrol "250 $d\r\n"; + } + } + + return 0; +} + sub DATA_smtp { my $testno; @@ -787,13 +836,6 @@ sub HELO_smtp { return 0; } -sub EHLO_smtp { - sendcontrol "250-SIZE\r\n"; - sendcontrol "250 Welcome visitor, stay a while staaaaaay forever\r\n"; - - return 0; -} - sub QUIT_smtp { sendcontrol "200 byebye\r\n"; |