From 0bc1ebe5bfc9532b85e22539fdf4a24f06d1dda8 Mon Sep 17 00:00:00 2001 From: Michael Date: Sat, 13 Mar 2021 11:37:11 +0000 Subject: [PATCH] Only set file permissions when configured --- src/Module/Proxy.php | 9 +++++++-- static/defaults.config.php | 6 +++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Module/Proxy.php b/src/Module/Proxy.php index 10ddd56334..735048a867 100644 --- a/src/Module/Proxy.php +++ b/src/Module/Proxy.php @@ -127,13 +127,16 @@ class Proxy extends BaseModule } $basepath = $a->getBasePath(); + $filepermission = DI::config()->get('system', 'proxy_file_chmod'); // Store original image if ($direct_cache) { // direct cache , store under ./proxy/ $filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true); file_put_contents($filename, $image->asString()); - chmod($filename, DI::config()->get('system', 'proxy_file_chmod')); + if (!empty($filepermission)) { + chmod($filename, $filepermission); + } } elseif($cachefile !== '') { // cache file file_put_contents($cachefile, $image->asString()); @@ -153,7 +156,9 @@ class Proxy extends BaseModule if ($direct_cache && $request['sizetype'] != '') { $filename = $basepath . '/proxy/' . ProxyUtils::proxifyUrl($request['url'], true) . $request['sizetype']; file_put_contents($filename, $image->asString()); - chmod($filename, DI::config()->get('system', 'proxy_file_chmod')); + if (!empty($filepermission)) { + chmod($filename, $filepermission); + } } self::responseImageHttpCache($image); diff --git a/static/defaults.config.php b/static/defaults.config.php index b075db36a0..ce9dd477aa 100644 --- a/static/defaults.config.php +++ b/static/defaults.config.php @@ -571,9 +571,9 @@ return [ // Timeout in seconds for fetching the XRD links. 'xrd_timeout' => 20, - // proxy_file_chmod (Integer) - // Access rights for downloaded files in /proxy/ directory - 'proxy_file_chmod' => 0640, + // proxy_file_chmod (Octal Integer) + // Access rights for downloaded files in /proxy/ directory like 0640 + 'proxy_file_chmod' => 0, ], 'experimental' => [ // exp_themes (Boolean)