aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Reschke <lukas@owncloud.com>2014-12-05 19:57:06 +0100
committerMorris Jobke <hey@morrisjobke.de>2014-12-11 00:09:55 +0100
commit9ea205dc3dd27f6e2506a4867e29b12180251620 (patch)
treee063d01f8b4be75e3bf823928dbd53d06b51f2f9
parentd84a1f6f3ae380d42dbd2970d6b3bfedd5e01200 (diff)
downloadnextcloud-server-9ea205dc3dd27f6e2506a4867e29b12180251620.tar.gz
nextcloud-server-9ea205dc3dd27f6e2506a4867e29b12180251620.zip
Check if open_basedir is set
The file:// protocol does not work with curl when an open_basedir is set. This fixes https://github.com/owncloud/core/issues/12016
-rw-r--r--core/setup/controller.php52
-rw-r--r--lib/base.php2
-rw-r--r--lib/private/largefilehelper.php2
-rw-r--r--lib/private/server.php6
-rw-r--r--tests/lib/largefilehelpergetfilesize.php9
5 files changed, 60 insertions, 11 deletions
diff --git a/core/setup/controller.php b/core/setup/controller.php
index 5a52b18f73b..ab4c351b1a0 100644
--- a/core/setup/controller.php
+++ b/core/setup/controller.php
@@ -9,13 +9,21 @@
namespace OC\Core\Setup;
+use bantu\IniGetWrapper\IniGetWrapper;
use OCP\IConfig;
+use OCP\IL10N;
class Controller {
/**
* @var \OCP\IConfig
*/
protected $config;
+ /** @var IniGetWrapper */
+ protected $iniWrapper;
+ /** @var IL10N */
+ protected $l10n;
+ /** @var \OC_Defaults */
+ protected $defaults;
/**
* @var string
@@ -24,12 +32,24 @@ class Controller {
/**
* @param IConfig $config
+ * @param IniGetWrapper $iniWrapper
+ * @param IL10N $l10n
+ * @param \OC_Defaults $defaults
*/
- function __construct(IConfig $config) {
+ function __construct(IConfig $config,
+ IniGetWrapper $iniWrapper,
+ IL10N $l10n,
+ \OC_Defaults $defaults) {
$this->autoConfigFile = \OC::$SERVERROOT.'/config/autoconfig.php';
$this->config = $config;
+ $this->iniWrapper = $iniWrapper;
+ $this->l10n = $l10n;
+ $this->defaults = $defaults;
}
+ /**
+ * @param $post
+ */
public function run($post) {
// Check for autosetup:
$post = $this->loadAutoConfig($post);
@@ -138,16 +158,36 @@ class Controller {
}
}
+
if (\OC_Util::runningOnMac()) {
- $l10n = \OC::$server->getL10N('core');
- $theme = new \OC_Defaults();
$errors[] = array(
- 'error' => $l10n->t(
+ 'error' => $this->l10n->t(
'Mac OS X is not supported and %s will not work properly on this platform. ' .
'Use it at your own risk! ',
- $theme->getName()
+ $this->defaults->getName()
+ ),
+ 'hint' => $this->l10n->t('For the best results, please consider using a GNU/Linux server instead.')
+ );
+ }
+
+ if($this->iniWrapper->getString('open_basedir') !== '' && PHP_INT_SIZE === 4) {
+ $errors[] = array(
+ 'error' => $this->l10n->t(
+ 'It seems that this %s instance is running on a 32bit PHP environment and the open_basedir has been configured in php.ini. ' .
+ 'This will lead to problems with files over 4GB and is highly discouraged.',
+ $this->defaults->getName()
+ ),
+ 'hint' => $this->l10n->t('Please remove the open_basedir setting within your php.ini or switch to 64bit PHP.')
+ );
+ }
+ if(!function_exists('curl_init') && PHP_INT_SIZE === 4) {
+ $errors[] = array(
+ 'error' => $this->l10n->t(
+ 'It seems that this %s instance is running on a 32bit PHP environment and cURL is not installed. ' .
+ 'This will lead to problems with files over 4GB and is highly discouraged.',
+ $this->defaults->getName()
),
- 'hint' => $l10n->t('For the best results, please consider using a GNU/Linux server instead.')
+ 'hint' => $this->l10n->t('Please install the cURL extension and restart your webserver.')
);
}
diff --git a/lib/base.php b/lib/base.php
index af2474c7d76..f2ff3bb4849 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -717,7 +717,7 @@ class OC {
// Check if ownCloud is installed or in maintenance (update) mode
if (!$systemConfig->getValue('installed', false)) {
\OC::$server->getSession()->clear();
- $controller = new OC\Core\Setup\Controller(\OC::$server->getConfig());
+ $controller = new OC\Core\Setup\Controller(\OC::$server->getConfig(), \OC::$server->getIniWrapper(), \OC::$server->getL10N('core'), new \OC_Defaults());
$controller->run($_POST);
exit();
}
diff --git a/lib/private/largefilehelper.php b/lib/private/largefilehelper.php
index 750ba1d23de..b6a8c536e9b 100644
--- a/lib/private/largefilehelper.php
+++ b/lib/private/largefilehelper.php
@@ -100,7 +100,7 @@ class LargeFileHelper {
* null on failure.
*/
public function getFileSizeViaCurl($filename) {
- if (function_exists('curl_init')) {
+ if (function_exists('curl_init') && \OC::$server->getIniWrapper()->getString('open_basedir') === '') {
$fencoded = rawurlencode($filename);
$ch = curl_init("file://$fencoded");
curl_setopt($ch, CURLOPT_NOBODY, true);
diff --git a/lib/private/server.php b/lib/private/server.php
index c0606fc4fe6..4107a0eeec8 100644
--- a/lib/private/server.php
+++ b/lib/private/server.php
@@ -286,7 +286,7 @@ class Server extends SimpleContainer implements IServerContainer {
return new \OC\Files\Config\MountProviderCollection($loader);
});
$this->registerService('IniWrapper', function ($c) {
- return new IniGetWrapper();
+ return new IniGetWrapper();
});
}
@@ -730,9 +730,9 @@ class Server extends SimpleContainer implements IServerContainer {
/**
* Get the IniWrapper
*
- * @return \bantu\IniGetWrapper\IniGetWrapper
+ * @return IniGetWrapper
*/
public function getIniWrapper() {
- return $this->query('IniWrapper');
+ return $this->query('IniWrapper');
}
}
diff --git a/tests/lib/largefilehelpergetfilesize.php b/tests/lib/largefilehelpergetfilesize.php
index c97b7b32b0f..57bc2381966 100644
--- a/tests/lib/largefilehelpergetfilesize.php
+++ b/tests/lib/largefilehelpergetfilesize.php
@@ -13,6 +13,10 @@ namespace Test;
* Large files are not considered yet.
*/
class LargeFileHelperGetFileSize extends TestCase {
+ /** @var string */
+ protected $filename;
+ /** @var int */
+ protected $fileSize;
/** @var \OC\LargeFileHelper */
protected $helper;
@@ -41,6 +45,11 @@ class LargeFileHelperGetFileSize extends TestCase {
'The PHP curl extension is required for this test.'
);
}
+ if (\OC::$server->getIniWrapper()->getString('open_basedir') !== '') {
+ $this->markTestSkipped(
+ 'The PHP curl extension does not work with the file:// protocol when open_basedir is enabled.'
+ );
+ }
$this->assertSame(
$fileSize,
$this->helper->getFileSizeViaCurl($filename)