diff options
author | Hendrik Langer <hendrik.langer@gmx.de> | 2011-10-19 23:38:35 +0200 |
---|---|---|
committer | Hendrik Langer <hendrik.langer@gmx.de> | 2011-10-19 23:38:35 +0200 |
commit | 466b41c36bf7093cdde9d2856eb520503f52640c (patch) | |
tree | 6456918f3f142f0ade1370ffb948fa9ffc59a267 /apps/user_openid/phpmyid.php | |
parent | da8d32ae38acdab576a30ca56b30579f427c780d (diff) | |
download | nextcloud-server-466b41c36bf7093cdde9d2856eb520503f52640c.tar.gz nextcloud-server-466b41c36bf7093cdde9d2856eb520503f52640c.zip |
Don't use sys_get_temp_dir(), as it reports the wrong path in restricted environments
Diffstat (limited to 'apps/user_openid/phpmyid.php')
-rw-r--r-- | apps/user_openid/phpmyid.php | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/apps/user_openid/phpmyid.php b/apps/user_openid/phpmyid.php index d8168c9a10d..c984dc8f5e6 100644 --- a/apps/user_openid/phpmyid.php +++ b/apps/user_openid/phpmyid.php @@ -603,7 +603,7 @@ function test_mode () { $res['gmp'] = 'pass - n/a'; } - // sys_get_temp_dir + // get_temp_dir $res['logfile'] = is_writable($profile['logfile']) ? 'pass' : "warn - log is not writable"; @@ -1374,30 +1374,38 @@ function str_diff_at ($a, $b) { } -if (! function_exists('sys_get_temp_dir') && ini_get('open_basedir') == false) { +if (! function_exists('get_temp_dir')) { /** * Create function if missing * @return string */ -function sys_get_temp_dir () { - $keys = array('TMP', 'TMPDIR', 'TEMP'); - foreach ($keys as $key) { - if (isset($_ENV[$key]) && is_dir($_ENV[$key]) && is_writable($_ENV[$key])) - return realpath($_ENV[$key]); - } + if (ini_get('open_basedir') == false) { + function get_temp_dir () { + $keys = array('TMP', 'TMPDIR', 'TEMP'); + foreach ($keys as $key) { + if (isset($_ENV[$key]) && is_dir($_ENV[$key]) && is_writable($_ENV[$key])) + return realpath($_ENV[$key]); + } - $tmp = tempnam(false, null); - if (file_exists($tmp)) { - $dir = realpath(dirname($tmp)); - unlink($tmp); - return realpath($dir); - } + $tmp = tempnam(false, null); + if (file_exists($tmp)) { + $dir = realpath(dirname($tmp)); + unlink($tmp); + return realpath($dir); + } - return realpath(dirname(__FILE__)); -}} elseif (! function_exists('sys_get_temp_dir')) { -function sys_get_temp_dir () { - return realpath(dirname(__FILE__)); -}} + return realpath(dirname(__FILE__)); + } + } + else { + function get_temp_dir () { + if (isset(ini_get('upload_tmp_dir')) && is_dir(ini_get('upload_tmp_dir')) && is_writable(ini_get('upload_tmp_dir'))) + return ini_get('upload_tmp_dir'); + else + return realpath(dirname(__FILE__)); + } + } +} /** @@ -1694,7 +1702,7 @@ if (! array_key_exists('lifetime', $profile)) { // Set a default log file if (! array_key_exists('logfile', $profile)) - $profile['logfile'] = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $profile['auth_realm'] . '.debug.log'; + $profile['logfile'] = get_temp_dir() . DIRECTORY_SEPARATOR . $profile['auth_realm'] . '.debug.log'; /* |