Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorszaimen <szaimen@e.mail.de>2021-09-17 19:19:22 +0300
committerGitHub <noreply@github.com>2021-09-17 19:19:22 +0300
commit3eb1d23720768d7df5f9340330d9ec76f6e96a51 (patch)
tree08d8e55c29c7e7cbbb8f8aa76488f92d1d0e8b99 /apps
parent62a814f4fbdec485e97e6b55a8320a02ced488bb (diff)
parentd4cc22daadb1f9d2bbf21830c321bed2eb6b0d88 (diff)
Merge pull request #28838 from stefan-schilling/enh/16719-integrity-check-temp-dir
Issue 16719: CheckSetupController.php now checks configured temporary directory for existence and if it's writable
Diffstat (limited to 'apps')
-rw-r--r--apps/settings/lib/Controller/CheckSetupController.php18
-rw-r--r--apps/settings/tests/Controller/CheckSetupControllerTest.php6
2 files changed, 23 insertions, 1 deletions
diff --git a/apps/settings/lib/Controller/CheckSetupController.php b/apps/settings/lib/Controller/CheckSetupController.php
index 3e239c15c1b..251237f252d 100644
--- a/apps/settings/lib/Controller/CheckSetupController.php
+++ b/apps/settings/lib/Controller/CheckSetupController.php
@@ -75,6 +75,7 @@ use OCP\IDateTimeFormatter;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IRequest;
+use OCP\ITempManager;
use OCP\IURLGenerator;
use OCP\Lock\ILockingProvider;
use OCP\Security\ISecureRandom;
@@ -111,6 +112,8 @@ class CheckSetupController extends Controller {
private $iniGetWrapper;
/** @var IDBConnection */
private $connection;
+ /** @var ITempManager */
+ private $tempManager;
public function __construct($AppName,
IRequest $request,
@@ -127,7 +130,8 @@ class CheckSetupController extends Controller {
MemoryInfo $memoryInfo,
ISecureRandom $secureRandom,
IniGetWrapper $iniGetWrapper,
- IDBConnection $connection) {
+ IDBConnection $connection,
+ ITempManager $tempManager) {
parent::__construct($AppName, $request);
$this->config = $config;
$this->clientService = $clientService;
@@ -143,6 +147,7 @@ class CheckSetupController extends Controller {
$this->secureRandom = $secureRandom;
$this->iniGetWrapper = $iniGetWrapper;
$this->connection = $connection;
+ $this->tempManager = $tempManager;
}
/**
@@ -554,6 +559,16 @@ Raw output
return extension_loaded('Zend OPcache');
}
+ private function isTemporaryDirectoryWritable(): bool {
+ try {
+ if (!empty($this->tempManager->getTempBaseDir())) {
+ return true;
+ }
+ } catch (\Exception $e) {
+ }
+ return false;
+ }
+
/**
* Iterates through the configured app roots and
* tests if the subdirectories are owned by the same user than the current user.
@@ -779,6 +794,7 @@ Raw output
CheckUserCertificates::class => ['pass' => $checkUserCertificates->run(), 'description' => $checkUserCertificates->description(), 'severity' => $checkUserCertificates->severity(), 'elements' => $checkUserCertificates->elements()],
'isDefaultPhoneRegionSet' => $this->config->getSystemValueString('default_phone_region', '') !== '',
SupportedDatabase::class => ['pass' => $supportedDatabases->run(), 'description' => $supportedDatabases->description(), 'severity' => $supportedDatabases->severity()],
+ 'temporaryDirectoryWritable' => $this->isTemporaryDirectoryWritable(),
]
);
}
diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php
index 5cfab1ccf2d..1924ddda951 100644
--- a/apps/settings/tests/Controller/CheckSetupControllerTest.php
+++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php
@@ -52,6 +52,7 @@ use OCP\IDateTimeFormatter;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IRequest;
+use OCP\ITempManager;
use OCP\IURLGenerator;
use OCP\Lock\ILockingProvider;
use PHPUnit\Framework\MockObject\MockObject;
@@ -99,6 +100,8 @@ class CheckSetupControllerTest extends TestCase {
private $iniGetWrapper;
/** @var IDBConnection|\PHPUnit\Framework\MockObject\MockObject */
private $connection;
+ /** @var ITempManager|\PHPUnit\Framework\MockObject\MockObject */
+ private $tempManager;
/**
* Holds a list of directories created during tests.
@@ -141,6 +144,7 @@ class CheckSetupControllerTest extends TestCase {
$this->iniGetWrapper = $this->getMockBuilder(IniGetWrapper::class)->getMock();
$this->connection = $this->getMockBuilder(IDBConnection::class)
->disableOriginalConstructor()->getMock();
+ $this->tempManager = $this->getMockBuilder(ITempManager::class)->getMock();
$this->checkSetupController = $this->getMockBuilder(CheckSetupController::class)
->setConstructorArgs([
'settings',
@@ -159,6 +163,7 @@ class CheckSetupControllerTest extends TestCase {
$this->secureRandom,
$this->iniGetWrapper,
$this->connection,
+ $this->tempManager,
])
->setMethods([
'isReadOnlyConfig',
@@ -181,6 +186,7 @@ class CheckSetupControllerTest extends TestCase {
'hasBigIntConversionPendingColumns',
'isMysqlUsedWithoutUTF8MB4',
'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed',
+ 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed',
])->getMock();
}