]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
ftpserver.pl: Added support for new SMTP commands
authorSteve Holme <steve_holme@hotmail.com>
Sat, 16 Nov 2013 11:11:45 +0000 (11:11 +0000)
committerSteve Holme <steve_holme@hotmail.com>
Sat, 16 Nov 2013 11:17:23 +0000 (11:17 +0000)
tests/ftpserver.pl

index 96cfdfe9852e67c796f4fd90675fc7a67a37e9cb..a116850aac2e6f28bdf264044cb264d19c8dc6f5 100755 (executable)
@@ -627,9 +627,14 @@ sub protocolsetup {
         %commandfunc = (
             'DATA' => \&DATA_smtp,
             'EHLO' => \&EHLO_smtp,
+            'EXPN' => \&EXPN_smtp,
             'HELO' => \&HELO_smtp,
+            'HELP' => \&HELP_smtp,
             'MAIL' => \&MAIL_smtp,
+            'NOOP' => \&NOOP_smtp,
+            'RSET' => \&RSET_smtp,
             'RCPT' => \&RCPT_smtp,
+            'VRFY' => \&VRFY_smtp,
             'QUIT' => \&QUIT_smtp,
         );
         %displaytext = (
@@ -957,6 +962,113 @@ sub DATA_smtp {
     return 0;
 }
 
+sub NOOP_smtp {
+    my ($args) = @_;
+
+    if($args) {
+        sendcontrol "501 Unrecognized parameter\r\n";
+    }
+    else {
+        sendcontrol "250 OK\r\n";
+    }
+
+    return 0;
+}
+
+sub RSET_smtp {
+    my ($args) = @_;
+
+    if($args) {
+        sendcontrol "501 Unrecognized parameter\r\n";
+    }
+    else {
+        sendcontrol "250 Resetting\r\n";
+    }
+
+    return 0;
+}
+
+sub HELP_smtp {
+    my ($args) = @_;
+
+    # One argument is optional
+    if($args) {
+        logmsg "HELP_smtp got $args\n";
+    }
+
+    sendcontrol "214-This server supports the following commands:\r\n";
+
+    if(@auth_mechs) {
+        sendcontrol "214 HELO EHLO RCPT DATA RSET MAIL QUIT HELP AUTH\r\n";
+    }
+    else {
+        sendcontrol "214 HELO EHLO RCPT DATA RSET MAIL QUIT HELP\r\n";
+    }
+
+    return 0;
+}
+
+sub VRFY_smtp {
+    my ($args) = @_;
+    my ($username, $address) = split(/ /, $args, 2);
+
+    logmsg "VRFY_smtp got $args\n";
+
+    if($username eq "") {
+        sendcontrol "501 Unrecognized parameter\r\n";
+    }
+    else {
+        my $testno = $smtp_client;
+
+        $testno =~ s/^([^0-9]*)//;
+        my $testpart = "";
+        if ($testno > 10000) {
+            $testpart = $testno % 10000;
+            $testno = int($testno / 10000);
+        }
+
+        loadtest("$srcdir/data/test$testno");
+
+        my @data = getpart("reply", "data$testpart");
+
+        for my $d (@data) {
+            sendcontrol $d;
+        }
+    }
+
+    return 0;
+}
+
+sub EXPN_smtp {
+    my ($list_name) = @_;
+
+    logmsg "EXPN_smtp got $list_name\n";
+
+    if(!$list_name) {
+        sendcontrol "501 Unrecognized parameter\r\n";
+    }
+    else {
+        my $testno = $smtp_client;
+
+        $testno =~ s/^([^0-9]*)//;
+        my $testpart = "";
+        if ($testno > 10000) {
+            $testpart = $testno % 10000;
+            $testno = int($testno / 10000);
+        }
+
+        loadtest("$srcdir/data/test$testno");
+
+        my @data = getpart("reply", "data$testpart");
+
+        for my $d (@data) {
+            sendcontrol $d;
+        }
+    }
+
+    return 0;
+}
+
 sub QUIT_smtp {
     sendcontrol "221 cURL $smtp_type server signing off\r\n";