summaryrefslogtreecommitdiff
path: root/ext/ftp/tests/server.inc
diff options
context:
space:
mode:
Diffstat (limited to 'ext/ftp/tests/server.inc')
-rw-r--r--ext/ftp/tests/server.inc38
1 files changed, 38 insertions, 0 deletions
diff --git a/ext/ftp/tests/server.inc b/ext/ftp/tests/server.inc
index ffef025074..1ae52f05b6 100644
--- a/ext/ftp/tests/server.inc
+++ b/ext/ftp/tests/server.inc
@@ -441,6 +441,44 @@ if ($pid) {
fputs($s, "350 OK\r\n");
}elseif (preg_match('/^SIZE largefile/', $buf)) {
fputs($s, "213 5368709120\r\n");
+ }elseif (preg_match('/^MLSD no_exists\//', $buf, $matches)) {
+ fputs($s, "425 Error establishing connection\r\n");
+ }elseif (preg_match("~^MLSD(?: ([A-Za-z./]+))?\r\n$~", $buf, $m)) {
+
+ if(isset($m[1]) && (($m[1] === 'bogusdir') || ($m[1] === '/bogusdir'))) {
+ fputs($s, "250 $m[1]: No such file or directory\r\n");
+ continue;
+ }
+
+ // there are some servers that don't open the ftp-data socket if there's nothing to send
+ if(isset($bug39458) && isset($m[1]) && $m[1] === 'emptydir') {
+ fputs($s, "226 Transfer complete.\r\n");
+ continue;
+ }
+
+ if(empty($pasv)) {
+ fputs($s, "150 File status okay; about to open data connection\r\n");
+ if(!$fs = stream_socket_client("tcp://$host:$port")) {
+ fputs($s, "425 Can't open data connection\r\n");
+ continue;
+ }
+ } else {
+ fputs($s, "125 Data connection already open; transfer starting.\r\n");
+ $fs = $pasvs;
+ }
+
+ if((!empty($ssl)) && (!stream_socket_enable_crypto($pasvs, TRUE, STREAM_CRYPTO_METHOD_SSLv23_SERVER))) {
+ die("SSLv23 handshake failed.\n");
+ }
+
+ if(empty($m[1]) || $m[1] !== 'emptydir') {
+ fputs($fs, "modify=20170127230002;perm=flcdmpe;type=cdir;unique=811U4340002;UNIX.group=33;UNIX.mode=0755;UNIX.owner=33; .\r\n");
+ fputs($fs, "modify=20170127230002;perm=flcdmpe;type=pdir;unique=811U4340002;UNIX.group=33;UNIX.mode=0755;UNIX.owner=33; ..\r\n");
+ fputs($fs, "modify=20170126121225;perm=adfrw;size=4729;type=file;unique=811U4340CB9;UNIX.group=33;UNIX.mode=0644;UNIX.owner=33; foobar\r\n");
+ }
+
+ fputs($s, "226 Closing data Connection.\r\n");
+ fclose($fs);
}else {
fputs($s, "500 Syntax error, command unrecognized.\r\n");
dump_and_exit($buf);