CheckSetupController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
  6. * @author Bjoern Schiessle <bjoern@schiessle.org>
  7. * @author Derek <derek.kelly27@gmail.com>
  8. * @author Joas Schilling <coding@schilljs.com>
  9. * @author Ko- <k.stoffelen@cs.ru.nl>
  10. * @author Lukas Reschke <lukas@statuscode.ch>
  11. * @author Morris Jobke <hey@morrisjobke.de>
  12. * @author Robin McCorkell <robin@mccorkell.me.uk>
  13. * @author Roeland Jago Douma <roeland@famdouma.nl>
  14. *
  15. * @license AGPL-3.0
  16. *
  17. * This code is free software: you can redistribute it and/or modify
  18. * it under the terms of the GNU Affero General Public License, version 3,
  19. * as published by the Free Software Foundation.
  20. *
  21. * This program is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU Affero General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU Affero General Public License, version 3,
  27. * along with this program. If not, see <http://www.gnu.org/licenses/>
  28. *
  29. */
  30. namespace OC\Settings\Controller;
  31. use bantu\IniGetWrapper\IniGetWrapper;
  32. use DirectoryIterator;
  33. use Doctrine\DBAL\DBALException;
  34. use Doctrine\DBAL\Platforms\SqlitePlatform;
  35. use Doctrine\DBAL\Types\Type;
  36. use GuzzleHttp\Exception\ClientException;
  37. use OC;
  38. use OC\AppFramework\Http;
  39. use OC\DB\Connection;
  40. use OC\DB\MissingIndexInformation;
  41. use OC\DB\SchemaWrapper;
  42. use OC\IntegrityCheck\Checker;
  43. use OC\Lock\NoopLockingProvider;
  44. use OC\MemoryInfo;
  45. use OCP\AppFramework\Controller;
  46. use OCP\AppFramework\Http\DataDisplayResponse;
  47. use OCP\AppFramework\Http\DataResponse;
  48. use OCP\AppFramework\Http\RedirectResponse;
  49. use OCP\Http\Client\IClientService;
  50. use OCP\IConfig;
  51. use OCP\IDateTimeFormatter;
  52. use OCP\IDBConnection;
  53. use OCP\IL10N;
  54. use OCP\ILogger;
  55. use OCP\IRequest;
  56. use OCP\IURLGenerator;
  57. use OCP\Lock\ILockingProvider;
  58. use OCP\Security\ISecureRandom;
  59. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  60. use Symfony\Component\EventDispatcher\GenericEvent;
  61. /**
  62. * @package OC\Settings\Controller
  63. */
  64. class CheckSetupController extends Controller {
  65. /** @var IConfig */
  66. private $config;
  67. /** @var IClientService */
  68. private $clientService;
  69. /** @var \OC_Util */
  70. private $util;
  71. /** @var IURLGenerator */
  72. private $urlGenerator;
  73. /** @var IL10N */
  74. private $l10n;
  75. /** @var Checker */
  76. private $checker;
  77. /** @var ILogger */
  78. private $logger;
  79. /** @var EventDispatcherInterface */
  80. private $dispatcher;
  81. /** @var IDBConnection|Connection */
  82. private $db;
  83. /** @var ILockingProvider */
  84. private $lockingProvider;
  85. /** @var IDateTimeFormatter */
  86. private $dateTimeFormatter;
  87. /** @var MemoryInfo */
  88. private $memoryInfo;
  89. /** @var ISecureRandom */
  90. private $secureRandom;
  91. public function __construct($AppName,
  92. IRequest $request,
  93. IConfig $config,
  94. IClientService $clientService,
  95. IURLGenerator $urlGenerator,
  96. \OC_Util $util,
  97. IL10N $l10n,
  98. Checker $checker,
  99. ILogger $logger,
  100. EventDispatcherInterface $dispatcher,
  101. IDBConnection $db,
  102. ILockingProvider $lockingProvider,
  103. IDateTimeFormatter $dateTimeFormatter,
  104. MemoryInfo $memoryInfo,
  105. ISecureRandom $secureRandom) {
  106. parent::__construct($AppName, $request);
  107. $this->config = $config;
  108. $this->clientService = $clientService;
  109. $this->util = $util;
  110. $this->urlGenerator = $urlGenerator;
  111. $this->l10n = $l10n;
  112. $this->checker = $checker;
  113. $this->logger = $logger;
  114. $this->dispatcher = $dispatcher;
  115. $this->db = $db;
  116. $this->lockingProvider = $lockingProvider;
  117. $this->dateTimeFormatter = $dateTimeFormatter;
  118. $this->memoryInfo = $memoryInfo;
  119. $this->secureRandom = $secureRandom;
  120. }
  121. /**
  122. * Checks if the server can connect to the internet using HTTPS and HTTP
  123. * @return bool
  124. */
  125. private function isInternetConnectionWorking() {
  126. if ($this->config->getSystemValue('has_internet_connection', true) === false) {
  127. return false;
  128. }
  129. $siteArray = $this->config->getSystemValue('connectivity_check_domains', [
  130. 'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
  131. ]);
  132. foreach($siteArray as $site) {
  133. if ($this->isSiteReachable($site)) {
  134. return true;
  135. }
  136. }
  137. return false;
  138. }
  139. /**
  140. * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
  141. * @return bool
  142. */
  143. private function isSiteReachable($sitename) {
  144. $httpSiteName = 'http://' . $sitename . '/';
  145. $httpsSiteName = 'https://' . $sitename . '/';
  146. try {
  147. $client = $this->clientService->newClient();
  148. $client->get($httpSiteName);
  149. $client->get($httpsSiteName);
  150. } catch (\Exception $e) {
  151. $this->logger->logException($e, ['app' => 'internet_connection_check']);
  152. return false;
  153. }
  154. return true;
  155. }
  156. /**
  157. * Checks whether a local memcache is installed or not
  158. * @return bool
  159. */
  160. private function isMemcacheConfigured() {
  161. return $this->config->getSystemValue('memcache.local', null) !== null;
  162. }
  163. /**
  164. * Whether PHP can generate "secure" pseudorandom integers
  165. *
  166. * @return bool
  167. */
  168. private function isRandomnessSecure() {
  169. try {
  170. $this->secureRandom->generate(1);
  171. } catch (\Exception $ex) {
  172. return false;
  173. }
  174. return true;
  175. }
  176. /**
  177. * Public for the sake of unit-testing
  178. *
  179. * @return array
  180. */
  181. protected function getCurlVersion() {
  182. return curl_version();
  183. }
  184. /**
  185. * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do
  186. * have multiple bugs which likely lead to problems in combination with
  187. * functionality required by ownCloud such as SNI.
  188. *
  189. * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
  190. * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
  191. * @return string
  192. */
  193. private function isUsedTlsLibOutdated() {
  194. // Don't run check when:
  195. // 1. Server has `has_internet_connection` set to false
  196. // 2. AppStore AND S2S is disabled
  197. if(!$this->config->getSystemValue('has_internet_connection', true)) {
  198. return '';
  199. }
  200. if(!$this->config->getSystemValue('appstoreenabled', true)
  201. && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
  202. && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
  203. return '';
  204. }
  205. $versionString = $this->getCurlVersion();
  206. if(isset($versionString['ssl_version'])) {
  207. $versionString = $versionString['ssl_version'];
  208. } else {
  209. return '';
  210. }
  211. $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
  212. if(!$this->config->getSystemValue('appstoreenabled', true)) {
  213. $features = (string)$this->l10n->t('Federated Cloud Sharing');
  214. }
  215. // Check if at least OpenSSL after 1.01d or 1.0.2b
  216. if(strpos($versionString, 'OpenSSL/') === 0) {
  217. $majorVersion = substr($versionString, 8, 5);
  218. $patchRelease = substr($versionString, 13, 6);
  219. if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
  220. ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
  221. return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['OpenSSL', $versionString, $features]);
  222. }
  223. }
  224. // Check if NSS and perform heuristic check
  225. if(strpos($versionString, 'NSS/') === 0) {
  226. try {
  227. $firstClient = $this->clientService->newClient();
  228. $firstClient->get('https://nextcloud.com/');
  229. $secondClient = $this->clientService->newClient();
  230. $secondClient->get('https://nextcloud.com/');
  231. } catch (ClientException $e) {
  232. if($e->getResponse()->getStatusCode() === 400) {
  233. return $this->l10n->t('cURL is using an outdated %1$s version (%2$s). Please update your operating system or features such as %3$s will not work reliably.', ['NSS', $versionString, $features]);
  234. }
  235. }
  236. }
  237. return '';
  238. }
  239. /**
  240. * Whether the version is outdated
  241. *
  242. * @return bool
  243. */
  244. protected function isPhpOutdated() {
  245. if (version_compare(PHP_VERSION, '7.1.0', '<')) {
  246. return true;
  247. }
  248. return false;
  249. }
  250. /**
  251. * Whether the php version is still supported (at time of release)
  252. * according to: https://secure.php.net/supported-versions.php
  253. *
  254. * @return array
  255. */
  256. private function isPhpSupported() {
  257. return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
  258. }
  259. /**
  260. * Check if the reverse proxy configuration is working as expected
  261. *
  262. * @return bool
  263. */
  264. private function forwardedForHeadersWorking() {
  265. $trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
  266. $remoteAddress = $this->request->getHeader('REMOTE_ADDR');
  267. if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies)) {
  268. return $remoteAddress !== $this->request->getRemoteAddress();
  269. }
  270. // either not enabled or working correctly
  271. return true;
  272. }
  273. /**
  274. * Checks if the correct memcache module for PHP is installed. Only
  275. * fails if memcached is configured and the working module is not installed.
  276. *
  277. * @return bool
  278. */
  279. private function isCorrectMemcachedPHPModuleInstalled() {
  280. if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
  281. return true;
  282. }
  283. // there are two different memcached modules for PHP
  284. // we only support memcached and not memcache
  285. // https://code.google.com/p/memcached/wiki/PHPClientComparison
  286. return !(!extension_loaded('memcached') && extension_loaded('memcache'));
  287. }
  288. /**
  289. * Checks if set_time_limit is not disabled.
  290. *
  291. * @return bool
  292. */
  293. private function isSettimelimitAvailable() {
  294. if (function_exists('set_time_limit')
  295. && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
  296. return true;
  297. }
  298. return false;
  299. }
  300. /**
  301. * @return RedirectResponse
  302. */
  303. public function rescanFailedIntegrityCheck() {
  304. $this->checker->runInstanceVerification();
  305. return new RedirectResponse(
  306. $this->urlGenerator->linkToRoute('settings.AdminSettings.index')
  307. );
  308. }
  309. /**
  310. * @NoCSRFRequired
  311. * @return DataResponse
  312. */
  313. public function getFailedIntegrityCheckFiles() {
  314. if(!$this->checker->isCodeCheckEnforced()) {
  315. return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
  316. }
  317. $completeResults = $this->checker->getResults();
  318. if(!empty($completeResults)) {
  319. $formattedTextResponse = 'Technical information
  320. =====================
  321. The following list covers which files have failed the integrity check. Please read
  322. the previous linked documentation to learn more about the errors and how to fix
  323. them.
  324. Results
  325. =======
  326. ';
  327. foreach($completeResults as $context => $contextResult) {
  328. $formattedTextResponse .= "- $context\n";
  329. foreach($contextResult as $category => $result) {
  330. $formattedTextResponse .= "\t- $category\n";
  331. if($category !== 'EXCEPTION') {
  332. foreach ($result as $key => $results) {
  333. $formattedTextResponse .= "\t\t- $key\n";
  334. }
  335. } else {
  336. foreach ($result as $key => $results) {
  337. $formattedTextResponse .= "\t\t- $results\n";
  338. }
  339. }
  340. }
  341. }
  342. $formattedTextResponse .= '
  343. Raw output
  344. ==========
  345. ';
  346. $formattedTextResponse .= print_r($completeResults, true);
  347. } else {
  348. $formattedTextResponse = 'No errors have been found.';
  349. }
  350. $response = new DataDisplayResponse(
  351. $formattedTextResponse,
  352. Http::STATUS_OK,
  353. [
  354. 'Content-Type' => 'text/plain',
  355. ]
  356. );
  357. return $response;
  358. }
  359. /**
  360. * Checks whether a PHP opcache is properly set up
  361. * @return bool
  362. */
  363. protected function isOpcacheProperlySetup() {
  364. $iniWrapper = new IniGetWrapper();
  365. if(!$iniWrapper->getBool('opcache.enable')) {
  366. return false;
  367. }
  368. if(!$iniWrapper->getBool('opcache.save_comments')) {
  369. return false;
  370. }
  371. if(!$iniWrapper->getBool('opcache.enable_cli')) {
  372. return false;
  373. }
  374. if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
  375. return false;
  376. }
  377. if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
  378. return false;
  379. }
  380. if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
  381. return false;
  382. }
  383. return true;
  384. }
  385. /**
  386. * Check if the required FreeType functions are present
  387. * @return bool
  388. */
  389. protected function hasFreeTypeSupport() {
  390. return function_exists('imagettfbbox') && function_exists('imagettftext');
  391. }
  392. protected function hasMissingIndexes(): array {
  393. $indexInfo = new MissingIndexInformation();
  394. // Dispatch event so apps can also hint for pending index updates if needed
  395. $event = new GenericEvent($indexInfo);
  396. $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
  397. return $indexInfo->getListOfMissingIndexes();
  398. }
  399. /**
  400. * warn if outdated version of a memcache module is used
  401. */
  402. protected function getOutdatedCaches(): array {
  403. $caches = [
  404. 'apcu' => ['name' => 'APCu', 'version' => '4.0.6'],
  405. 'redis' => ['name' => 'Redis', 'version' => '2.2.5'],
  406. ];
  407. $outdatedCaches = [];
  408. foreach ($caches as $php_module => $data) {
  409. $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<');
  410. if ($isOutdated) {
  411. $outdatedCaches[] = $data;
  412. }
  413. }
  414. return $outdatedCaches;
  415. }
  416. protected function isSqliteUsed() {
  417. return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
  418. }
  419. protected function isReadOnlyConfig(): bool {
  420. return \OC_Helper::isReadOnlyConfigEnabled();
  421. }
  422. protected function hasValidTransactionIsolationLevel(): bool {
  423. try {
  424. if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
  425. return true;
  426. }
  427. return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED;
  428. } catch (DBALException $e) {
  429. // ignore
  430. }
  431. return true;
  432. }
  433. protected function hasFileinfoInstalled(): bool {
  434. return \OC_Util::fileInfoLoaded();
  435. }
  436. protected function hasWorkingFileLocking(): bool {
  437. return !($this->lockingProvider instanceof NoopLockingProvider);
  438. }
  439. protected function getSuggestedOverwriteCliURL(): string {
  440. $suggestedOverwriteCliUrl = '';
  441. if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
  442. $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
  443. if (!$this->config->getSystemValue('config_is_read_only', false)) {
  444. // Set the overwrite URL when it was not set yet.
  445. $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
  446. $suggestedOverwriteCliUrl = '';
  447. }
  448. }
  449. return $suggestedOverwriteCliUrl;
  450. }
  451. protected function getLastCronInfo(): array {
  452. $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
  453. return [
  454. 'diffInSeconds' => time() - $lastCronRun,
  455. 'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
  456. 'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
  457. ];
  458. }
  459. protected function getCronErrors() {
  460. $errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
  461. if (is_array($errors)) {
  462. return $errors;
  463. }
  464. return [];
  465. }
  466. protected function isPHPMailerUsed(): bool {
  467. return $this->config->getSystemValue('mail_smtpmode', 'smtp') === 'php';
  468. }
  469. protected function hasOpcacheLoaded(): bool {
  470. return function_exists('opcache_get_status');
  471. }
  472. /**
  473. * Iterates through the configured app roots and
  474. * tests if the subdirectories are owned by the same user than the current user.
  475. *
  476. * @return array
  477. */
  478. protected function getAppDirsWithDifferentOwner(): array {
  479. $currentUser = posix_getuid();
  480. $appDirsWithDifferentOwner = [[]];
  481. foreach (OC::$APPSROOTS as $appRoot) {
  482. if ($appRoot['writable'] === true) {
  483. $appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
  484. }
  485. }
  486. $appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
  487. sort($appDirsWithDifferentOwner);
  488. return $appDirsWithDifferentOwner;
  489. }
  490. /**
  491. * Tests if the directories for one apps directory are writable by the current user.
  492. *
  493. * @param int $currentUser The current user
  494. * @param array $appRoot The app root config
  495. * @return string[] The none writable directory paths inside the app root
  496. */
  497. private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
  498. $appDirsWithDifferentOwner = [];
  499. $appsPath = $appRoot['path'];
  500. $appsDir = new DirectoryIterator($appRoot['path']);
  501. foreach ($appsDir as $fileInfo) {
  502. if ($fileInfo->isDir() && !$fileInfo->isDot()) {
  503. $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
  504. $appDirUser = fileowner($absAppPath);
  505. if ($appDirUser !== $currentUser) {
  506. $appDirsWithDifferentOwner[] = $absAppPath;
  507. }
  508. }
  509. }
  510. return $appDirsWithDifferentOwner;
  511. }
  512. /**
  513. * Checks for potential PHP modules that would improve the instance
  514. *
  515. * @return string[] A list of PHP modules that is recommended
  516. */
  517. protected function hasRecommendedPHPModules(): array {
  518. $recommendedPHPModules = [];
  519. if (!function_exists('grapheme_strlen')) {
  520. $recommendedPHPModules[] = 'intl';
  521. }
  522. if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
  523. if (!extension_loaded('imagick')) {
  524. $recommendedPHPModules[] = 'imagick';
  525. }
  526. }
  527. return $recommendedPHPModules;
  528. }
  529. protected function isMysqlUsedWithoutUTF8MB4(): bool {
  530. return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
  531. }
  532. protected function hasBigIntConversionPendingColumns(): array {
  533. // copy of ConvertFilecacheBigInt::getColumnsByTable()
  534. $tables = [
  535. 'activity' => ['activity_id', 'object_id'],
  536. 'activity_mq' => ['mail_id'],
  537. 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
  538. 'mimetypes' => ['id'],
  539. 'storages' => ['numeric_id'],
  540. ];
  541. $schema = new SchemaWrapper($this->db);
  542. $isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
  543. $pendingColumns = [];
  544. foreach ($tables as $tableName => $columns) {
  545. if (!$schema->hasTable($tableName)) {
  546. continue;
  547. }
  548. $table = $schema->getTable($tableName);
  549. foreach ($columns as $columnName) {
  550. $column = $table->getColumn($columnName);
  551. $isAutoIncrement = $column->getAutoincrement();
  552. $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
  553. if ($column->getType()->getName() !== Type::BIGINT && !$isAutoIncrementOnSqlite) {
  554. $pendingColumns[] = $tableName . '.' . $columnName;
  555. }
  556. }
  557. }
  558. return $pendingColumns;
  559. }
  560. protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
  561. $objectStore = $this->config->getSystemValue('objectstore', null);
  562. $objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
  563. if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
  564. return true;
  565. }
  566. if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
  567. return true;
  568. }
  569. if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
  570. return true;
  571. }
  572. $tempPath = sys_get_temp_dir();
  573. if (!is_dir($tempPath)) {
  574. $this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
  575. return false;
  576. }
  577. $freeSpaceInTemp = disk_free_space($tempPath);
  578. if ($freeSpaceInTemp === false) {
  579. $this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
  580. return false;
  581. }
  582. $freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
  583. if ($freeSpaceInTempInGB > 50) {
  584. return true;
  585. }
  586. $this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
  587. return false;
  588. }
  589. /**
  590. * @return DataResponse
  591. */
  592. public function check() {
  593. return new DataResponse(
  594. [
  595. 'isGetenvServerWorking' => !empty(getenv('PATH')),
  596. 'isReadOnlyConfig' => $this->isReadOnlyConfig(),
  597. 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
  598. 'outdatedCaches' => $this->getOutdatedCaches(),
  599. 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
  600. 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
  601. 'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
  602. 'cronInfo' => $this->getLastCronInfo(),
  603. 'cronErrors' => $this->getCronErrors(),
  604. 'serverHasInternetConnection' => $this->isInternetConnectionWorking(),
  605. 'isMemcacheConfigured' => $this->isMemcacheConfigured(),
  606. 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
  607. 'isRandomnessSecure' => $this->isRandomnessSecure(),
  608. 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
  609. 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
  610. 'phpSupported' => $this->isPhpSupported(),
  611. 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
  612. 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
  613. 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
  614. 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
  615. 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
  616. 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
  617. 'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
  618. 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
  619. 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
  620. 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
  621. 'missingIndexes' => $this->hasMissingIndexes(),
  622. 'isSqliteUsed' => $this->isSqliteUsed(),
  623. 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
  624. 'isPHPMailerUsed' => $this->isPHPMailerUsed(),
  625. 'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
  626. 'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
  627. 'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
  628. 'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
  629. 'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
  630. 'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
  631. 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
  632. ]
  633. );
  634. }
  635. }