Skip to content

Commit fe2885d

Browse files
vtemiannikic
authored andcommitted
Fixed bug #77765
Set mode 40755 for directories, via FTP stream stat. Because we already manage to CWD into the current directory, we should set 40755 as mode, instead of 40644.
1 parent 09e5223 commit fe2885d

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ PHP NEWS
5858
(Nikita)
5959
. Fixed bug #76717 (var_export() does not create a parsable value for
6060
PHP_INT_MIN). (Nikita)
61+
. Fixed bug #77765 (FTP stream wrapper should set the directory as
62+
executable). (Vlad Temian)
6163

6264
07 Mar 2019, PHP 7.2.16
6365

ext/standard/ftp_fopen_wrapper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,7 @@ static int php_stream_ftp_url_stat(php_stream_wrapper *wrapper, const char *url,
805805
if (result < 200 || result > 299) {
806806
ssb->sb.st_mode |= S_IFREG;
807807
} else {
808-
ssb->sb.st_mode |= S_IFDIR;
808+
ssb->sb.st_mode |= S_IFDIR | S_IXUSR | S_IXGRP | S_IXOTH;
809809
}
810810

811811
php_stream_write_string(stream, "TYPE I\r\n"); /* we need this since some servers refuse to accept SIZE command in ASCII mode */
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
stat() on directory should return 40755 for ftp://
3+
--SKIPIF--
4+
<?php
5+
if (array_search('ftp',stream_get_wrappers()) === FALSE) die("skip ftp wrapper not available.");
6+
if (!function_exists('pcntl_fork')) die("skip pcntl_fork() not available.");
7+
?>
8+
--FILE--
9+
<?php
10+
11+
require __DIR__ . "/../../../ftp/tests/server.inc";
12+
13+
$path = "ftp://localhost:" . $port."/www";
14+
15+
var_dump(stat($path)['mode']);
16+
?>
17+
==DONE==
18+
--EXPECTF--
19+
string(11) "SIZE /www
20+
"
21+
int(16877)
22+
==DONE==

0 commit comments

Comments
 (0)