diff --git a/api/src/Vfs/Filesystem/StreamWrapper.php b/api/src/Vfs/Filesystem/StreamWrapper.php index 45e59f1a25..c1d99ef8f6 100644 --- a/api/src/Vfs/Filesystem/StreamWrapper.php +++ b/api/src/Vfs/Filesystem/StreamWrapper.php @@ -54,6 +54,10 @@ class StreamWrapper implements Vfs\StreamWrapperIface */ const DIR_MIME_TYPE = Vfs::DIR_MIME_TYPE ; + /** + * mode-bits, which have to be set for files + */ + const MODE_LINK = 0120000; /** * mode-bits, which have to be set for files */ @@ -298,6 +302,23 @@ class StreamWrapper implements Vfs\StreamWrapperIface return $this->url_stat($this->opened_stream_url,0); } + /** + * This method is called in response to readlink(). + * + * The readlink value is read by url_stat or dir_opendir and therefore cached in the stat-cache. + * + * @param string $path + * @return string|boolean content of the symlink or false if $url is no symlink (or not found) + */ + function readlink($path) + { + if (!($url = Vfs::resolve_url($path))) + { + return false; + } + return readlink(Vfs::parse_url($url, PHP_URL_PATH)); + } + /** * Method called for symlink() * @@ -554,7 +575,7 @@ class StreamWrapper implements Vfs\StreamWrapperIface $parts = Vfs::parse_url($url); $path = Vfs::decodePath($parts['path']); - $stat = @stat($path); // suppressed the stat failed warnings + $stat = $flags & STREAM_URL_STAT_LINK ? @lstat($path) : @stat($path); // suppressed the stat failed warnings if ($stat) { @@ -566,7 +587,8 @@ class StreamWrapper implements Vfs\StreamWrapperIface } $stat['uid'] = $stat[4] = $uid; $stat['gid'] = $stat[5] = $gid; - $stat['mode'] = $stat[2] = $stat['mode'] & self::MODE_DIR ? self::MODE_DIR | $mode : self::MODE_FILE | ($mode & ~0111); + $stat['mode'] = $stat[2] = $stat['mode'] & self::MODE_DIR ? self::MODE_DIR | $mode : + ((($stat['mode'] & self::MODE_LINK) === self::MODE_LINK ? self::MODE_LINK : self::MODE_FILE) | ($mode & ~0111)); // write rights also depend on the write rights of the webserver if (!is_writable($path)) { diff --git a/api/src/Vfs/StreamWrapper.php b/api/src/Vfs/StreamWrapper.php index d12bdfdc9e..f666751eb9 100644 --- a/api/src/Vfs/StreamWrapper.php +++ b/api/src/Vfs/StreamWrapper.php @@ -725,7 +725,7 @@ class StreamWrapper extends Base implements StreamWrapperIface { $stat = @stat($url); // suppressed the stat failed warnings - if ($stat && ($stat['mode'] & self::MODE_LINK)) + if ($stat && ($stat['mode'] & self::MODE_LINK) === self::MODE_LINK) { if (!$check_symlink_depth) { diff --git a/filemanager/test.php b/filemanager/test.php index 416e2edaac..8c95d838e3 100644 --- a/filemanager/test.php +++ b/filemanager/test.php @@ -24,6 +24,7 @@ if (!($path = Api\Cache::getSession('filemanger','test'))) } if (isset($_REQUEST['path'])) $path = $_REQUEST['path']; echo Api\Html::form("
Path: ".Api\Html::input('path',$path,'text','size="40"'). + Api\Html::input_hidden(['cd'=>'no']). Api\Html::submit_button('',lang('Submit'))."
\n",array(),'','','','','GET'); if (isset($path) && !empty($path))