Allow metarefresh module to specify the permissions of the resulting files, overriding the default 0600. Contributed by Dick Visser.
git-svn-id: http://simplesamlphp.googlecode.com/svn/trunk@3260 44740490-163a-0410-bde0-09ae8108e29a
This commit is contained in:
parent
0c1d9d7bcb
commit
bba9ee7fcb
|
@ -1972,9 +1972,10 @@ class SimpleSAML_Utilities {
|
|||
* @param string $filename The name of the file.
|
||||
* @param string $data The data we should write to the file.
|
||||
*/
|
||||
public static function writeFile($filename, $data) {
|
||||
public static function writeFile($filename, $data, $mode=0600) {
|
||||
assert('is_string($filename)');
|
||||
assert('is_string($data)');
|
||||
assert('is_numeric($mode)');
|
||||
|
||||
$tmpFile = $filename . '.new.' . getmypid() . '.' . php_uname('n');
|
||||
|
||||
|
@ -1985,7 +1986,7 @@ class SimpleSAML_Utilities {
|
|||
}
|
||||
|
||||
if (!self::isWindowsOS()) {
|
||||
$res = chmod($tmpFile, 0600);
|
||||
$res = chmod($tmpFile, $mode);
|
||||
if ($res === FALSE) {
|
||||
unlink($tmpFile);
|
||||
throw new SimpleSAML_Error_Exception('Error changing file mode ' . $tmpFile .
|
||||
|
|
|
@ -230,7 +230,8 @@ class sspmod_metarefresh_MetaLoader {
|
|||
$this->stateFile,
|
||||
"<?php\n/* This file was generated by the metarefresh module at ".$this->getTime() . ".\n".
|
||||
" Do not update it manually as it will get overwritten. */\n".
|
||||
'$state = ' . var_export($this->state, TRUE) . ";\n?>\n"
|
||||
'$state = ' . var_export($this->state, TRUE) . ";\n?>\n",
|
||||
0644
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +381,7 @@ class sspmod_metarefresh_MetaLoader {
|
|||
|
||||
$content .= "\n" . '?>';
|
||||
|
||||
SimpleSAML_Utilities::writeFile($filename, $content);
|
||||
SimpleSAML_Utilities::writeFile($filename, $content, 0644);
|
||||
} elseif(is_file($filename)) {
|
||||
if(unlink($filename)) {
|
||||
SimpleSAML_Logger::debug('Deleting stale metadata file: ' . $filename);
|
||||
|
@ -443,4 +444,4 @@ class sspmod_metarefresh_MetaLoader {
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
Reference in New Issue