aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2011-11-01 14:11:36 +0100
committerYang Tse <yangsita@gmail.com>2011-11-01 14:11:36 +0100
commitaf425efe833b0b0fd6e8d85954d18bbe9c940401 (patch)
tree7114e758822b19abab5bc62cc144e9f116284250
parent9cfc0c73a7d4b664b532c108bd2d5f8078972f9d (diff)
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.
-rwxr-xr-xtests/ftpserver.pl46
1 files changed, 38 insertions, 8 deletions
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;
}