loadtest("$srcdir/data/test$testno");
- logmsg "MDTM $testno\n";
-
my @data = getpart("reply", "mdtm");
my $reply = $data[0];
if($reply <0) {
sendcontrol "550 $testno: no such file.\r\n";
- logmsg "MDTM $testno: no such file\n";
}
elsif($reply) {
sendcontrol "$reply\r\n";
- logmsg "MDTM $testno returned $reply\n";
}
else {
sendcontrol "500 MDTM: no such command.\r\n";
- logmsg "MDTM: no such command\n";
}
return 0;
}
loadtest("$srcdir/data/test$testno");
- logmsg "SIZE file \"$testno\"\n";
-
if($testno eq "verifiedserver") {
my $response = "WE ROOLZ: $$\r\n";
my $size = length($response);
sendcontrol "213 $size\r\n";
- logmsg "SIZE $testno returned $size\n";
return 0;
}
if($size) {
if($size > -1) {
sendcontrol "213 $size\r\n";
- logmsg "SIZE $testno returned $size\n";
}
else {
sendcontrol "550 $testno: No such file or directory.\r\n";
- logmsg "SIZE $testno: no such file\n";
}
}
else {
}
if($size) {
sendcontrol "213 $size\r\n";
- logmsg "SIZE $testno returned $size\n";
}
else {
sendcontrol "550 $testno: No such file or directory.\r\n";
- logmsg "SIZE $testno: no such file\n";
}
}
return 0;
sub RETR_command {
my ($testno) = @_;
- logmsg "RETR file \"$testno\"\n";
-
if($testno =~ /^verifiedserver$/) {
# this is the secret command that verifies that this actually is
# the curl test server
my $response = "WE ROOLZ: $$\r\n";
my $len = length($response);
sendcontrol "150 Binary junk ($len bytes).\r\n";
- logmsg "pass our pid on the data connection\n";
senddata "WE ROOLZ: $$\r\n";
close_dataconn(0);
- logmsg "Data sent, sending a 226-reponse now\n";
sendcontrol "226 File transfer complete\r\n";
if($verbose) {
print STDERR "FTPD: We returned proof we are the test server\n";
}
- logmsg "we returned proof that we are the test server\n";
return 0;
}
if($retrweirdo) {
sendcontrol "150 Binary data connection for $testno () ($size bytes).\r\n",
"226 File transfer complete\r\n";
- logmsg "150+226 in one shot!\n";
- logmsg "pass RETR data on data connection\n";
for(@data) {
my $send = $_;
senddata $send;
}
sendcontrol "150 Binary data connection for $testno () $sz.\r\n";
- logmsg "150 Binary data connection for $testno () $sz.\n";
- logmsg "pass RETR data on data connection\n";
for(@data) {
my $send = $_;
senddata $send;
}
else {
sendcontrol "550 $testno: No such file or directory.\r\n";
- logmsg "550 $testno: no such file\n";
}
return 0;
}
sendcontrol "125 Gimme gimme gimme!\r\n";
- logmsg "retrieve STOR data on data connection\n";
-
open(FILE, ">$filename") ||
return 0; # failed to open output
my $ulsize=0;
my $disc=0;
while (5 == (sysread DREAD, $line, 5)) {
- logmsg "command from sockfilt: $line";
if($line eq "DATA\n") {
my $i;
sysread DREAD, $i, 5;
}
elsif($line eq "DISC\n") {
# disconnect!
- logmsg "DISC means disconnect!\n";
$disc=1;
last;
}
# EPRT |2|::1|49706|
elsif(($cmd eq "EPRT") && ($grok_eprt)) {
if($arg !~ /(\d+)\|([^\|]+)\|(\d+)/) {
- logmsg "bad EPRT-line: $arg\n";
sendcontrol "500 silly you, go away\r\n";
return 0;
}
$port = $3;
}
else {
- logmsg "got a $cmd line we don't like\n";
sendcontrol "500 we don't like $cmd now\r\n";
return 0;
}
unless (m/^([A-Z]{3,4})\s?(.*)/i) {
sendcontrol "500 '$_': command not understood.\r\n";
- logmsg "unknown crap received: $_, bailing out hard\n";
last;
}
my $FTPCMD=$1;