Commit 699e39d1 authored by skummer's avatar skummer

ZP-304 #comment check file ownership after touching log files #time 40m

git-svn-id: https://z-push.org/svn/z-push/trunk@1630 b7dd7b3b-3a3c-0410-9da9-bee62a6cc5b5
parent 1f795b8b
...@@ -236,6 +236,10 @@ class ZPush { ...@@ -236,6 +236,10 @@ class ZPush {
if (!touch(LOGERRORFILE)) if (!touch(LOGERRORFILE))
throw new FatalMisconfigurationException("The configured LOGERRORFILE can not be modified."); throw new FatalMisconfigurationException("The configured LOGERRORFILE can not be modified.");
// check ownership on the (eventually) just created files
self::checkFileOwner(LOGFILE);
self::checkFileOwner(LOGERRORFILE);
// set time zone // set time zone
// code contributed by Robert Scheck (rsc) - more information: https://developer.berlios.de/mantis/view.php?id=479 // code contributed by Robert Scheck (rsc) - more information: https://developer.berlios.de/mantis/view.php?id=479
if(function_exists("date_default_timezone_set")) { if(function_exists("date_default_timezone_set")) {
...@@ -806,5 +810,29 @@ END; ...@@ -806,5 +810,29 @@ END;
return $defcapa; return $defcapa;
} }
/**
* Checks if a file has the same owner and group as the parent directory.
* If not, owner and group are updated.
* Function code contributed by Robert Scheck aka rsc.
*
* @param string $file
*
* @access private
* @return boolean
*/
static private function checkFileOwner($file) {
if(posix_getuid() == 0 && file_exists($file)) {
$dir = dirname($file);
$perm_dir = stat($dir);
$perm_log = stat($file);
if($perm_dir[4] !== $perm_log[4] || $perm_dir[5] !== $perm_log[5]) {
chown($file, $perm_dir[4]);
chgrp($file, $perm_dir[5]);
}
}
return true;
}
} }
?> ?>
\ 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