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 23KB

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