CheckSetupController.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  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->getNumeric('opcache.max_accelerated_files') < 10000) {
  372. return false;
  373. }
  374. if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
  375. return false;
  376. }
  377. if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
  378. return false;
  379. }
  380. return true;
  381. }
  382. /**
  383. * Check if the required FreeType functions are present
  384. * @return bool
  385. */
  386. protected function hasFreeTypeSupport() {
  387. return function_exists('imagettfbbox') && function_exists('imagettftext');
  388. }
  389. protected function hasMissingIndexes(): array {
  390. $indexInfo = new MissingIndexInformation();
  391. // Dispatch event so apps can also hint for pending index updates if needed
  392. $event = new GenericEvent($indexInfo);
  393. $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
  394. return $indexInfo->getListOfMissingIndexes();
  395. }
  396. /**
  397. * warn if outdated version of a memcache module is used
  398. */
  399. protected function getOutdatedCaches(): array {
  400. $caches = [
  401. 'apcu' => ['name' => 'APCu', 'version' => '4.0.6'],
  402. 'redis' => ['name' => 'Redis', 'version' => '2.2.5'],
  403. ];
  404. $outdatedCaches = [];
  405. foreach ($caches as $php_module => $data) {
  406. $isOutdated = extension_loaded($php_module) && version_compare(phpversion($php_module), $data['version'], '<');
  407. if ($isOutdated) {
  408. $outdatedCaches[] = $data;
  409. }
  410. }
  411. return $outdatedCaches;
  412. }
  413. protected function isSqliteUsed() {
  414. return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
  415. }
  416. protected function isReadOnlyConfig(): bool {
  417. return \OC_Helper::isReadOnlyConfigEnabled();
  418. }
  419. protected function hasValidTransactionIsolationLevel(): bool {
  420. try {
  421. if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
  422. return true;
  423. }
  424. return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED;
  425. } catch (DBALException $e) {
  426. // ignore
  427. }
  428. return true;
  429. }
  430. protected function hasFileinfoInstalled(): bool {
  431. return \OC_Util::fileInfoLoaded();
  432. }
  433. protected function hasWorkingFileLocking(): bool {
  434. return !($this->lockingProvider instanceof NoopLockingProvider);
  435. }
  436. protected function getSuggestedOverwriteCliURL(): string {
  437. $suggestedOverwriteCliUrl = '';
  438. if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
  439. $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
  440. if (!$this->config->getSystemValue('config_is_read_only', false)) {
  441. // Set the overwrite URL when it was not set yet.
  442. $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
  443. $suggestedOverwriteCliUrl = '';
  444. }
  445. }
  446. return $suggestedOverwriteCliUrl;
  447. }
  448. protected function getLastCronInfo(): array {
  449. $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
  450. return [
  451. 'diffInSeconds' => time() - $lastCronRun,
  452. 'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
  453. 'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
  454. ];
  455. }
  456. protected function getCronErrors() {
  457. $errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
  458. if (is_array($errors)) {
  459. return $errors;
  460. }
  461. return [];
  462. }
  463. protected function isPHPMailerUsed(): bool {
  464. return $this->config->getSystemValue('mail_smtpmode', 'smtp') === 'php';
  465. }
  466. protected function hasOpcacheLoaded(): bool {
  467. return function_exists('opcache_get_status');
  468. }
  469. /**
  470. * Iterates through the configured app roots and
  471. * tests if the subdirectories are owned by the same user than the current user.
  472. *
  473. * @return array
  474. */
  475. protected function getAppDirsWithDifferentOwner(): array {
  476. $currentUser = posix_getuid();
  477. $appDirsWithDifferentOwner = [[]];
  478. foreach (OC::$APPSROOTS as $appRoot) {
  479. if ($appRoot['writable'] === true) {
  480. $appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
  481. }
  482. }
  483. $appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
  484. sort($appDirsWithDifferentOwner);
  485. return $appDirsWithDifferentOwner;
  486. }
  487. /**
  488. * Tests if the directories for one apps directory are writable by the current user.
  489. *
  490. * @param int $currentUser The current user
  491. * @param array $appRoot The app root config
  492. * @return string[] The none writable directory paths inside the app root
  493. */
  494. private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
  495. $appDirsWithDifferentOwner = [];
  496. $appsPath = $appRoot['path'];
  497. $appsDir = new DirectoryIterator($appRoot['path']);
  498. foreach ($appsDir as $fileInfo) {
  499. if ($fileInfo->isDir() && !$fileInfo->isDot()) {
  500. $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
  501. $appDirUser = fileowner($absAppPath);
  502. if ($appDirUser !== $currentUser) {
  503. $appDirsWithDifferentOwner[] = $absAppPath;
  504. }
  505. }
  506. }
  507. return $appDirsWithDifferentOwner;
  508. }
  509. /**
  510. * Checks for potential PHP modules that would improve the instance
  511. *
  512. * @return string[] A list of PHP modules that is recommended
  513. */
  514. protected function hasRecommendedPHPModules(): array {
  515. $recommendedPHPModules = [];
  516. if (!function_exists('grapheme_strlen')) {
  517. $recommendedPHPModules[] = 'intl';
  518. }
  519. if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
  520. if (!extension_loaded('imagick')) {
  521. $recommendedPHPModules[] = 'imagick';
  522. }
  523. }
  524. return $recommendedPHPModules;
  525. }
  526. protected function isMysqlUsedWithoutUTF8MB4(): bool {
  527. return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
  528. }
  529. protected function hasBigIntConversionPendingColumns(): array {
  530. // copy of ConvertFilecacheBigInt::getColumnsByTable()
  531. $tables = [
  532. 'activity' => ['activity_id', 'object_id'],
  533. 'activity_mq' => ['mail_id'],
  534. 'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
  535. 'mimetypes' => ['id'],
  536. 'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
  537. 'storages' => ['numeric_id'],
  538. ];
  539. $schema = new SchemaWrapper($this->db);
  540. $isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
  541. $pendingColumns = [];
  542. foreach ($tables as $tableName => $columns) {
  543. if (!$schema->hasTable($tableName)) {
  544. continue;
  545. }
  546. $table = $schema->getTable($tableName);
  547. foreach ($columns as $columnName) {
  548. $column = $table->getColumn($columnName);
  549. $isAutoIncrement = $column->getAutoincrement();
  550. $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
  551. if ($column->getType()->getName() !== Type::BIGINT && !$isAutoIncrementOnSqlite) {
  552. $pendingColumns[] = $tableName . '.' . $columnName;
  553. }
  554. }
  555. }
  556. return $pendingColumns;
  557. }
  558. protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
  559. $objectStore = $this->config->getSystemValue('objectstore', null);
  560. $objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
  561. if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
  562. return true;
  563. }
  564. if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
  565. return true;
  566. }
  567. if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
  568. return true;
  569. }
  570. $tempPath = sys_get_temp_dir();
  571. if (!is_dir($tempPath)) {
  572. $this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
  573. return false;
  574. }
  575. $freeSpaceInTemp = disk_free_space($tempPath);
  576. if ($freeSpaceInTemp === false) {
  577. $this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
  578. return false;
  579. }
  580. $freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
  581. if ($freeSpaceInTempInGB > 50) {
  582. return true;
  583. }
  584. $this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
  585. return false;
  586. }
  587. /**
  588. * @return DataResponse
  589. */
  590. public function check() {
  591. return new DataResponse(
  592. [
  593. 'isGetenvServerWorking' => !empty(getenv('PATH')),
  594. 'isReadOnlyConfig' => $this->isReadOnlyConfig(),
  595. 'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
  596. 'outdatedCaches' => $this->getOutdatedCaches(),
  597. 'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
  598. 'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
  599. 'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
  600. 'cronInfo' => $this->getLastCronInfo(),
  601. 'cronErrors' => $this->getCronErrors(),
  602. 'serverHasInternetConnection' => $this->isInternetConnectionWorking(),
  603. 'isMemcacheConfigured' => $this->isMemcacheConfigured(),
  604. 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
  605. 'isRandomnessSecure' => $this->isRandomnessSecure(),
  606. 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
  607. 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
  608. 'phpSupported' => $this->isPhpSupported(),
  609. 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
  610. 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
  611. 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
  612. 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
  613. 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
  614. 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
  615. 'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
  616. 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
  617. 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
  618. 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
  619. 'missingIndexes' => $this->hasMissingIndexes(),
  620. 'isSqliteUsed' => $this->isSqliteUsed(),
  621. 'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
  622. 'isPHPMailerUsed' => $this->isPHPMailerUsed(),
  623. 'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
  624. 'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
  625. 'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
  626. 'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
  627. 'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
  628. 'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
  629. 'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
  630. ]
  631. );
  632. }
  633. }