diff --git a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php index 562ca12133ccb0aea7806cf3ae528c8aed1b4354..6c7ddfadd371af9c567706ee81d9c43ae0d7fbec 100644 --- a/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php +++ b/lib/SimpleSAML/Logger/LoggingHandlerSyslog.php @@ -23,7 +23,7 @@ class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_Loggin * OS Check * Setting facility to LOG_USER (only valid in Windows), enable log level rewrite on windows systems. */ - if (substr(strtoupper(PHP_OS),0,3) == 'WIN') { + if (SimpleSAML_Utilities::isWindowsOS()) { $this->isWindows = true; $facility = LOG_USER; } diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php index 56ae886f15afe874e8250e30b70e55c0d4fc94a0..cb0170c5cb225ed9c9c3b15beaafecb949fb412d 100644 --- a/lib/SimpleSAML/Utilities.php +++ b/lib/SimpleSAML/Utilities.php @@ -1937,6 +1937,15 @@ class SimpleSAML_Utilities { ': ' . SimpleSAML_Utilities::getLastError()); } + if (!self::isWindowsOS()) { + $res = chmod($tmpFile, 0600); + if ($res === FALSE) { + unlink($tmpFile); + throw new SimpleSAML_Error_Exception('Error changing file mode ' . $tmpFile . + ': ' . SimpleSAML_Utilities::getLastError()); + } + } + $res = rename($tmpFile, $filename); if ($res === FALSE) { unlink($tmpFile); @@ -2258,4 +2267,14 @@ class SimpleSAML_Utilities { return $clear; } + + /** + * This function checks if we are running on Windows OS. + * + * @return TRUE if we are on Windows OS, FALSE otherwise. + */ + public static function isWindowsOS() { + return substr(strtoupper(PHP_OS),0,3) == 'WIN'; + } + }