* API/Admin: fixed SQL error on repairing filesystem, if one of required directories has wrong permissions

This commit is contained in:
Ralf Becker
2014-01-07 09:55:07 +00:00
parent a469a1254b
commit c5191e3e01
3 changed files with 31 additions and 1 deletions

View File

@@ -136,7 +136,7 @@ class sqlfs_utils extends sqlfs_stream_wrapper
$msgs = array();
foreach($dirs as $path => $id)
{
if (!($stat = self::url_stat($path, STREAM_URL_STAT_LINK)) || ($stat['mode'] & 05) != 05)
if (!($stat = self::url_stat($path, STREAM_URL_STAT_LINK)))
{
if ($check_only)
{
@@ -171,6 +171,30 @@ class sqlfs_utils extends sqlfs_stream_wrapper
}
}
}
// check if directory is at least world readable and executable (r-x), we allow more but not less
elseif (($stat['mode'] & 05) != 05)
{
if ($check_only)
{
$msgs[] = lang('Required directory "%1" has wrong mode %2 instead of %3!',
$path, egw_vfs::int2mode($stat['mode']), egw_vfs::int2mode(05|0x4000));
}
else
{
$stmt = self::$pdo->prepare('UPDATE '.self::TABLE.' SET fs_mode=:fs_mode WHERE fs_id=:fs_id');
if (($ok = $stmt->execute(array(
'fs_id' => $id,
'fs_mode' => 05,
))))
{
$msgs[] = lang('Mode of required directory "%1" changed to %2.', $path, egw_vfs::int2mode(05|0x4000));
}
else
{
$msgs[] = lang('Failed to change mode of required directory "%1" to %2!', $path, egw_vfs::int2mode(05|0x4000));
}
}
}
}
if (!$check_only && $msgs)
{