From af425efe833b0b0fd6e8d85954d18bbe9c940401 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Tue, 1 Nov 2011 14:11:36 +0100 Subject: FTP test server: NODATACONN commands follow-up Make NODATACONN custom commands apply to both active and passive FTP, and ensure 425 and 421 are not returned unless data channel usage is attempted. --- tests/ftpserver.pl | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) (limited to 'tests') diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index 729cbf7f3..70356a1c3 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -831,7 +831,15 @@ my @ftpdir=("total 20\r\n", "dr-xr-xr-x 5 0 1 512 Oct 1 1997 usr\r\n"); if($datasockf_conn eq 'no') { - sendcontrol "503 data channel not established\r\n"; + if($nodataconn425) { + sendcontrol "425 Can't open data connection\r\n"; + } + elsif($nodataconn421) { + sendcontrol "421 Connection timed out\r\n"; + } + else { + sendcontrol "503 data channel not established\r\n"; + } return 0; } @@ -852,7 +860,15 @@ sub NLST_ftp { my @ftpdir=("file", "with space", "fake", "..", " ..", "funny", "README"); if($datasockf_conn eq 'no') { - sendcontrol "503 data channel not established\r\n"; + if($nodataconn425) { + sendcontrol "425 Can't open data connection\r\n"; + } + elsif($nodataconn421) { + sendcontrol "421 Connection timed out\r\n"; + } + else { + sendcontrol "503 data channel not established\r\n"; + } return 0; } @@ -960,7 +976,15 @@ sub RETR_ftp { my ($testno) = @_; if($datasockf_conn eq 'no') { - sendcontrol "503 data channel not established\r\n"; + if($nodataconn425) { + sendcontrol "425 Can't open data connection\r\n"; + } + elsif($nodataconn421) { + sendcontrol "421 Connection timed out\r\n"; + } + else { + sendcontrol "503 data channel not established\r\n"; + } return 0; } @@ -1059,7 +1083,15 @@ sub STOR_ftp { my $filename = "log/upload.$testno"; if($datasockf_conn eq 'no') { - sendcontrol "503 data channel not established\r\n"; + if($nodataconn425) { + sendcontrol "425 Can't open data connection\r\n"; + } + elsif($nodataconn421) { + sendcontrol "421 Connection timed out\r\n"; + } + else { + sendcontrol "503 data channel not established\r\n"; + } return 0; } @@ -1347,7 +1379,6 @@ sub PORT_ftp { "(NODATACONN425)\n"; datasockf_state('ACTIVE_NODATACONN'); logmsg "====> Active DATA channel not established\n"; - sendcontrol "425 Can't open data connection\r\n"; return; } elsif($nodataconn421) { @@ -1355,7 +1386,6 @@ sub PORT_ftp { "(NODATACONN421)\n"; datasockf_state('ACTIVE_NODATACONN'); logmsg "====> Active DATA channel not established\n"; - sendcontrol "421 Connection timed out\r\n"; return; } @@ -1513,12 +1543,12 @@ sub customize { $pasvbadip=1; } elsif($_ =~ /NODATACONN425/) { - # applies only to active FTP mode + # applies to both active and passive FTP modes logmsg "FTPD: instructed to use NODATACONN425\n"; $nodataconn425=1; } elsif($_ =~ /NODATACONN421/) { - # applies only to active FTP mode + # applies to both active and passive FTP modes logmsg "FTPD: instructed to use NODATACONN421\n"; $nodataconn421=1; } -- cgit v1.2.3