forked from extern/egroupware
got symlinks working for filesystem streamwrapper and fix one bug in Vfs with symlinks
This commit is contained in:
parent
c4c747899f
commit
6502eaeab8
@ -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))
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -24,6 +24,7 @@ if (!($path = Api\Cache::getSession('filemanger','test')))
|
||||
}
|
||||
if (isset($_REQUEST['path'])) $path = $_REQUEST['path'];
|
||||
echo Api\Html::form("<p>Path: ".Api\Html::input('path',$path,'text','size="40"').
|
||||
Api\Html::input_hidden(['cd'=>'no']).
|
||||
Api\Html::submit_button('',lang('Submit'))."</p>\n",array(),'','','','','GET');
|
||||
|
||||
if (isset($path) && !empty($path))
|
||||
|
Loading…
Reference in New Issue
Block a user