aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authormovatica <c0d3@movatica.com>2020-02-18 19:29:53 +0100
committermovatica <c0d3@movatica.com>2020-02-18 19:29:53 +0100
commit3aa75874971939d1a5fde5d5cbca46695cb03af3 (patch)
tree02cdd4bd34eb7fcd3e1e62e6f3d4ec8fb05df563
parentd4f6a7852c473169f2c3998e813e107bc6b0d9e0 (diff)
downloaddokuwiki-3aa75874971939d1a5fde5d5cbca46695cb03af3.tar.gz
dokuwiki-3aa75874971939d1a5fde5d5cbca46695cb03af3.zip
Fixed inconsistent handling of falsy values on fperm setting
The $conf['fperm'] value was checked in multiple files using different methods. This can cause permission trouble with restricted environments, i.e. when chmod is forbidden and file permissions are non-default. Now, all checks use implicit cast to boolean which leads to consistent behaviour. Also, a misleading variable was renamed in context to better understand one of the checks.
-rw-r--r--inc/Search/Indexer.php4
-rw-r--r--inc/init.php2
-rw-r--r--inc/io.php2
-rw-r--r--inc/media.php4
-rw-r--r--lib/plugins/extension/helper/extension.php4
5 files changed, 8 insertions, 8 deletions
diff --git a/inc/Search/Indexer.php b/inc/Search/Indexer.php
index 8770ac794..a29e5b28b 100644
--- a/inc/Search/Indexer.php
+++ b/inc/Search/Indexer.php
@@ -1000,7 +1000,7 @@ class Indexer {
if (!empty($lines))
fwrite($fh, "\n");
fclose($fh);
- if (isset($conf['fperm']))
+ if ($conf['fperm'])
chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');
return true;
@@ -1067,7 +1067,7 @@ class Indexer {
fwrite($fh, $line);
}
fclose($fh);
- if (isset($conf['fperm']))
+ if ($conf['fperm'])
chmod($fn.'.tmp', $conf['fperm']);
io_rename($fn.'.tmp', $fn.'.idx');
return true;
diff --git a/inc/init.php b/inc/init.php
index 69ef6f15a..743356857 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -340,7 +340,7 @@ function init_files(){
$fh = @fopen($file,'a');
if($fh){
fclose($fh);
- if(!empty($conf['fperm'])) chmod($file, $conf['fperm']);
+ if($conf['fperm']) chmod($file, $conf['fperm']);
}else{
nice_die("$file is not writable. Check your permissions settings!");
}
diff --git a/inc/io.php b/inc/io.php
index 18aae25e7..1dfabe845 100644
--- a/inc/io.php
+++ b/inc/io.php
@@ -252,7 +252,7 @@ function _io_saveFile($file, $content, $append) {
fclose($fh);
}
- if(!$fileexists and !empty($conf['fperm'])) chmod($file, $conf['fperm']);
+ if(!$fileexists and $conf['fperm']) chmod($file, $conf['fperm']);
return true;
}
diff --git a/inc/media.php b/inc/media.php
index ec40df5ef..cc29bd16c 100644
--- a/inc/media.php
+++ b/inc/media.php
@@ -2082,7 +2082,7 @@ function media_resize_image($file, $ext, $w, $h=0){
media_resize_imageIM($ext, $file, $info[0], $info[1], $local, $w, $h) ||
media_resize_imageGD($ext, $file, $info[0], $info[1], $local, $w, $h)
) {
- if(!empty($conf['fperm'])) @chmod($local, $conf['fperm']);
+ if($conf['fperm']) @chmod($local, $conf['fperm']);
return $local;
}
//still here? resizing failed
@@ -2149,7 +2149,7 @@ function media_crop_image($file, $ext, $w, $h=0){
if( $mtime > @filemtime($file) ||
media_crop_imageIM($ext,$file,$info[0],$info[1],$local,$cw,$ch,$cx,$cy) ||
media_resize_imageGD($ext,$file,$cw,$ch,$local,$cw,$ch,$cx,$cy) ){
- if(!empty($conf['fperm'])) @chmod($local, $conf['fperm']);
+ if($conf['fperm']) @chmod($local, $conf['fperm']);
return media_resize_image($local,$ext, $w, $h);
}
diff --git a/lib/plugins/extension/helper/extension.php b/lib/plugins/extension/helper/extension.php
index 0186620d0..f5846b75f 100644
--- a/lib/plugins/extension/helper/extension.php
+++ b/lib/plugins/extension/helper/extension.php
@@ -1238,10 +1238,10 @@ class helper_plugin_extension_extension extends DokuWiki_Plugin
closedir($dh);
return $ok;
} else {
- $exists = file_exists($dst);
+ $existed = file_exists($dst);
if (!@copy($src, $dst)) return false;
- if (!$exists && !empty($conf['fperm'])) chmod($dst, $conf['fperm']);
+ if (!$existed && $conf['fperm']) chmod($dst, $conf['fperm']);
@touch($dst, filemtime($src));
}