File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2828 'certdir ' => 'cert/ ' ,
2929 'dictionarydir ' => 'dictionaries/ ' ,
3030 'loggingdir ' => 'log/ ' ,
31-
31+
32+ /*
33+ * A directory where simpleSAMLphp can save temporary files.
34+ *
35+ * SimpleSAMLphp will attempt to create this directory if it doesn't exist.
36+ */
37+ 'tempdir ' => '/tmp/simplesaml ' ,
38+
3239 'version ' => 'trunk ' ,
3340
3441 /**
Original file line number Diff line number Diff line change @@ -2027,6 +2027,36 @@ public static function writeFile($filename, $data) {
20272027 }
20282028 }
20292029
2030+
2031+ /**
2032+ * Get temp directory path.
2033+ *
2034+ * This function retrieves the path to a directory where
2035+ * temporary files can be saved.
2036+ *
2037+ * @return string Path to temp directory, without a trailing '/'.
2038+ */
2039+ public static function getTempDir () {
2040+
2041+ $ globalConfig = SimpleSAML_Configuration::getInstance ();
2042+
2043+ $ tempDir = $ globalConfig ->getString ('tempdir ' , '/tmp/simplesaml ' );
2044+
2045+ while (substr ($ tempDir , -1 ) === '/ ' ) {
2046+ $ tempDir = substr ($ tempDir , 0 , -1 );
2047+ }
2048+
2049+ if (!is_dir ($ tempDir )) {
2050+ $ ret = mkdir ($ tempDir , 0700 , TRUE );
2051+ if (!$ ret ) {
2052+ throw new SimpleSAML_Error_Exception ('Error creating temp dir ' .
2053+ var_export ($ tempDir , TRUE ) . ': ' . SimpleSAML_Utilities::getLastError ());
2054+ }
2055+ }
2056+
2057+ return $ tempDir ;
2058+ }
2059+
20302060}
20312061
20322062?>
You can’t perform that action at this time.
0 commit comments