@@ -119,6 +119,7 @@ discard block |
||
119 | 119 | |
120 | 120 | /** |
121 | 121 | * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP |
122 | + * @param string $sitename |
|
122 | 123 | * @return bool |
123 | 124 | */ |
124 | 125 | private function isSiteReachable($sitename) { |
@@ -316,7 +317,7 @@ discard block |
||
316 | 317 | |
317 | 318 | /** |
318 | 319 | * @NoCSRFRequired |
319 | - * @return DataResponse |
|
320 | + * @return DataDisplayResponse |
|
320 | 321 | */ |
321 | 322 | public function getFailedIntegrityCheckFiles() { |
322 | 323 | if(!$this->checker->isCodeCheckEnforced()) { |
@@ -49,284 +49,284 @@ discard block |
||
49 | 49 | * @package OC\Settings\Controller |
50 | 50 | */ |
51 | 51 | class CheckSetupController extends Controller { |
52 | - /** @var IConfig */ |
|
53 | - private $config; |
|
54 | - /** @var IClientService */ |
|
55 | - private $clientService; |
|
56 | - /** @var \OC_Util */ |
|
57 | - private $util; |
|
58 | - /** @var IURLGenerator */ |
|
59 | - private $urlGenerator; |
|
60 | - /** @var IL10N */ |
|
61 | - private $l10n; |
|
62 | - /** @var Checker */ |
|
63 | - private $checker; |
|
64 | - /** @var ILogger */ |
|
65 | - private $logger; |
|
66 | - |
|
67 | - /** |
|
68 | - * @param string $AppName |
|
69 | - * @param IRequest $request |
|
70 | - * @param IConfig $config |
|
71 | - * @param IClientService $clientService |
|
72 | - * @param IURLGenerator $urlGenerator |
|
73 | - * @param \OC_Util $util |
|
74 | - * @param IL10N $l10n |
|
75 | - * @param Checker $checker |
|
76 | - * @param ILogger $logger |
|
77 | - */ |
|
78 | - public function __construct($AppName, |
|
79 | - IRequest $request, |
|
80 | - IConfig $config, |
|
81 | - IClientService $clientService, |
|
82 | - IURLGenerator $urlGenerator, |
|
83 | - \OC_Util $util, |
|
84 | - IL10N $l10n, |
|
85 | - Checker $checker, |
|
86 | - ILogger $logger) { |
|
87 | - parent::__construct($AppName, $request); |
|
88 | - $this->config = $config; |
|
89 | - $this->clientService = $clientService; |
|
90 | - $this->util = $util; |
|
91 | - $this->urlGenerator = $urlGenerator; |
|
92 | - $this->l10n = $l10n; |
|
93 | - $this->checker = $checker; |
|
94 | - $this->logger = $logger; |
|
95 | - } |
|
96 | - |
|
97 | - /** |
|
98 | - * Checks if the server can connect to the internet using HTTPS and HTTP |
|
99 | - * @return bool |
|
100 | - */ |
|
101 | - private function isInternetConnectionWorking() { |
|
102 | - if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
|
103 | - return false; |
|
104 | - } |
|
105 | - |
|
106 | - $siteArray = ['www.nextcloud.com', |
|
107 | - 'www.startpage.com', |
|
108 | - 'www.eff.org', |
|
109 | - 'www.edri.org', |
|
110 | - ]; |
|
111 | - |
|
112 | - foreach($siteArray as $site) { |
|
113 | - if ($this->isSiteReachable($site)) { |
|
114 | - return true; |
|
115 | - } |
|
116 | - } |
|
117 | - return false; |
|
118 | - } |
|
119 | - |
|
120 | - /** |
|
121 | - * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP |
|
122 | - * @return bool |
|
123 | - */ |
|
124 | - private function isSiteReachable($sitename) { |
|
125 | - $httpSiteName = 'http://' . $sitename . '/'; |
|
126 | - $httpsSiteName = 'https://' . $sitename . '/'; |
|
127 | - |
|
128 | - try { |
|
129 | - $client = $this->clientService->newClient(); |
|
130 | - $client->get($httpSiteName); |
|
131 | - $client->get($httpsSiteName); |
|
132 | - } catch (\Exception $e) { |
|
133 | - $this->logger->logException($e, ['app' => 'internet_connection_check']); |
|
134 | - return false; |
|
135 | - } |
|
136 | - return true; |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Checks whether a local memcache is installed or not |
|
141 | - * @return bool |
|
142 | - */ |
|
143 | - private function isMemcacheConfigured() { |
|
144 | - return $this->config->getSystemValue('memcache.local', null) !== null; |
|
145 | - } |
|
146 | - |
|
147 | - /** |
|
148 | - * Whether /dev/urandom is available to the PHP controller |
|
149 | - * |
|
150 | - * @return bool |
|
151 | - */ |
|
152 | - private function isUrandomAvailable() { |
|
153 | - if(@file_exists('/dev/urandom')) { |
|
154 | - $file = fopen('/dev/urandom', 'rb'); |
|
155 | - if($file) { |
|
156 | - fclose($file); |
|
157 | - return true; |
|
158 | - } |
|
159 | - } |
|
160 | - |
|
161 | - return false; |
|
162 | - } |
|
163 | - |
|
164 | - /** |
|
165 | - * Public for the sake of unit-testing |
|
166 | - * |
|
167 | - * @return array |
|
168 | - */ |
|
169 | - protected function getCurlVersion() { |
|
170 | - return curl_version(); |
|
171 | - } |
|
172 | - |
|
173 | - /** |
|
174 | - * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
|
175 | - * have multiple bugs which likely lead to problems in combination with |
|
176 | - * functionality required by ownCloud such as SNI. |
|
177 | - * |
|
178 | - * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
|
179 | - * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
|
180 | - * @return string |
|
181 | - */ |
|
182 | - private function isUsedTlsLibOutdated() { |
|
183 | - // Don't run check when: |
|
184 | - // 1. Server has `has_internet_connection` set to false |
|
185 | - // 2. AppStore AND S2S is disabled |
|
186 | - if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
187 | - return ''; |
|
188 | - } |
|
189 | - if(!$this->config->getSystemValue('appstoreenabled', true) |
|
190 | - && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
|
191 | - && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
|
192 | - return ''; |
|
193 | - } |
|
194 | - |
|
195 | - $versionString = $this->getCurlVersion(); |
|
196 | - if(isset($versionString['ssl_version'])) { |
|
197 | - $versionString = $versionString['ssl_version']; |
|
198 | - } else { |
|
199 | - return ''; |
|
200 | - } |
|
201 | - |
|
202 | - $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
203 | - if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
204 | - $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
205 | - } |
|
206 | - |
|
207 | - // Check if at least OpenSSL after 1.01d or 1.0.2b |
|
208 | - if(strpos($versionString, 'OpenSSL/') === 0) { |
|
209 | - $majorVersion = substr($versionString, 8, 5); |
|
210 | - $patchRelease = substr($versionString, 13, 6); |
|
211 | - |
|
212 | - if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
213 | - ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
|
214 | - return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['OpenSSL', $versionString, $features]); |
|
215 | - } |
|
216 | - } |
|
217 | - |
|
218 | - // Check if NSS and perform heuristic check |
|
219 | - if(strpos($versionString, 'NSS/') === 0) { |
|
220 | - try { |
|
221 | - $firstClient = $this->clientService->newClient(); |
|
222 | - $firstClient->get('https://nextcloud.com/'); |
|
223 | - |
|
224 | - $secondClient = $this->clientService->newClient(); |
|
225 | - $secondClient->get('https://nextcloud.com/'); |
|
226 | - } catch (ClientException $e) { |
|
227 | - if($e->getResponse()->getStatusCode() === 400) { |
|
228 | - return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['NSS', $versionString, $features]); |
|
229 | - } |
|
230 | - } |
|
231 | - } |
|
232 | - |
|
233 | - return ''; |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Whether the version is outdated |
|
238 | - * |
|
239 | - * @return bool |
|
240 | - */ |
|
241 | - protected function isPhpOutdated() { |
|
242 | - if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
243 | - return true; |
|
244 | - } |
|
245 | - |
|
246 | - return false; |
|
247 | - } |
|
248 | - |
|
249 | - /** |
|
250 | - * Whether the php version is still supported (at time of release) |
|
251 | - * according to: https://secure.php.net/supported-versions.php |
|
252 | - * |
|
253 | - * @return array |
|
254 | - */ |
|
255 | - private function isPhpSupported() { |
|
256 | - return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; |
|
257 | - } |
|
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->getRemoteAddress(); |
|
267 | - |
|
268 | - if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { |
|
269 | - return false; |
|
270 | - } |
|
271 | - |
|
272 | - // either not enabled or working correctly |
|
273 | - return true; |
|
274 | - } |
|
275 | - |
|
276 | - /** |
|
277 | - * Checks if the correct memcache module for PHP is installed. Only |
|
278 | - * fails if memcached is configured and the working module is not installed. |
|
279 | - * |
|
280 | - * @return bool |
|
281 | - */ |
|
282 | - private function isCorrectMemcachedPHPModuleInstalled() { |
|
283 | - if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') { |
|
284 | - return true; |
|
285 | - } |
|
286 | - |
|
287 | - // there are two different memcached modules for PHP |
|
288 | - // we only support memcached and not memcache |
|
289 | - // https://code.google.com/p/memcached/wiki/PHPClientComparison |
|
290 | - return !(!extension_loaded('memcached') && extension_loaded('memcache')); |
|
291 | - } |
|
292 | - |
|
293 | - /** |
|
294 | - * Checks if set_time_limit is not disabled. |
|
295 | - * |
|
296 | - * @return bool |
|
297 | - */ |
|
298 | - private function isSettimelimitAvailable() { |
|
299 | - if (function_exists('set_time_limit') |
|
300 | - && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
301 | - return true; |
|
302 | - } |
|
303 | - |
|
304 | - return false; |
|
305 | - } |
|
306 | - |
|
307 | - /** |
|
308 | - * @return RedirectResponse |
|
309 | - */ |
|
310 | - public function rescanFailedIntegrityCheck() { |
|
311 | - $this->checker->runInstanceVerification(); |
|
312 | - return new RedirectResponse( |
|
313 | - $this->urlGenerator->linkToRoute('settings.AdminSettings.index') |
|
314 | - ); |
|
315 | - } |
|
316 | - |
|
317 | - /** |
|
318 | - * @NoCSRFRequired |
|
319 | - * @return DataResponse |
|
320 | - */ |
|
321 | - public function getFailedIntegrityCheckFiles() { |
|
322 | - if(!$this->checker->isCodeCheckEnforced()) { |
|
323 | - return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
|
324 | - } |
|
325 | - |
|
326 | - $completeResults = $this->checker->getResults(); |
|
327 | - |
|
328 | - if(!empty($completeResults)) { |
|
329 | - $formattedTextResponse = 'Technical information |
|
52 | + /** @var IConfig */ |
|
53 | + private $config; |
|
54 | + /** @var IClientService */ |
|
55 | + private $clientService; |
|
56 | + /** @var \OC_Util */ |
|
57 | + private $util; |
|
58 | + /** @var IURLGenerator */ |
|
59 | + private $urlGenerator; |
|
60 | + /** @var IL10N */ |
|
61 | + private $l10n; |
|
62 | + /** @var Checker */ |
|
63 | + private $checker; |
|
64 | + /** @var ILogger */ |
|
65 | + private $logger; |
|
66 | + |
|
67 | + /** |
|
68 | + * @param string $AppName |
|
69 | + * @param IRequest $request |
|
70 | + * @param IConfig $config |
|
71 | + * @param IClientService $clientService |
|
72 | + * @param IURLGenerator $urlGenerator |
|
73 | + * @param \OC_Util $util |
|
74 | + * @param IL10N $l10n |
|
75 | + * @param Checker $checker |
|
76 | + * @param ILogger $logger |
|
77 | + */ |
|
78 | + public function __construct($AppName, |
|
79 | + IRequest $request, |
|
80 | + IConfig $config, |
|
81 | + IClientService $clientService, |
|
82 | + IURLGenerator $urlGenerator, |
|
83 | + \OC_Util $util, |
|
84 | + IL10N $l10n, |
|
85 | + Checker $checker, |
|
86 | + ILogger $logger) { |
|
87 | + parent::__construct($AppName, $request); |
|
88 | + $this->config = $config; |
|
89 | + $this->clientService = $clientService; |
|
90 | + $this->util = $util; |
|
91 | + $this->urlGenerator = $urlGenerator; |
|
92 | + $this->l10n = $l10n; |
|
93 | + $this->checker = $checker; |
|
94 | + $this->logger = $logger; |
|
95 | + } |
|
96 | + |
|
97 | + /** |
|
98 | + * Checks if the server can connect to the internet using HTTPS and HTTP |
|
99 | + * @return bool |
|
100 | + */ |
|
101 | + private function isInternetConnectionWorking() { |
|
102 | + if ($this->config->getSystemValue('has_internet_connection', true) === false) { |
|
103 | + return false; |
|
104 | + } |
|
105 | + |
|
106 | + $siteArray = ['www.nextcloud.com', |
|
107 | + 'www.startpage.com', |
|
108 | + 'www.eff.org', |
|
109 | + 'www.edri.org', |
|
110 | + ]; |
|
111 | + |
|
112 | + foreach($siteArray as $site) { |
|
113 | + if ($this->isSiteReachable($site)) { |
|
114 | + return true; |
|
115 | + } |
|
116 | + } |
|
117 | + return false; |
|
118 | + } |
|
119 | + |
|
120 | + /** |
|
121 | + * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP |
|
122 | + * @return bool |
|
123 | + */ |
|
124 | + private function isSiteReachable($sitename) { |
|
125 | + $httpSiteName = 'http://' . $sitename . '/'; |
|
126 | + $httpsSiteName = 'https://' . $sitename . '/'; |
|
127 | + |
|
128 | + try { |
|
129 | + $client = $this->clientService->newClient(); |
|
130 | + $client->get($httpSiteName); |
|
131 | + $client->get($httpsSiteName); |
|
132 | + } catch (\Exception $e) { |
|
133 | + $this->logger->logException($e, ['app' => 'internet_connection_check']); |
|
134 | + return false; |
|
135 | + } |
|
136 | + return true; |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Checks whether a local memcache is installed or not |
|
141 | + * @return bool |
|
142 | + */ |
|
143 | + private function isMemcacheConfigured() { |
|
144 | + return $this->config->getSystemValue('memcache.local', null) !== null; |
|
145 | + } |
|
146 | + |
|
147 | + /** |
|
148 | + * Whether /dev/urandom is available to the PHP controller |
|
149 | + * |
|
150 | + * @return bool |
|
151 | + */ |
|
152 | + private function isUrandomAvailable() { |
|
153 | + if(@file_exists('/dev/urandom')) { |
|
154 | + $file = fopen('/dev/urandom', 'rb'); |
|
155 | + if($file) { |
|
156 | + fclose($file); |
|
157 | + return true; |
|
158 | + } |
|
159 | + } |
|
160 | + |
|
161 | + return false; |
|
162 | + } |
|
163 | + |
|
164 | + /** |
|
165 | + * Public for the sake of unit-testing |
|
166 | + * |
|
167 | + * @return array |
|
168 | + */ |
|
169 | + protected function getCurlVersion() { |
|
170 | + return curl_version(); |
|
171 | + } |
|
172 | + |
|
173 | + /** |
|
174 | + * Check if the used SSL lib is outdated. Older OpenSSL and NSS versions do |
|
175 | + * have multiple bugs which likely lead to problems in combination with |
|
176 | + * functionality required by ownCloud such as SNI. |
|
177 | + * |
|
178 | + * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546 |
|
179 | + * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172 |
|
180 | + * @return string |
|
181 | + */ |
|
182 | + private function isUsedTlsLibOutdated() { |
|
183 | + // Don't run check when: |
|
184 | + // 1. Server has `has_internet_connection` set to false |
|
185 | + // 2. AppStore AND S2S is disabled |
|
186 | + if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
187 | + return ''; |
|
188 | + } |
|
189 | + if(!$this->config->getSystemValue('appstoreenabled', true) |
|
190 | + && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
|
191 | + && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
|
192 | + return ''; |
|
193 | + } |
|
194 | + |
|
195 | + $versionString = $this->getCurlVersion(); |
|
196 | + if(isset($versionString['ssl_version'])) { |
|
197 | + $versionString = $versionString['ssl_version']; |
|
198 | + } else { |
|
199 | + return ''; |
|
200 | + } |
|
201 | + |
|
202 | + $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
203 | + if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
204 | + $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
205 | + } |
|
206 | + |
|
207 | + // Check if at least OpenSSL after 1.01d or 1.0.2b |
|
208 | + if(strpos($versionString, 'OpenSSL/') === 0) { |
|
209 | + $majorVersion = substr($versionString, 8, 5); |
|
210 | + $patchRelease = substr($versionString, 13, 6); |
|
211 | + |
|
212 | + if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
213 | + ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
|
214 | + return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['OpenSSL', $versionString, $features]); |
|
215 | + } |
|
216 | + } |
|
217 | + |
|
218 | + // Check if NSS and perform heuristic check |
|
219 | + if(strpos($versionString, 'NSS/') === 0) { |
|
220 | + try { |
|
221 | + $firstClient = $this->clientService->newClient(); |
|
222 | + $firstClient->get('https://nextcloud.com/'); |
|
223 | + |
|
224 | + $secondClient = $this->clientService->newClient(); |
|
225 | + $secondClient->get('https://nextcloud.com/'); |
|
226 | + } catch (ClientException $e) { |
|
227 | + if($e->getResponse()->getStatusCode() === 400) { |
|
228 | + return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['NSS', $versionString, $features]); |
|
229 | + } |
|
230 | + } |
|
231 | + } |
|
232 | + |
|
233 | + return ''; |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Whether the version is outdated |
|
238 | + * |
|
239 | + * @return bool |
|
240 | + */ |
|
241 | + protected function isPhpOutdated() { |
|
242 | + if (version_compare(PHP_VERSION, '7.0.0', '<')) { |
|
243 | + return true; |
|
244 | + } |
|
245 | + |
|
246 | + return false; |
|
247 | + } |
|
248 | + |
|
249 | + /** |
|
250 | + * Whether the php version is still supported (at time of release) |
|
251 | + * according to: https://secure.php.net/supported-versions.php |
|
252 | + * |
|
253 | + * @return array |
|
254 | + */ |
|
255 | + private function isPhpSupported() { |
|
256 | + return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION]; |
|
257 | + } |
|
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->getRemoteAddress(); |
|
267 | + |
|
268 | + if (is_array($trustedProxies) && in_array($remoteAddress, $trustedProxies)) { |
|
269 | + return false; |
|
270 | + } |
|
271 | + |
|
272 | + // either not enabled or working correctly |
|
273 | + return true; |
|
274 | + } |
|
275 | + |
|
276 | + /** |
|
277 | + * Checks if the correct memcache module for PHP is installed. Only |
|
278 | + * fails if memcached is configured and the working module is not installed. |
|
279 | + * |
|
280 | + * @return bool |
|
281 | + */ |
|
282 | + private function isCorrectMemcachedPHPModuleInstalled() { |
|
283 | + if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') { |
|
284 | + return true; |
|
285 | + } |
|
286 | + |
|
287 | + // there are two different memcached modules for PHP |
|
288 | + // we only support memcached and not memcache |
|
289 | + // https://code.google.com/p/memcached/wiki/PHPClientComparison |
|
290 | + return !(!extension_loaded('memcached') && extension_loaded('memcache')); |
|
291 | + } |
|
292 | + |
|
293 | + /** |
|
294 | + * Checks if set_time_limit is not disabled. |
|
295 | + * |
|
296 | + * @return bool |
|
297 | + */ |
|
298 | + private function isSettimelimitAvailable() { |
|
299 | + if (function_exists('set_time_limit') |
|
300 | + && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) { |
|
301 | + return true; |
|
302 | + } |
|
303 | + |
|
304 | + return false; |
|
305 | + } |
|
306 | + |
|
307 | + /** |
|
308 | + * @return RedirectResponse |
|
309 | + */ |
|
310 | + public function rescanFailedIntegrityCheck() { |
|
311 | + $this->checker->runInstanceVerification(); |
|
312 | + return new RedirectResponse( |
|
313 | + $this->urlGenerator->linkToRoute('settings.AdminSettings.index') |
|
314 | + ); |
|
315 | + } |
|
316 | + |
|
317 | + /** |
|
318 | + * @NoCSRFRequired |
|
319 | + * @return DataResponse |
|
320 | + */ |
|
321 | + public function getFailedIntegrityCheckFiles() { |
|
322 | + if(!$this->checker->isCodeCheckEnforced()) { |
|
323 | + return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
|
324 | + } |
|
325 | + |
|
326 | + $completeResults = $this->checker->getResults(); |
|
327 | + |
|
328 | + if(!empty($completeResults)) { |
|
329 | + $formattedTextResponse = 'Technical information |
|
330 | 330 | ===================== |
331 | 331 | The following list covers which files have failed the integrity check. Please read |
332 | 332 | the previous linked documentation to learn more about the errors and how to fix |
@@ -335,112 +335,112 @@ discard block |
||
335 | 335 | Results |
336 | 336 | ======= |
337 | 337 | '; |
338 | - foreach($completeResults as $context => $contextResult) { |
|
339 | - $formattedTextResponse .= "- $context\n"; |
|
340 | - |
|
341 | - foreach($contextResult as $category => $result) { |
|
342 | - $formattedTextResponse .= "\t- $category\n"; |
|
343 | - if($category !== 'EXCEPTION') { |
|
344 | - foreach ($result as $key => $results) { |
|
345 | - $formattedTextResponse .= "\t\t- $key\n"; |
|
346 | - } |
|
347 | - } else { |
|
348 | - foreach ($result as $key => $results) { |
|
349 | - $formattedTextResponse .= "\t\t- $results\n"; |
|
350 | - } |
|
351 | - } |
|
352 | - |
|
353 | - } |
|
354 | - } |
|
355 | - |
|
356 | - $formattedTextResponse .= ' |
|
338 | + foreach($completeResults as $context => $contextResult) { |
|
339 | + $formattedTextResponse .= "- $context\n"; |
|
340 | + |
|
341 | + foreach($contextResult as $category => $result) { |
|
342 | + $formattedTextResponse .= "\t- $category\n"; |
|
343 | + if($category !== 'EXCEPTION') { |
|
344 | + foreach ($result as $key => $results) { |
|
345 | + $formattedTextResponse .= "\t\t- $key\n"; |
|
346 | + } |
|
347 | + } else { |
|
348 | + foreach ($result as $key => $results) { |
|
349 | + $formattedTextResponse .= "\t\t- $results\n"; |
|
350 | + } |
|
351 | + } |
|
352 | + |
|
353 | + } |
|
354 | + } |
|
355 | + |
|
356 | + $formattedTextResponse .= ' |
|
357 | 357 | Raw output |
358 | 358 | ========== |
359 | 359 | '; |
360 | - $formattedTextResponse .= print_r($completeResults, true); |
|
361 | - } else { |
|
362 | - $formattedTextResponse = 'No errors have been found.'; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - $response = new DataDisplayResponse( |
|
367 | - $formattedTextResponse, |
|
368 | - Http::STATUS_OK, |
|
369 | - [ |
|
370 | - 'Content-Type' => 'text/plain', |
|
371 | - ] |
|
372 | - ); |
|
373 | - |
|
374 | - return $response; |
|
375 | - } |
|
376 | - |
|
377 | - /** |
|
378 | - * Checks whether a PHP opcache is properly set up |
|
379 | - * @return bool |
|
380 | - */ |
|
381 | - protected function isOpcacheProperlySetup() { |
|
382 | - $iniWrapper = new IniGetWrapper(); |
|
383 | - |
|
384 | - $isOpcacheProperlySetUp = true; |
|
385 | - |
|
386 | - if(!$iniWrapper->getBool('opcache.enable')) { |
|
387 | - $isOpcacheProperlySetUp = false; |
|
388 | - } |
|
389 | - |
|
390 | - if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
391 | - $isOpcacheProperlySetUp = false; |
|
392 | - } |
|
393 | - |
|
394 | - if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
395 | - $isOpcacheProperlySetUp = false; |
|
396 | - } |
|
397 | - |
|
398 | - if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
399 | - $isOpcacheProperlySetUp = false; |
|
400 | - } |
|
401 | - |
|
402 | - if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
403 | - $isOpcacheProperlySetUp = false; |
|
404 | - } |
|
405 | - |
|
406 | - if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
407 | - $isOpcacheProperlySetUp = false; |
|
408 | - } |
|
409 | - |
|
410 | - return $isOpcacheProperlySetUp; |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Check if the required FreeType functions are present |
|
415 | - * @return bool |
|
416 | - */ |
|
417 | - protected function hasFreeTypeSupport() { |
|
418 | - return function_exists('imagettfbbox') && function_exists('imagettftext'); |
|
419 | - } |
|
420 | - |
|
421 | - /** |
|
422 | - * @return DataResponse |
|
423 | - */ |
|
424 | - public function check() { |
|
425 | - return new DataResponse( |
|
426 | - [ |
|
427 | - 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), |
|
428 | - 'isMemcacheConfigured' => $this->isMemcacheConfigured(), |
|
429 | - 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), |
|
430 | - 'isUrandomAvailable' => $this->isUrandomAvailable(), |
|
431 | - 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), |
|
432 | - 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), |
|
433 | - 'phpSupported' => $this->isPhpSupported(), |
|
434 | - 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), |
|
435 | - 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), |
|
436 | - 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), |
|
437 | - 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), |
|
438 | - 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), |
|
439 | - 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(), |
|
440 | - 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), |
|
441 | - 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), |
|
442 | - 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), |
|
443 | - ] |
|
444 | - ); |
|
445 | - } |
|
360 | + $formattedTextResponse .= print_r($completeResults, true); |
|
361 | + } else { |
|
362 | + $formattedTextResponse = 'No errors have been found.'; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + $response = new DataDisplayResponse( |
|
367 | + $formattedTextResponse, |
|
368 | + Http::STATUS_OK, |
|
369 | + [ |
|
370 | + 'Content-Type' => 'text/plain', |
|
371 | + ] |
|
372 | + ); |
|
373 | + |
|
374 | + return $response; |
|
375 | + } |
|
376 | + |
|
377 | + /** |
|
378 | + * Checks whether a PHP opcache is properly set up |
|
379 | + * @return bool |
|
380 | + */ |
|
381 | + protected function isOpcacheProperlySetup() { |
|
382 | + $iniWrapper = new IniGetWrapper(); |
|
383 | + |
|
384 | + $isOpcacheProperlySetUp = true; |
|
385 | + |
|
386 | + if(!$iniWrapper->getBool('opcache.enable')) { |
|
387 | + $isOpcacheProperlySetUp = false; |
|
388 | + } |
|
389 | + |
|
390 | + if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
391 | + $isOpcacheProperlySetUp = false; |
|
392 | + } |
|
393 | + |
|
394 | + if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
395 | + $isOpcacheProperlySetUp = false; |
|
396 | + } |
|
397 | + |
|
398 | + if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
399 | + $isOpcacheProperlySetUp = false; |
|
400 | + } |
|
401 | + |
|
402 | + if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
403 | + $isOpcacheProperlySetUp = false; |
|
404 | + } |
|
405 | + |
|
406 | + if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
407 | + $isOpcacheProperlySetUp = false; |
|
408 | + } |
|
409 | + |
|
410 | + return $isOpcacheProperlySetUp; |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Check if the required FreeType functions are present |
|
415 | + * @return bool |
|
416 | + */ |
|
417 | + protected function hasFreeTypeSupport() { |
|
418 | + return function_exists('imagettfbbox') && function_exists('imagettftext'); |
|
419 | + } |
|
420 | + |
|
421 | + /** |
|
422 | + * @return DataResponse |
|
423 | + */ |
|
424 | + public function check() { |
|
425 | + return new DataResponse( |
|
426 | + [ |
|
427 | + 'serverHasInternetConnection' => $this->isInternetConnectionWorking(), |
|
428 | + 'isMemcacheConfigured' => $this->isMemcacheConfigured(), |
|
429 | + 'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'), |
|
430 | + 'isUrandomAvailable' => $this->isUrandomAvailable(), |
|
431 | + 'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'), |
|
432 | + 'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(), |
|
433 | + 'phpSupported' => $this->isPhpSupported(), |
|
434 | + 'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(), |
|
435 | + 'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'), |
|
436 | + 'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(), |
|
437 | + 'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(), |
|
438 | + 'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'), |
|
439 | + 'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(), |
|
440 | + 'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'), |
|
441 | + 'isSettimelimitAvailable' => $this->isSettimelimitAvailable(), |
|
442 | + 'hasFreeTypeSupport' => $this->hasFreeTypeSupport(), |
|
443 | + ] |
|
444 | + ); |
|
445 | + } |
|
446 | 446 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | 'www.edri.org', |
110 | 110 | ]; |
111 | 111 | |
112 | - foreach($siteArray as $site) { |
|
112 | + foreach ($siteArray as $site) { |
|
113 | 113 | if ($this->isSiteReachable($site)) { |
114 | 114 | return true; |
115 | 115 | } |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @return bool |
123 | 123 | */ |
124 | 124 | private function isSiteReachable($sitename) { |
125 | - $httpSiteName = 'http://' . $sitename . '/'; |
|
126 | - $httpsSiteName = 'https://' . $sitename . '/'; |
|
125 | + $httpSiteName = 'http://'.$sitename.'/'; |
|
126 | + $httpsSiteName = 'https://'.$sitename.'/'; |
|
127 | 127 | |
128 | 128 | try { |
129 | 129 | $client = $this->clientService->newClient(); |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * @return bool |
151 | 151 | */ |
152 | 152 | private function isUrandomAvailable() { |
153 | - if(@file_exists('/dev/urandom')) { |
|
153 | + if (@file_exists('/dev/urandom')) { |
|
154 | 154 | $file = fopen('/dev/urandom', 'rb'); |
155 | - if($file) { |
|
155 | + if ($file) { |
|
156 | 156 | fclose($file); |
157 | 157 | return true; |
158 | 158 | } |
@@ -183,40 +183,40 @@ discard block |
||
183 | 183 | // Don't run check when: |
184 | 184 | // 1. Server has `has_internet_connection` set to false |
185 | 185 | // 2. AppStore AND S2S is disabled |
186 | - if(!$this->config->getSystemValue('has_internet_connection', true)) { |
|
186 | + if (!$this->config->getSystemValue('has_internet_connection', true)) { |
|
187 | 187 | return ''; |
188 | 188 | } |
189 | - if(!$this->config->getSystemValue('appstoreenabled', true) |
|
189 | + if (!$this->config->getSystemValue('appstoreenabled', true) |
|
190 | 190 | && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no' |
191 | 191 | && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') { |
192 | 192 | return ''; |
193 | 193 | } |
194 | 194 | |
195 | 195 | $versionString = $this->getCurlVersion(); |
196 | - if(isset($versionString['ssl_version'])) { |
|
196 | + if (isset($versionString['ssl_version'])) { |
|
197 | 197 | $versionString = $versionString['ssl_version']; |
198 | 198 | } else { |
199 | 199 | return ''; |
200 | 200 | } |
201 | 201 | |
202 | - $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
203 | - if(!$this->config->getSystemValue('appstoreenabled', true)) { |
|
204 | - $features = (string)$this->l10n->t('Federated Cloud Sharing'); |
|
202 | + $features = (string) $this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing'); |
|
203 | + if (!$this->config->getSystemValue('appstoreenabled', true)) { |
|
204 | + $features = (string) $this->l10n->t('Federated Cloud Sharing'); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | // Check if at least OpenSSL after 1.01d or 1.0.2b |
208 | - if(strpos($versionString, 'OpenSSL/') === 0) { |
|
208 | + if (strpos($versionString, 'OpenSSL/') === 0) { |
|
209 | 209 | $majorVersion = substr($versionString, 8, 5); |
210 | 210 | $patchRelease = substr($versionString, 13, 6); |
211 | 211 | |
212 | - if(($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
212 | + if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) || |
|
213 | 213 | ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) { |
214 | 214 | return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['OpenSSL', $versionString, $features]); |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | 218 | // Check if NSS and perform heuristic check |
219 | - if(strpos($versionString, 'NSS/') === 0) { |
|
219 | + if (strpos($versionString, 'NSS/') === 0) { |
|
220 | 220 | try { |
221 | 221 | $firstClient = $this->clientService->newClient(); |
222 | 222 | $firstClient->get('https://nextcloud.com/'); |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $secondClient = $this->clientService->newClient(); |
225 | 225 | $secondClient->get('https://nextcloud.com/'); |
226 | 226 | } catch (ClientException $e) { |
227 | - if($e->getResponse()->getStatusCode() === 400) { |
|
227 | + if ($e->getResponse()->getStatusCode() === 400) { |
|
228 | 228 | return (string) $this->l10n->t('cURL is using an outdated %s version (%s). Please update your operating system or features such as %s will not work reliably.', ['NSS', $versionString, $features]); |
229 | 229 | } |
230 | 230 | } |
@@ -319,13 +319,13 @@ discard block |
||
319 | 319 | * @return DataResponse |
320 | 320 | */ |
321 | 321 | public function getFailedIntegrityCheckFiles() { |
322 | - if(!$this->checker->isCodeCheckEnforced()) { |
|
322 | + if (!$this->checker->isCodeCheckEnforced()) { |
|
323 | 323 | return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.'); |
324 | 324 | } |
325 | 325 | |
326 | 326 | $completeResults = $this->checker->getResults(); |
327 | 327 | |
328 | - if(!empty($completeResults)) { |
|
328 | + if (!empty($completeResults)) { |
|
329 | 329 | $formattedTextResponse = 'Technical information |
330 | 330 | ===================== |
331 | 331 | The following list covers which files have failed the integrity check. Please read |
@@ -335,12 +335,12 @@ discard block |
||
335 | 335 | Results |
336 | 336 | ======= |
337 | 337 | '; |
338 | - foreach($completeResults as $context => $contextResult) { |
|
338 | + foreach ($completeResults as $context => $contextResult) { |
|
339 | 339 | $formattedTextResponse .= "- $context\n"; |
340 | 340 | |
341 | - foreach($contextResult as $category => $result) { |
|
341 | + foreach ($contextResult as $category => $result) { |
|
342 | 342 | $formattedTextResponse .= "\t- $category\n"; |
343 | - if($category !== 'EXCEPTION') { |
|
343 | + if ($category !== 'EXCEPTION') { |
|
344 | 344 | foreach ($result as $key => $results) { |
345 | 345 | $formattedTextResponse .= "\t\t- $key\n"; |
346 | 346 | } |
@@ -383,27 +383,27 @@ discard block |
||
383 | 383 | |
384 | 384 | $isOpcacheProperlySetUp = true; |
385 | 385 | |
386 | - if(!$iniWrapper->getBool('opcache.enable')) { |
|
386 | + if (!$iniWrapper->getBool('opcache.enable')) { |
|
387 | 387 | $isOpcacheProperlySetUp = false; |
388 | 388 | } |
389 | 389 | |
390 | - if(!$iniWrapper->getBool('opcache.save_comments')) { |
|
390 | + if (!$iniWrapper->getBool('opcache.save_comments')) { |
|
391 | 391 | $isOpcacheProperlySetUp = false; |
392 | 392 | } |
393 | 393 | |
394 | - if(!$iniWrapper->getBool('opcache.enable_cli')) { |
|
394 | + if (!$iniWrapper->getBool('opcache.enable_cli')) { |
|
395 | 395 | $isOpcacheProperlySetUp = false; |
396 | 396 | } |
397 | 397 | |
398 | - if($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
398 | + if ($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) { |
|
399 | 399 | $isOpcacheProperlySetUp = false; |
400 | 400 | } |
401 | 401 | |
402 | - if($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
402 | + if ($iniWrapper->getNumeric('opcache.memory_consumption') < 128) { |
|
403 | 403 | $isOpcacheProperlySetUp = false; |
404 | 404 | } |
405 | 405 | |
406 | - if($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
406 | + if ($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) { |
|
407 | 407 | $isOpcacheProperlySetUp = false; |
408 | 408 | } |
409 | 409 |