Skip to content
Snippets Groups Projects
Commit ea2f96f6 authored by Andjelko Horvat's avatar Andjelko Horvat
Browse files

Add SimpleSAML_Utilities::isWindowsOS and chmod file in...

Add SimpleSAML_Utilities::isWindowsOS and chmod file in SimpleSAML_Utilities::writeFile() (issue #469).

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@3015 44740490-163a-0410-bde0-09ae8108e29a
parent 44f99376
No related branches found
No related tags found
No related merge requests found
...@@ -23,7 +23,7 @@ class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_Loggin ...@@ -23,7 +23,7 @@ class SimpleSAML_Logger_LoggingHandlerSyslog implements SimpleSAML_Logger_Loggin
* OS Check * OS Check
* Setting facility to LOG_USER (only valid in Windows), enable log level rewrite on windows systems. * 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; $this->isWindows = true;
$facility = LOG_USER; $facility = LOG_USER;
} }
......
...@@ -1937,6 +1937,15 @@ class SimpleSAML_Utilities { ...@@ -1937,6 +1937,15 @@ class SimpleSAML_Utilities {
': ' . SimpleSAML_Utilities::getLastError()); ': ' . 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); $res = rename($tmpFile, $filename);
if ($res === FALSE) { if ($res === FALSE) {
unlink($tmpFile); unlink($tmpFile);
...@@ -2258,4 +2267,14 @@ class SimpleSAML_Utilities { ...@@ -2258,4 +2267,14 @@ class SimpleSAML_Utilities {
return $clear; 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';
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment