aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars <winnetou+github@catolic.de>2015-12-24 00:20:30 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-01-11 11:50:31 +0100
commit3a5087ccdff79012a6c14adb63dbaa2e61607f2d (patch)
tree605286c84b0d11cb84594db64643b9f925bcf877
parent05f9b4041942794eab74328b95bfbf04c7c9e203 (diff)
downloadnextcloud-server-3a5087ccdff79012a6c14adb63dbaa2e61607f2d.tar.gz
nextcloud-server-3a5087ccdff79012a6c14adb63dbaa2e61607f2d.zip
tempnam accepts a directory as its first parameter, not a full path and filename.
tempnam falls back to creating a file in the system's temp directory. On systems with open_basedir restrictions, this may trigger an error message. By moving this below the checkTemporaryDirectory-loop, tempnam will only be tested if all alternatives fail and the error message is most likely avoided.
-rw-r--r--lib/private/tempmanager.php11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/private/tempmanager.php b/lib/private/tempmanager.php
index c4fa9231eb6..ae7b9c98e33 100644
--- a/lib/private/tempmanager.php
+++ b/lib/private/tempmanager.php
@@ -225,11 +225,6 @@ class TempManager implements ITempManager {
if ($temp = getenv('TMPDIR')) {
$directories[] = $temp;
}
- $temp = tempnam(__FILE__, '');
- if (file_exists($temp)) {
- unlink($temp);
- $directories[] = dirname($temp);
- }
if ($temp = sys_get_temp_dir()) {
$directories[] = $temp;
}
@@ -239,6 +234,12 @@ class TempManager implements ITempManager {
return $dir;
}
}
+
+ $temp = tempnam(dirname(__FILE__), '');
+ if (file_exists($temp)) {
+ unlink($temp);
+ return dirname($temp);
+ }
throw new \UnexpectedValueException('Unable to detect system temporary directory');
}