Commit 4f2e6e35 authored by Sebastian Kummer's avatar Sebastian Kummer

Merge pull request #159 in ZP/z-push from bugfix/ZP-845-improve-utils-fixfileowner to develop

* commit '01358ff4':
  ZP-845 Improve Utils::FixFileOwner.

(cherry picked from commit fc5bc5d3)
parent 55edf8a1
...@@ -886,11 +886,16 @@ class Utils { ...@@ -886,11 +886,16 @@ class Utils {
if(posix_getuid() == 0 && file_exists($file)) { if(posix_getuid() == 0 && file_exists($file)) {
$dir = dirname($file); $dir = dirname($file);
$perm_dir = stat($dir); $perm_dir = stat($dir);
$perm_log = stat($file); $perm_file = stat($file);
if($perm_dir[4] !== $perm_log[4] || $perm_dir[5] !== $perm_log[5]) { if ($perm_file['uid'] == 0 && $perm_dir['uid'] == 0) {
chown($file, $perm_dir[4]); unlink($file);
chgrp($file, $perm_dir[5]); throw new FatalException("FixFileOwner: $dir must be owned by the nginx/apache/php user instead of root");
}
if($perm_dir['uid'] !== $perm_file['uid'] || $perm_dir['gid'] !== $perm_file['gid']) {
chown($file, $perm_dir['uid']);
chgrp($file, $perm_dir['gid']);
} }
} }
return true; return true;
...@@ -984,4 +989,4 @@ function w2ui($string) { return windows1252_to_utf8($string, "//TRANSLIT"); } ...@@ -984,4 +989,4 @@ function w2ui($string) { return windows1252_to_utf8($string, "//TRANSLIT"); }
function u2wi($string) { return utf8_to_windows1252($string, "//TRANSLIT"); } function u2wi($string) { return utf8_to_windows1252($string, "//TRANSLIT"); }
?> ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment