aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2001-11-28 13:07:49 +0000
committerDaniel Stenberg <daniel@haxx.se>2001-11-28 13:07:49 +0000
commit10fdb1d743746294da4d23cbfd677e60d3d6f5d0 (patch)
treee1e99930dc0e5f3fffe443a862e0021cb2e1eef5 /tests
parentf0d3fccd4baa8206cd993a4c248788aa09666a21 (diff)
EPSV and SIZE adjustments
Diffstat (limited to 'tests')
-rw-r--r--tests/data/test1002
-rw-r--r--tests/data/test1026
-rw-r--r--tests/ftpserver.pl39
3 files changed, 41 insertions, 6 deletions
diff --git a/tests/data/test100 b/tests/data/test100
index 3f81d6bdb..c5ccce786 100644
--- a/tests/data/test100
+++ b/tests/data/test100
@@ -37,7 +37,7 @@ filter off really nothing
USER anonymous
PASS curl_by_daniel@haxx.se
PWD
-PASV
+EPSV
TYPE A
LIST
</protocol>
diff --git a/tests/data/test102 b/tests/data/test102
index 138e57ca7..186732625 100644
--- a/tests/data/test102
+++ b/tests/data/test102
@@ -19,6 +19,10 @@ FTP RETR PASV
ftp://%HOSTIP:%FTPPORT/102
</command>
</test>
+<file name="log/ftpserver.cmd">
+REPLY EPSV 500 no such command
+</file>
+
# Verify data after the test has been "shot"
<verify>
@@ -26,8 +30,10 @@ ftp://%HOSTIP:%FTPPORT/102
USER anonymous
PASS curl_by_daniel@haxx.se
PWD
+EPSV
PASV
TYPE I
+SIZE 102
RETR 102
</protocol>
</verify>
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index ef3478775..beae5fa14 100644
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -65,6 +65,7 @@ my %commandok = (
'USER' => 'fresh',
'PASS' => 'passwd',
'PASV' => 'loggedin|twosock',
+ 'EPSV' => 'loggedin|twosock',
'PORT' => 'loggedin|twosock',
'TYPE' => 'loggedin|twosock',
'LIST' => 'twosock',
@@ -86,6 +87,7 @@ my %statechange = ( 'USER' => 'passwd', # USER goes to passwd state
'PASS' => 'loggedin', # PASS goes to loggedin state
'PORT' => 'twosock', # PORT goes to twosock
'PASV' => 'twosock', # PASV goes to twosock
+ 'EPSV' => 'twosock', # EPSV goes to twosock
);
# this text is shown before the function specified below is run
@@ -108,6 +110,7 @@ my %commandfunc = ( 'PORT' => \&PORT_command,
'LIST' => \&LIST_command,
'NLST' => \&NLST_command,
'PASV' => \&PASV_command,
+ 'EPSV' => \&PASV_command,
'RETR' => \&RETR_command,
'SIZE' => \&SIZE_command,
'REST' => \&REST_command,
@@ -174,8 +177,19 @@ sub SIZE_command {
logmsg "SIZE $testno returned $size\n";
}
else {
- print "550 $testno: No such file or directory.\r\n";
- logmsg "SIZE $testno: no such file\n";
+ $size=0;
+ @data = getpart("reply", "data");
+ for(@data) {
+ $size += length($_);
+ }
+ if($size) {
+ print "213 $size\r\n";
+ logmsg "SIZE $testno returned $size\n";
+ }
+ else {
+ print "550 $testno: No such file or directory.\r\n";
+ logmsg "SIZE $testno: no such file\n";
+ }
}
return 0;
}
@@ -259,6 +273,8 @@ sub STOR_command {
my $pasvport=9000;
sub PASV_command {
+ my ($arg, $cmd)=@_;
+
socket(Server2, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
setsockopt(Server2, SOL_SOCKET, SO_REUSEADDR,
pack("l", 1)) || die "setsockopt: $!";
@@ -283,8 +299,17 @@ sub PASV_command {
}
listen(Server2,SOMAXCONN) || die "listen: $!";
- printf("227 Entering Passive Mode (127,0,0,1,%d,%d)\n",
- ($pasvport/256), ($pasvport%256));
+ if($cmd ne "EPSV") {
+ # PASV reply
+ logmsg "replying to a $cmd command\n";
+ printf("227 Entering Passive Mode (127,0,0,1,%d,%d)\n",
+ ($pasvport/256), ($pasvport%256));
+ }
+ else {
+ # EPSV reply
+ logmsg "replying to a $cmd command\n";
+ printf("229 Entering Passive Mode (|||%d|)\n", $pasvport);
+ }
my $paddr = accept(SOCK, Server2);
my($iport,$iaddr) = sockaddr_in($paddr);
@@ -297,6 +322,7 @@ sub PASV_command {
return;
}
+
sub PORT_command {
my $arg = $_[0];
@@ -432,6 +458,9 @@ for ( $waitedpid = 0;
if($text eq "") {
$text = $displaytext{$FTPCMD};
}
+ else {
+ logmsg "$FTPCMD made to send '$text'\n";
+ }
if($text) {
print "$text\r\n";
}
@@ -442,7 +471,7 @@ for ( $waitedpid = 0;
my $func = $commandfunc{$FTPCMD};
if($func) {
# it is!
- \&$func($FTPARG);
+ \&$func($FTPARG, $FTPCMD);
}
}