You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CheckSetupController.php 22KB

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