only chmod logfile if necessary

otherwise e.g. on SELinux this will log an error, so we better avoid it if not necessary.
This commit is contained in:
duritong 2017-01-29 00:55:39 +01:00 committed by GitHub
parent b614547ff8
commit dbf4a4b844

View file

@ -116,7 +116,9 @@ class File {
);
$entry = json_encode($entry);
$handle = @fopen(self::$logFile, 'a');
@chmod(self::$logFile, 0640);
if ((fileperms(self::$logFile) & 0777) != 0640) {
@chmod(self::$logFile, 0640);
}
if ($handle) {
fwrite($handle, $entry."\n");
fclose($handle);