summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHendrik Langer <hendrik.langer@gmx.de>2011-10-19 23:38:35 +0200
committerHendrik Langer <hendrik.langer@gmx.de>2011-10-19 23:38:35 +0200
commit466b41c36bf7093cdde9d2856eb520503f52640c (patch)
tree6456918f3f142f0ade1370ffb948fa9ffc59a267 /lib
parentda8d32ae38acdab576a30ca56b30579f427c780d (diff)
downloadnextcloud-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 'lib')
-rw-r--r--lib/base.php25
-rw-r--r--lib/db.php4
-rw-r--r--lib/files.php6
-rw-r--r--lib/filestorage/local.php2
-rw-r--r--lib/filestorage/remote.php2
-rw-r--r--lib/installer.php4
-rw-r--r--lib/remote/cloud.php8
7 files changed, 26 insertions, 25 deletions
diff --git a/lib/base.php b/lib/base.php
index 8adb1cc9102..d5fff1e0a74 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -186,18 +186,19 @@ if( !isset( $RUNTIME_NOAPPS )){
OC::init();
-if(!function_exists('sys_get_temp_dir')) {
- function sys_get_temp_dir() {
- if( $temp=getenv('TMP') ) return $temp;
- if( $temp=getenv('TEMP') ) return $temp;
- if( $temp=getenv('TMPDIR') ) return $temp;
- $temp=tempnam(__FILE__,'');
- if (file_exists($temp)) {
- unlink($temp);
- return dirname($temp);
- }
- return null;
- }
+if(!function_exists('get_temp_dir')) {
+ function get_temp_dir() {
+ if( $temp=ini_get('upload_tmp_dir') ) return $temp;
+ if( $temp=getenv('TMP') ) return $temp;
+ if( $temp=getenv('TEMP') ) return $temp;
+ if( $temp=getenv('TMPDIR') ) return $temp;
+ $temp=tempnam(__FILE__,'');
+ if (file_exists($temp)) {
+ unlink($temp);
+ return dirname($temp);
+ }
+ return null;
+ }
}
require_once('fakedirstream.php');
diff --git a/lib/db.php b/lib/db.php
index bcfda4592f2..44be619fde1 100644
--- a/lib/db.php
+++ b/lib/db.php
@@ -285,7 +285,7 @@ class OC_DB {
$content = file_get_contents( $file );
// Make changes and save them to a temporary file
- $file2 = tempnam( sys_get_temp_dir(), 'oc_db_scheme_' );
+ $file2 = tempnam( get_temp_dir(), 'oc_db_scheme_' );
$content = str_replace( '*dbname*', $CONFIG_DBNAME, $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
if( $CONFIG_DBTYPE == 'pgsql' ){ //mysql support it too but sqlite don't
@@ -392,7 +392,7 @@ class OC_DB {
$content = file_get_contents( $file );
// Make changes and save them to a temporary file
- $file2 = tempnam( sys_get_temp_dir(), 'oc_db_scheme_' );
+ $file2 = tempnam( get_temp_dir(), 'oc_db_scheme_' );
$content = str_replace( '*dbname*', $CONFIG_DBNAME, $content );
$content = str_replace( '*dbprefix*', $CONFIG_DBTABLEPREFIX, $content );
file_put_contents( $file2, $content );
diff --git a/lib/files.php b/lib/files.php
index 631726bf9b5..88b559059f0 100644
--- a/lib/files.php
+++ b/lib/files.php
@@ -91,7 +91,7 @@ class OC_Files {
if(is_array($files)){
$zip = new ZipArchive();
- $filename = sys_get_temp_dir()."/ownCloud.zip";
+ $filename = get_temp_dir()."/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
@@ -108,7 +108,7 @@ class OC_Files {
$zip->close();
}elseif(OC_Filesystem::is_dir($dir.'/'.$files)){
$zip = new ZipArchive();
- $filename = sys_get_temp_dir()."/ownCloud.zip";
+ $filename = get_temp_dir()."/ownCloud.zip";
if ($zip->open($filename, ZIPARCHIVE::CREATE)!==TRUE) {
exit("cannot open <$filename>\n");
}
@@ -271,7 +271,7 @@ class OC_Files {
* @return string guessed mime type
*/
static function pull($source,$token,$dir,$file){
- $tmpfile=tempnam(sys_get_temp_dir(),'remoteCloudFile');
+ $tmpfile=tempnam(get_temp_dir(),'remoteCloudFile');
$fp=fopen($tmpfile,'w+');
$url=$source.="/files/pull.php?token=$token";
$ch=curl_init();
diff --git a/lib/filestorage/local.php b/lib/filestorage/local.php
index 8e0907f8d3b..8db0ffead4e 100644
--- a/lib/filestorage/local.php
+++ b/lib/filestorage/local.php
@@ -161,7 +161,7 @@ class OC_Filestorage_Local extends OC_Filestorage{
}
public function toTmpFile($path){
- $tmpFolder=sys_get_temp_dir();
+ $tmpFolder=get_temp_dir();
$filename=tempnam($tmpFolder,'OC_TEMP_FILE_'.substr($path,strrpos($path,'.')));
$fileStats = stat($this->datadir.$path);
if(copy($this->datadir.$path,$filename)){
diff --git a/lib/filestorage/remote.php b/lib/filestorage/remote.php
index fb14c4121a2..88bdbca481c 100644
--- a/lib/filestorage/remote.php
+++ b/lib/filestorage/remote.php
@@ -211,7 +211,7 @@ class OC_Filestorage_Remote extends OC_Filestorage{
$parent=dirname($path);
$name=substr($path,strlen($parent)+1);
$file=$this->remote->getFile($parent,$name);
- $file=tempnam(sys_get_temp_dir(),'oc_');
+ $file=tempnam(get_temp_dir(),'oc_');
file_put_contents($file,$data);
if($return=$this->remote->sendTmpFile($file,$parent,$name)){
$this->notifyObservers($path,OC_FILEACTION_WRITE);
diff --git a/lib/installer.php b/lib/installer.php
index 242ca97934f..9248f68e011 100644
--- a/lib/installer.php
+++ b/lib/installer.php
@@ -62,7 +62,7 @@ class OC_Installer{
//download the file if necesary
if($data['source']=='http'){
- $path=tempnam(sys_get_temp_dir(),'oc_installer_');
+ $path=tempnam(get_temp_dir(),'oc_installer_');
if(!isset($data['href'])){
OC_Log::write('core','No href specified when installing app from http',OC_Log::ERROR);
return false;
@@ -77,7 +77,7 @@ class OC_Installer{
}
//extract the archive in a temporary folder
- $extractDir=tempnam(sys_get_temp_dir(),'oc_installer_uncompressed_');
+ $extractDir=tempnam(get_temp_dir(),'oc_installer_uncompressed_');
unlink($extractDir);
mkdir($extractDir);
$zip = new ZipArchive;
diff --git a/lib/remote/cloud.php b/lib/remote/cloud.php
index 75d60155d06..a9c74e8bf5f 100644
--- a/lib/remote/cloud.php
+++ b/lib/remote/cloud.php
@@ -17,7 +17,7 @@ class OC_REMOTE_CLOUD{
*/
private function apiCall($action,$parameters=false,$assoc=false){
if(!$this->cookiefile){
- $this->cookiefile=sys_get_temp_dir().'/remoteCloudCookie'.uniqid();
+ $this->cookiefile=get_temp_dir().'/remoteCloudCookie'.uniqid();
}
$url=$this->path.='/files/api.php';
$fields_string="action=$action&";
@@ -168,9 +168,9 @@ class OC_REMOTE_CLOUD{
}
$ch=curl_init();
if(!$this->cookiefile){
- $this->cookiefile=sys_get_temp_dir().'/remoteCloudCookie'.uniqid();
+ $this->cookiefile=get_temp_dir().'/remoteCloudCookie'.uniqid();
}
- $tmpfile=tempnam(sys_get_temp_dir(),'remoteCloudFile');
+ $tmpfile=tempnam(get_temp_dir(),'remoteCloudFile');
$fp=fopen($tmpfile,'w+');
$url=$this->path.="/files/api.php?action=get&dir=$dir&file=$file";
curl_setopt($ch,CURLOPT_URL,$url);
@@ -191,7 +191,7 @@ class OC_REMOTE_CLOUD{
public function sendTmpFile($tmp,$targetDir,$targetFile){
$token=sha1(uniqid().$tmp);
- $file=sys_get_temp_dir().'/'.'remoteCloudFile'.$token;
+ $file=get_temp_dir().'/'.'remoteCloudFile'.$token;
rename($tmp,$file);
if( OC_Config::getValue( "forcessl", false ) or isset($_SERVER['HTTPS']) and $_SERVER['HTTPS'] == 'on') {
$url = "https://". $_SERVER['SERVER_NAME'] . OC::$WEBROOT;