Commit 26361620 authored by Steve Holme's avatar Steve Holme
Browse files

ftpserver.pl: Reworked SMTP verified server detection

Following the addition of informational commands to the SMTP protocol,
the test server is no longer required to return the verified server
information in responses that curl only outputs in verbose mode.

Instead, a similar detection mechanism to that used by FTP, IMAP and
POP3 can now be used.
parent c9dd4022
Loading
Loading
Loading
Loading
+63 −76
Original line number Diff line number Diff line
@@ -702,19 +702,6 @@ my $smtp_client;

sub EHLO_smtp {
    my ($client) = @_;

    if($client eq "verifiedserver") {
        # This is the secret command that verifies that this actually is
        # the curl test server
        sendcontrol "554 WE ROOLZ: $$\r\n";

        if($verbose) {
            print STDERR "FTPD: We returned proof we are the test server\n";
        }

        logmsg "return proof we are we\n";
    }
    else {
    my @data;

    # TODO: Get the IP address of the client connection to use in the
@@ -773,18 +760,6 @@ sub EHLO_smtp {
sub HELO_smtp {
    my ($client) = @_;

    if($client eq "verifiedserver") {
        # This is the secret command that verifies that this actually is
        # the curl test server
        sendcontrol "554 WE ROOLZ: $$\r\n";

        if($verbose) {
            print STDERR "FTPD: We returned proof we are the test server\n";
        }

        logmsg "return proof we are we\n";
    }
    else {
    # TODO: Get the IP address of the client connection to use in the HELO
    # response when the client doesn't specify one but for now use 127.0.0.1
    if(!$client) {
@@ -799,7 +774,6 @@ sub HELO_smtp {

    # Store the client (as it may contain the test number)
    $smtp_client = $client;
    }

    return 0;
}
@@ -997,6 +971,18 @@ sub HELP_smtp {
        logmsg "HELP_smtp got $args\n";
    }

    if($smtp_client eq "verifiedserver") {
        # This is the secret command that verifies that this actually is
        # the curl test server
        sendcontrol "214 WE ROOLZ: $$\r\n";

        if($verbose) {
            print STDERR "FTPD: We returned proof we are the test server\n";
        }

        logmsg "return proof we are we\n";
    }
    else {
        sendcontrol "214-This server supports the following commands:\r\n";

        if(@auth_mechs) {
@@ -1005,6 +991,7 @@ sub HELP_smtp {
        else {
            sendcontrol "214 HELO EHLO RCPT DATA RSET MAIL VRFY EXPN QUIT HELP\r\n";
        }
    }

    return 0;
}
+0 −8
Original line number Diff line number Diff line
@@ -790,14 +790,6 @@ sub verifyftp {
    if($proto eq "ftps") {
        $extra .= "--insecure --ftp-ssl-control ";
    }
    elsif($proto eq "smtp") {
        # SMTP is a bit different since it requires more options and it
        # has _no_ output!
        $extra .= "--mail-rcpt verifiedserver ";
        $extra .= "--mail-from fake\@example.com ";
        $extra .= "--upload /dev/null ";
        $extra .= "--stderr - "; # move stderr to parse the verbose stuff
    }

    my $flags = "--max-time $server_response_maxtime ";
    $flags .= "--silent ";