mirror of https://github.com/moparisthebest/curl
EPSV and SIZE adjustments
This commit is contained in:
parent
f0d3fccd4b
commit
10fdb1d743
|
@ -37,7 +37,7 @@ filter off really nothing
|
||||||
USER anonymous
|
USER anonymous
|
||||||
PASS curl_by_daniel@haxx.se
|
PASS curl_by_daniel@haxx.se
|
||||||
PWD
|
PWD
|
||||||
PASV
|
EPSV
|
||||||
TYPE A
|
TYPE A
|
||||||
LIST
|
LIST
|
||||||
</protocol>
|
</protocol>
|
||||||
|
|
|
@ -19,6 +19,10 @@ FTP RETR PASV
|
||||||
ftp://%HOSTIP:%FTPPORT/102
|
ftp://%HOSTIP:%FTPPORT/102
|
||||||
</command>
|
</command>
|
||||||
</test>
|
</test>
|
||||||
|
<file name="log/ftpserver.cmd">
|
||||||
|
REPLY EPSV 500 no such command
|
||||||
|
</file>
|
||||||
|
|
||||||
|
|
||||||
# Verify data after the test has been "shot"
|
# Verify data after the test has been "shot"
|
||||||
<verify>
|
<verify>
|
||||||
|
@ -26,8 +30,10 @@ ftp://%HOSTIP:%FTPPORT/102
|
||||||
USER anonymous
|
USER anonymous
|
||||||
PASS curl_by_daniel@haxx.se
|
PASS curl_by_daniel@haxx.se
|
||||||
PWD
|
PWD
|
||||||
|
EPSV
|
||||||
PASV
|
PASV
|
||||||
TYPE I
|
TYPE I
|
||||||
|
SIZE 102
|
||||||
RETR 102
|
RETR 102
|
||||||
</protocol>
|
</protocol>
|
||||||
</verify>
|
</verify>
|
||||||
|
|
|
@ -65,6 +65,7 @@ my %commandok = (
|
||||||
'USER' => 'fresh',
|
'USER' => 'fresh',
|
||||||
'PASS' => 'passwd',
|
'PASS' => 'passwd',
|
||||||
'PASV' => 'loggedin|twosock',
|
'PASV' => 'loggedin|twosock',
|
||||||
|
'EPSV' => 'loggedin|twosock',
|
||||||
'PORT' => 'loggedin|twosock',
|
'PORT' => 'loggedin|twosock',
|
||||||
'TYPE' => 'loggedin|twosock',
|
'TYPE' => 'loggedin|twosock',
|
||||||
'LIST' => 'twosock',
|
'LIST' => 'twosock',
|
||||||
|
@ -86,6 +87,7 @@ my %statechange = ( 'USER' => 'passwd', # USER goes to passwd state
|
||||||
'PASS' => 'loggedin', # PASS goes to loggedin state
|
'PASS' => 'loggedin', # PASS goes to loggedin state
|
||||||
'PORT' => 'twosock', # PORT goes to twosock
|
'PORT' => 'twosock', # PORT goes to twosock
|
||||||
'PASV' => 'twosock', # PASV 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
|
# this text is shown before the function specified below is run
|
||||||
|
@ -108,6 +110,7 @@ my %commandfunc = ( 'PORT' => \&PORT_command,
|
||||||
'LIST' => \&LIST_command,
|
'LIST' => \&LIST_command,
|
||||||
'NLST' => \&NLST_command,
|
'NLST' => \&NLST_command,
|
||||||
'PASV' => \&PASV_command,
|
'PASV' => \&PASV_command,
|
||||||
|
'EPSV' => \&PASV_command,
|
||||||
'RETR' => \&RETR_command,
|
'RETR' => \&RETR_command,
|
||||||
'SIZE' => \&SIZE_command,
|
'SIZE' => \&SIZE_command,
|
||||||
'REST' => \&REST_command,
|
'REST' => \&REST_command,
|
||||||
|
@ -174,8 +177,19 @@ sub SIZE_command {
|
||||||
logmsg "SIZE $testno returned $size\n";
|
logmsg "SIZE $testno returned $size\n";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print "550 $testno: No such file or directory.\r\n";
|
$size=0;
|
||||||
logmsg "SIZE $testno: no such file\n";
|
@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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -259,6 +273,8 @@ sub STOR_command {
|
||||||
|
|
||||||
my $pasvport=9000;
|
my $pasvport=9000;
|
||||||
sub PASV_command {
|
sub PASV_command {
|
||||||
|
my ($arg, $cmd)=@_;
|
||||||
|
|
||||||
socket(Server2, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
|
socket(Server2, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";
|
||||||
setsockopt(Server2, SOL_SOCKET, SO_REUSEADDR,
|
setsockopt(Server2, SOL_SOCKET, SO_REUSEADDR,
|
||||||
pack("l", 1)) || die "setsockopt: $!";
|
pack("l", 1)) || die "setsockopt: $!";
|
||||||
|
@ -283,8 +299,17 @@ sub PASV_command {
|
||||||
}
|
}
|
||||||
listen(Server2,SOMAXCONN) || die "listen: $!";
|
listen(Server2,SOMAXCONN) || die "listen: $!";
|
||||||
|
|
||||||
printf("227 Entering Passive Mode (127,0,0,1,%d,%d)\n",
|
if($cmd ne "EPSV") {
|
||||||
($pasvport/256), ($pasvport%256));
|
# 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 $paddr = accept(SOCK, Server2);
|
||||||
my($iport,$iaddr) = sockaddr_in($paddr);
|
my($iport,$iaddr) = sockaddr_in($paddr);
|
||||||
|
@ -297,6 +322,7 @@ sub PASV_command {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub PORT_command {
|
sub PORT_command {
|
||||||
my $arg = $_[0];
|
my $arg = $_[0];
|
||||||
|
|
||||||
|
@ -432,6 +458,9 @@ for ( $waitedpid = 0;
|
||||||
if($text eq "") {
|
if($text eq "") {
|
||||||
$text = $displaytext{$FTPCMD};
|
$text = $displaytext{$FTPCMD};
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
logmsg "$FTPCMD made to send '$text'\n";
|
||||||
|
}
|
||||||
if($text) {
|
if($text) {
|
||||||
print "$text\r\n";
|
print "$text\r\n";
|
||||||
}
|
}
|
||||||
|
@ -442,7 +471,7 @@ for ( $waitedpid = 0;
|
||||||
my $func = $commandfunc{$FTPCMD};
|
my $func = $commandfunc{$FTPCMD};
|
||||||
if($func) {
|
if($func) {
|
||||||
# it is!
|
# it is!
|
||||||
\&$func($FTPARG);
|
\&$func($FTPARG, $FTPCMD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue