mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-09 23:11:57 +01:00
special mkdir of links_stream_wrapper, so the entry dirs do not inherit the other read/browse rights from the app dir
This commit is contained in:
parent
2a1d86911b
commit
0080dc39f0
@ -744,32 +744,16 @@ class egw_link extends solink
|
|||||||
{
|
{
|
||||||
echo "<p>attach_file: app='$app', id='$id', tmp_name='$file[tmp_name]', name='$file[name]', size='$file[size]', type='$file[type]', path='$file[path]', ip='$file[ip]', comment='$comment'</p>\n";
|
echo "<p>attach_file: app='$app', id='$id', tmp_name='$file[tmp_name]', name='$file[name]', size='$file[size]', type='$file[type]', path='$file[path]', ip='$file[ip]', comment='$comment'</p>\n";
|
||||||
}
|
}
|
||||||
$app_dir = self::vfs_path($app);
|
|
||||||
|
|
||||||
// we dont want an owner, as this would give rights independent of the apps ACL
|
|
||||||
$current_user = egw_vfs::$user; egw_vfs::$user = 0;
|
|
||||||
|
|
||||||
$Ok = true;
|
|
||||||
if (!file_exists($app_dir))
|
|
||||||
{
|
|
||||||
egw_vfs::$is_root = true;
|
|
||||||
$Ok = mkdir($app_dir,0700,true);
|
|
||||||
if (!$Ok) echo "<p>Can't mkdir($app_dir,0700,true)!</p>\n";
|
|
||||||
egw_vfs::$is_root = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$entry_dir = self::vfs_path($app,$id);
|
$entry_dir = self::vfs_path($app,$id);
|
||||||
if ($Ok && !file_exists($entry_dir))
|
if (file_exists($entry_dir) || ($Ok = mkdir($entry_dir,0,true)))
|
||||||
{
|
|
||||||
$Ok = mkdir($entry_dir,0700);
|
|
||||||
}
|
|
||||||
egw_vfs::$user = $current_user;
|
|
||||||
|
|
||||||
if ($Ok)
|
|
||||||
{
|
{
|
||||||
$Ok = copy($file['tmp_name'],$fname = $entry_dir.'/'.$file['name']) &&
|
$Ok = copy($file['tmp_name'],$fname = $entry_dir.'/'.$file['name']) &&
|
||||||
($stat = links_stream_wrapper::url_stat($fname,0));
|
($stat = links_stream_wrapper::url_stat($fname,0));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
error_log(__METHOD__."($app,$id,$file,$comment) Can't mkdir $entry_dir!");
|
||||||
|
}
|
||||||
// todo: set comment
|
// todo: set comment
|
||||||
|
|
||||||
return $Ok ? -$stat['ino'] : false;
|
return $Ok ? -$stat['ino'] : false;
|
||||||
@ -781,6 +765,7 @@ class egw_link extends solink
|
|||||||
* @param int/string $app > 0: file_id of an attchemnt or $app/$id entry which linked to
|
* @param int/string $app > 0: file_id of an attchemnt or $app/$id entry which linked to
|
||||||
* @param string $id='' id in app
|
* @param string $id='' id in app
|
||||||
* @param string $fname filename
|
* @param string $fname filename
|
||||||
|
* @return boolean/array false on error ($app or $id not found), array with path as key and boolean result of delete
|
||||||
*/
|
*/
|
||||||
static function delete_attached($app,$id='',$fname = '')
|
static function delete_attached($app,$id='',$fname = '')
|
||||||
{
|
{
|
||||||
|
@ -142,6 +142,44 @@ class links_stream_wrapper extends sqlfs_stream_wrapper
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mkdir for links
|
||||||
|
*
|
||||||
|
* Reimplemented as we have no static late binding to allow the extended sqlfs to call our eacl and to set no default rights for entry dirs
|
||||||
|
*
|
||||||
|
* This method is called in response to mkdir() calls on URL paths associated with the wrapper.
|
||||||
|
*
|
||||||
|
* It should attempt to create the directory specified by path.
|
||||||
|
* In order for the appropriate error message to be returned, do not define this method if your wrapper does not support creating directories.
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @param int $mode not used(!), we inherit 005 for /apps/$app and set 000 for /apps/$app/$id
|
||||||
|
* @param int $options Posible values include STREAM_REPORT_ERRORS and STREAM_MKDIR_RECURSIVE, we allways use recursive!
|
||||||
|
* @return boolean TRUE on success or FALSE on failure
|
||||||
|
*/
|
||||||
|
static function mkdir($path,$mode,$options)
|
||||||
|
{
|
||||||
|
|
||||||
|
if($path[0] != '/') $path = parse_url($path,PHP_URL_PATH);
|
||||||
|
|
||||||
|
list(,$apps,$app,$id,$rel_path) = explode('/',$path,5);
|
||||||
|
|
||||||
|
$ret = false;
|
||||||
|
if ($apps == 'apps' && $app && !$id || self::check_extended_acl($path,egw_vfs::WRITABLE)) // app directory itself is allways ok
|
||||||
|
{
|
||||||
|
egw_vfs::$is_root = true;
|
||||||
|
$current_user = egw_vfs::$user; egw_vfs::$user = 0;
|
||||||
|
|
||||||
|
$ret = parent::mkdir($path,0,$options|STREAM_MKDIR_RECURSIVE);
|
||||||
|
if ($id) parent::chmod($path,0); // no other rights
|
||||||
|
|
||||||
|
egw_vfs::$user = $current_user;
|
||||||
|
egw_vfs::$is_root = false;
|
||||||
|
}
|
||||||
|
//error_log(__METHOD__."($path,$mode,$options) apps=$apps, app=$app, id=$id: returning $ret");
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_register_wrapper(links_stream_wrapper::SCHEME ,'links_stream_wrapper');
|
stream_register_wrapper(links_stream_wrapper::SCHEME ,'links_stream_wrapper');
|
||||||
|
Loading…
Reference in New Issue
Block a user