Merge pull request #10040 from annando/file-permissions

Only set file permissions when configured
This commit is contained in:
Hypolite Petovan 2021-03-13 07:19:30 -05:00 committed by GitHub
commit e8929efbea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

View File

@ -127,13 +127,16 @@ class Proxy extends BaseModule
} }
$basepath = $a->getBasePath(); $basepath = $a->getBasePath();
$filepermission = DI::config()->get('system', 'proxy_file_chmod');
// Store original image // Store original image
if ($direct_cache) { if ($direct_cache) {
// direct cache , store under ./proxy/ // direct cache , store under ./proxy/
$filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true); $filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true);
file_put_contents($filename, $image->asString()); file_put_contents($filename, $image->asString());
chmod($filename, DI::config()->get('system', 'proxy_file_chmod')); if (!empty($filepermission)) {
chmod($filename, $filepermission);
}
} elseif($cachefile !== '') { } elseif($cachefile !== '') {
// cache file // cache file
file_put_contents($cachefile, $image->asString()); file_put_contents($cachefile, $image->asString());
@ -153,7 +156,9 @@ class Proxy extends BaseModule
if ($direct_cache && $request['sizetype'] != '') { if ($direct_cache && $request['sizetype'] != '') {
$filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true) . $request['sizetype']; $filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true) . $request['sizetype'];
file_put_contents($filename, $image->asString()); file_put_contents($filename, $image->asString());
chmod($filename, DI::config()->get('system', 'proxy_file_chmod')); if (!empty($filepermission)) {
chmod($filename, $filepermission);
}
} }
self::responseImageHttpCache($image); self::responseImageHttpCache($image);

View File

@ -571,9 +571,9 @@ return [
// Timeout in seconds for fetching the XRD links. // Timeout in seconds for fetching the XRD links.
'xrd_timeout' => 20, 'xrd_timeout' => 20,
// proxy_file_chmod (Integer) // proxy_file_chmod (Octal Integer like 0640)
// Access rights for downloaded files in /proxy/ directory // If set, defines the files permissions for downloaded files in the /proxy/ directory, default is system-dependent
'proxy_file_chmod' => 0640, 'proxy_file_chmod' => 0,
], ],
'experimental' => [ 'experimental' => [
// exp_themes (Boolean) // exp_themes (Boolean)