Passed
Push — master ( 4361d6...b604d5 )
by Roeland
12:05 queued 10s
created
apps/encryption/composer/composer/autoload_classmap.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -6,31 +6,31 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'OCA\\Encryption\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
10
-    'OCA\\Encryption\\Command\\DisableMasterKey' => $baseDir . '/../lib/Command/DisableMasterKey.php',
11
-    'OCA\\Encryption\\Command\\EnableMasterKey' => $baseDir . '/../lib/Command/EnableMasterKey.php',
12
-    'OCA\\Encryption\\Command\\RecoverUser' => $baseDir . '/../lib/Command/RecoverUser.php',
13
-    'OCA\\Encryption\\Command\\ScanLegacyFormat' => $baseDir . '/../lib/Command/ScanLegacyFormat.php',
14
-    'OCA\\Encryption\\Controller\\RecoveryController' => $baseDir . '/../lib/Controller/RecoveryController.php',
15
-    'OCA\\Encryption\\Controller\\SettingsController' => $baseDir . '/../lib/Controller/SettingsController.php',
16
-    'OCA\\Encryption\\Controller\\StatusController' => $baseDir . '/../lib/Controller/StatusController.php',
17
-    'OCA\\Encryption\\Crypto\\Crypt' => $baseDir . '/../lib/Crypto/Crypt.php',
18
-    'OCA\\Encryption\\Crypto\\DecryptAll' => $baseDir . '/../lib/Crypto/DecryptAll.php',
19
-    'OCA\\Encryption\\Crypto\\EncryptAll' => $baseDir . '/../lib/Crypto/EncryptAll.php',
20
-    'OCA\\Encryption\\Crypto\\Encryption' => $baseDir . '/../lib/Crypto/Encryption.php',
21
-    'OCA\\Encryption\\Exceptions\\MultiKeyDecryptException' => $baseDir . '/../lib/Exceptions/MultiKeyDecryptException.php',
22
-    'OCA\\Encryption\\Exceptions\\MultiKeyEncryptException' => $baseDir . '/../lib/Exceptions/MultiKeyEncryptException.php',
23
-    'OCA\\Encryption\\Exceptions\\PrivateKeyMissingException' => $baseDir . '/../lib/Exceptions/PrivateKeyMissingException.php',
24
-    'OCA\\Encryption\\Exceptions\\PublicKeyMissingException' => $baseDir . '/../lib/Exceptions/PublicKeyMissingException.php',
25
-    'OCA\\Encryption\\HookManager' => $baseDir . '/../lib/HookManager.php',
26
-    'OCA\\Encryption\\Hooks\\Contracts\\IHook' => $baseDir . '/../lib/Hooks/Contracts/IHook.php',
27
-    'OCA\\Encryption\\Hooks\\UserHooks' => $baseDir . '/../lib/Hooks/UserHooks.php',
28
-    'OCA\\Encryption\\KeyManager' => $baseDir . '/../lib/KeyManager.php',
29
-    'OCA\\Encryption\\Migration\\SetMasterKeyStatus' => $baseDir . '/../lib/Migration/SetMasterKeyStatus.php',
30
-    'OCA\\Encryption\\Recovery' => $baseDir . '/../lib/Recovery.php',
31
-    'OCA\\Encryption\\Session' => $baseDir . '/../lib/Session.php',
32
-    'OCA\\Encryption\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
33
-    'OCA\\Encryption\\Settings\\Personal' => $baseDir . '/../lib/Settings/Personal.php',
34
-    'OCA\\Encryption\\Users\\Setup' => $baseDir . '/../lib/Users/Setup.php',
35
-    'OCA\\Encryption\\Util' => $baseDir . '/../lib/Util.php',
9
+    'OCA\\Encryption\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
10
+    'OCA\\Encryption\\Command\\DisableMasterKey' => $baseDir.'/../lib/Command/DisableMasterKey.php',
11
+    'OCA\\Encryption\\Command\\EnableMasterKey' => $baseDir.'/../lib/Command/EnableMasterKey.php',
12
+    'OCA\\Encryption\\Command\\RecoverUser' => $baseDir.'/../lib/Command/RecoverUser.php',
13
+    'OCA\\Encryption\\Command\\ScanLegacyFormat' => $baseDir.'/../lib/Command/ScanLegacyFormat.php',
14
+    'OCA\\Encryption\\Controller\\RecoveryController' => $baseDir.'/../lib/Controller/RecoveryController.php',
15
+    'OCA\\Encryption\\Controller\\SettingsController' => $baseDir.'/../lib/Controller/SettingsController.php',
16
+    'OCA\\Encryption\\Controller\\StatusController' => $baseDir.'/../lib/Controller/StatusController.php',
17
+    'OCA\\Encryption\\Crypto\\Crypt' => $baseDir.'/../lib/Crypto/Crypt.php',
18
+    'OCA\\Encryption\\Crypto\\DecryptAll' => $baseDir.'/../lib/Crypto/DecryptAll.php',
19
+    'OCA\\Encryption\\Crypto\\EncryptAll' => $baseDir.'/../lib/Crypto/EncryptAll.php',
20
+    'OCA\\Encryption\\Crypto\\Encryption' => $baseDir.'/../lib/Crypto/Encryption.php',
21
+    'OCA\\Encryption\\Exceptions\\MultiKeyDecryptException' => $baseDir.'/../lib/Exceptions/MultiKeyDecryptException.php',
22
+    'OCA\\Encryption\\Exceptions\\MultiKeyEncryptException' => $baseDir.'/../lib/Exceptions/MultiKeyEncryptException.php',
23
+    'OCA\\Encryption\\Exceptions\\PrivateKeyMissingException' => $baseDir.'/../lib/Exceptions/PrivateKeyMissingException.php',
24
+    'OCA\\Encryption\\Exceptions\\PublicKeyMissingException' => $baseDir.'/../lib/Exceptions/PublicKeyMissingException.php',
25
+    'OCA\\Encryption\\HookManager' => $baseDir.'/../lib/HookManager.php',
26
+    'OCA\\Encryption\\Hooks\\Contracts\\IHook' => $baseDir.'/../lib/Hooks/Contracts/IHook.php',
27
+    'OCA\\Encryption\\Hooks\\UserHooks' => $baseDir.'/../lib/Hooks/UserHooks.php',
28
+    'OCA\\Encryption\\KeyManager' => $baseDir.'/../lib/KeyManager.php',
29
+    'OCA\\Encryption\\Migration\\SetMasterKeyStatus' => $baseDir.'/../lib/Migration/SetMasterKeyStatus.php',
30
+    'OCA\\Encryption\\Recovery' => $baseDir.'/../lib/Recovery.php',
31
+    'OCA\\Encryption\\Session' => $baseDir.'/../lib/Session.php',
32
+    'OCA\\Encryption\\Settings\\Admin' => $baseDir.'/../lib/Settings/Admin.php',
33
+    'OCA\\Encryption\\Settings\\Personal' => $baseDir.'/../lib/Settings/Personal.php',
34
+    'OCA\\Encryption\\Users\\Setup' => $baseDir.'/../lib/Users/Setup.php',
35
+    'OCA\\Encryption\\Util' => $baseDir.'/../lib/Util.php',
36 36
 );
Please login to merge, or discard this patch.
apps/encryption/composer/composer/autoload_static.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -6,53 +6,53 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitEncryption
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\Encryption\\' => 15,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\Encryption\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'OCA\\Encryption\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
25
-        'OCA\\Encryption\\Command\\DisableMasterKey' => __DIR__ . '/..' . '/../lib/Command/DisableMasterKey.php',
26
-        'OCA\\Encryption\\Command\\EnableMasterKey' => __DIR__ . '/..' . '/../lib/Command/EnableMasterKey.php',
27
-        'OCA\\Encryption\\Command\\RecoverUser' => __DIR__ . '/..' . '/../lib/Command/RecoverUser.php',
28
-        'OCA\\Encryption\\Command\\ScanLegacyFormat' => __DIR__ . '/..' . '/../lib/Command/ScanLegacyFormat.php',
29
-        'OCA\\Encryption\\Controller\\RecoveryController' => __DIR__ . '/..' . '/../lib/Controller/RecoveryController.php',
30
-        'OCA\\Encryption\\Controller\\SettingsController' => __DIR__ . '/..' . '/../lib/Controller/SettingsController.php',
31
-        'OCA\\Encryption\\Controller\\StatusController' => __DIR__ . '/..' . '/../lib/Controller/StatusController.php',
32
-        'OCA\\Encryption\\Crypto\\Crypt' => __DIR__ . '/..' . '/../lib/Crypto/Crypt.php',
33
-        'OCA\\Encryption\\Crypto\\DecryptAll' => __DIR__ . '/..' . '/../lib/Crypto/DecryptAll.php',
34
-        'OCA\\Encryption\\Crypto\\EncryptAll' => __DIR__ . '/..' . '/../lib/Crypto/EncryptAll.php',
35
-        'OCA\\Encryption\\Crypto\\Encryption' => __DIR__ . '/..' . '/../lib/Crypto/Encryption.php',
36
-        'OCA\\Encryption\\Exceptions\\MultiKeyDecryptException' => __DIR__ . '/..' . '/../lib/Exceptions/MultiKeyDecryptException.php',
37
-        'OCA\\Encryption\\Exceptions\\MultiKeyEncryptException' => __DIR__ . '/..' . '/../lib/Exceptions/MultiKeyEncryptException.php',
38
-        'OCA\\Encryption\\Exceptions\\PrivateKeyMissingException' => __DIR__ . '/..' . '/../lib/Exceptions/PrivateKeyMissingException.php',
39
-        'OCA\\Encryption\\Exceptions\\PublicKeyMissingException' => __DIR__ . '/..' . '/../lib/Exceptions/PublicKeyMissingException.php',
40
-        'OCA\\Encryption\\HookManager' => __DIR__ . '/..' . '/../lib/HookManager.php',
41
-        'OCA\\Encryption\\Hooks\\Contracts\\IHook' => __DIR__ . '/..' . '/../lib/Hooks/Contracts/IHook.php',
42
-        'OCA\\Encryption\\Hooks\\UserHooks' => __DIR__ . '/..' . '/../lib/Hooks/UserHooks.php',
43
-        'OCA\\Encryption\\KeyManager' => __DIR__ . '/..' . '/../lib/KeyManager.php',
44
-        'OCA\\Encryption\\Migration\\SetMasterKeyStatus' => __DIR__ . '/..' . '/../lib/Migration/SetMasterKeyStatus.php',
45
-        'OCA\\Encryption\\Recovery' => __DIR__ . '/..' . '/../lib/Recovery.php',
46
-        'OCA\\Encryption\\Session' => __DIR__ . '/..' . '/../lib/Session.php',
47
-        'OCA\\Encryption\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
48
-        'OCA\\Encryption\\Settings\\Personal' => __DIR__ . '/..' . '/../lib/Settings/Personal.php',
49
-        'OCA\\Encryption\\Users\\Setup' => __DIR__ . '/..' . '/../lib/Users/Setup.php',
50
-        'OCA\\Encryption\\Util' => __DIR__ . '/..' . '/../lib/Util.php',
23
+    public static $classMap = array(
24
+        'OCA\\Encryption\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
25
+        'OCA\\Encryption\\Command\\DisableMasterKey' => __DIR__.'/..'.'/../lib/Command/DisableMasterKey.php',
26
+        'OCA\\Encryption\\Command\\EnableMasterKey' => __DIR__.'/..'.'/../lib/Command/EnableMasterKey.php',
27
+        'OCA\\Encryption\\Command\\RecoverUser' => __DIR__.'/..'.'/../lib/Command/RecoverUser.php',
28
+        'OCA\\Encryption\\Command\\ScanLegacyFormat' => __DIR__.'/..'.'/../lib/Command/ScanLegacyFormat.php',
29
+        'OCA\\Encryption\\Controller\\RecoveryController' => __DIR__.'/..'.'/../lib/Controller/RecoveryController.php',
30
+        'OCA\\Encryption\\Controller\\SettingsController' => __DIR__.'/..'.'/../lib/Controller/SettingsController.php',
31
+        'OCA\\Encryption\\Controller\\StatusController' => __DIR__.'/..'.'/../lib/Controller/StatusController.php',
32
+        'OCA\\Encryption\\Crypto\\Crypt' => __DIR__.'/..'.'/../lib/Crypto/Crypt.php',
33
+        'OCA\\Encryption\\Crypto\\DecryptAll' => __DIR__.'/..'.'/../lib/Crypto/DecryptAll.php',
34
+        'OCA\\Encryption\\Crypto\\EncryptAll' => __DIR__.'/..'.'/../lib/Crypto/EncryptAll.php',
35
+        'OCA\\Encryption\\Crypto\\Encryption' => __DIR__.'/..'.'/../lib/Crypto/Encryption.php',
36
+        'OCA\\Encryption\\Exceptions\\MultiKeyDecryptException' => __DIR__.'/..'.'/../lib/Exceptions/MultiKeyDecryptException.php',
37
+        'OCA\\Encryption\\Exceptions\\MultiKeyEncryptException' => __DIR__.'/..'.'/../lib/Exceptions/MultiKeyEncryptException.php',
38
+        'OCA\\Encryption\\Exceptions\\PrivateKeyMissingException' => __DIR__.'/..'.'/../lib/Exceptions/PrivateKeyMissingException.php',
39
+        'OCA\\Encryption\\Exceptions\\PublicKeyMissingException' => __DIR__.'/..'.'/../lib/Exceptions/PublicKeyMissingException.php',
40
+        'OCA\\Encryption\\HookManager' => __DIR__.'/..'.'/../lib/HookManager.php',
41
+        'OCA\\Encryption\\Hooks\\Contracts\\IHook' => __DIR__.'/..'.'/../lib/Hooks/Contracts/IHook.php',
42
+        'OCA\\Encryption\\Hooks\\UserHooks' => __DIR__.'/..'.'/../lib/Hooks/UserHooks.php',
43
+        'OCA\\Encryption\\KeyManager' => __DIR__.'/..'.'/../lib/KeyManager.php',
44
+        'OCA\\Encryption\\Migration\\SetMasterKeyStatus' => __DIR__.'/..'.'/../lib/Migration/SetMasterKeyStatus.php',
45
+        'OCA\\Encryption\\Recovery' => __DIR__.'/..'.'/../lib/Recovery.php',
46
+        'OCA\\Encryption\\Session' => __DIR__.'/..'.'/../lib/Session.php',
47
+        'OCA\\Encryption\\Settings\\Admin' => __DIR__.'/..'.'/../lib/Settings/Admin.php',
48
+        'OCA\\Encryption\\Settings\\Personal' => __DIR__.'/..'.'/../lib/Settings/Personal.php',
49
+        'OCA\\Encryption\\Users\\Setup' => __DIR__.'/..'.'/../lib/Users/Setup.php',
50
+        'OCA\\Encryption\\Util' => __DIR__.'/..'.'/../lib/Util.php',
51 51
     );
52 52
 
53 53
     public static function getInitializer(ClassLoader $loader)
54 54
     {
55
-        return \Closure::bind(function () use ($loader) {
55
+        return \Closure::bind(function() use ($loader) {
56 56
             $loader->prefixLengthsPsr4 = ComposerStaticInitEncryption::$prefixLengthsPsr4;
57 57
             $loader->prefixDirsPsr4 = ComposerStaticInitEncryption::$prefixDirsPsr4;
58 58
             $loader->classMap = ComposerStaticInitEncryption::$classMap;
Please login to merge, or discard this patch.
apps/encryption/lib/Crypto/Crypt.php 1 patch
Indentation   +661 added lines, -661 removed lines patch added patch discarded remove patch
@@ -56,665 +56,665 @@
 block discarded – undo
56 56
  * @package OCA\Encryption\Crypto
57 57
  */
58 58
 class Crypt {
59
-	public const DEFAULT_CIPHER = 'AES-256-CTR';
60
-	// default cipher from old Nextcloud versions
61
-	public const LEGACY_CIPHER = 'AES-128-CFB';
62
-
63
-	// default key format, old Nextcloud version encrypted the private key directly
64
-	// with the user password
65
-	public const LEGACY_KEY_FORMAT = 'password';
66
-
67
-	public const HEADER_START = 'HBEGIN';
68
-	public const HEADER_END = 'HEND';
69
-
70
-	/** @var ILogger */
71
-	private $logger;
72
-
73
-	/** @var string */
74
-	private $user;
75
-
76
-	/** @var IConfig */
77
-	private $config;
78
-
79
-	/** @var array */
80
-	private $supportedKeyFormats;
81
-
82
-	/** @var IL10N */
83
-	private $l;
84
-
85
-	/** @var array */
86
-	private $supportedCiphersAndKeySize = [
87
-		'AES-256-CTR' => 32,
88
-		'AES-128-CTR' => 16,
89
-		'AES-256-CFB' => 32,
90
-		'AES-128-CFB' => 16,
91
-	];
92
-
93
-	/** @var bool */
94
-	private $supportLegacy;
95
-
96
-	/**
97
-	 * @param ILogger $logger
98
-	 * @param IUserSession $userSession
99
-	 * @param IConfig $config
100
-	 * @param IL10N $l
101
-	 */
102
-	public function __construct(ILogger $logger, IUserSession $userSession, IConfig $config, IL10N $l) {
103
-		$this->logger = $logger;
104
-		$this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : '"no user given"';
105
-		$this->config = $config;
106
-		$this->l = $l;
107
-		$this->supportedKeyFormats = ['hash', 'password'];
108
-
109
-		$this->supportLegacy = $this->config->getSystemValueBool('encryption.legacy_format_support', false);
110
-	}
111
-
112
-	/**
113
-	 * create new private/public key-pair for user
114
-	 *
115
-	 * @return array|bool
116
-	 */
117
-	public function createKeyPair() {
118
-		$log = $this->logger;
119
-		$res = $this->getOpenSSLPKey();
120
-
121
-		if (!$res) {
122
-			$log->error("Encryption Library couldn't generate users key-pair for {$this->user}",
123
-				['app' => 'encryption']);
124
-
125
-			if (openssl_error_string()) {
126
-				$log->error('Encryption library openssl_pkey_new() fails: ' . openssl_error_string(),
127
-					['app' => 'encryption']);
128
-			}
129
-		} elseif (openssl_pkey_export($res,
130
-			$privateKey,
131
-			null,
132
-			$this->getOpenSSLConfig())) {
133
-			$keyDetails = openssl_pkey_get_details($res);
134
-			$publicKey = $keyDetails['key'];
135
-
136
-			return [
137
-				'publicKey' => $publicKey,
138
-				'privateKey' => $privateKey
139
-			];
140
-		}
141
-		$log->error('Encryption library couldn\'t export users private key, please check your servers OpenSSL configuration.' . $this->user,
142
-			['app' => 'encryption']);
143
-		if (openssl_error_string()) {
144
-			$log->error('Encryption Library:' . openssl_error_string(),
145
-				['app' => 'encryption']);
146
-		}
147
-
148
-		return false;
149
-	}
150
-
151
-	/**
152
-	 * Generates a new private key
153
-	 *
154
-	 * @return resource
155
-	 */
156
-	public function getOpenSSLPKey() {
157
-		$config = $this->getOpenSSLConfig();
158
-		return openssl_pkey_new($config);
159
-	}
160
-
161
-	/**
162
-	 * get openSSL Config
163
-	 *
164
-	 * @return array
165
-	 */
166
-	private function getOpenSSLConfig() {
167
-		$config = ['private_key_bits' => 4096];
168
-		$config = array_merge(
169
-			$config,
170
-			$this->config->getSystemValue('openssl', [])
171
-		);
172
-		return $config;
173
-	}
174
-
175
-	/**
176
-	 * @param string $plainContent
177
-	 * @param string $passPhrase
178
-	 * @param int $version
179
-	 * @param int $position
180
-	 * @return false|string
181
-	 * @throws EncryptionFailedException
182
-	 */
183
-	public function symmetricEncryptFileContent($plainContent, $passPhrase, $version, $position) {
184
-		if (!$plainContent) {
185
-			$this->logger->error('Encryption Library, symmetrical encryption failed no content given',
186
-				['app' => 'encryption']);
187
-			return false;
188
-		}
189
-
190
-		$iv = $this->generateIv();
191
-
192
-		$encryptedContent = $this->encrypt($plainContent,
193
-			$iv,
194
-			$passPhrase,
195
-			$this->getCipher());
196
-
197
-		// Create a signature based on the key as well as the current version
198
-		$sig = $this->createSignature($encryptedContent, $passPhrase.'_'.$version.'_'.$position);
199
-
200
-		// combine content to encrypt the IV identifier and actual IV
201
-		$catFile = $this->concatIV($encryptedContent, $iv);
202
-		$catFile = $this->concatSig($catFile, $sig);
203
-		return $this->addPadding($catFile);
204
-	}
205
-
206
-	/**
207
-	 * generate header for encrypted file
208
-	 *
209
-	 * @param string $keyFormat (can be 'hash' or 'password')
210
-	 * @return string
211
-	 * @throws \InvalidArgumentException
212
-	 */
213
-	public function generateHeader($keyFormat = 'hash') {
214
-		if (in_array($keyFormat, $this->supportedKeyFormats, true) === false) {
215
-			throw new \InvalidArgumentException('key format "' . $keyFormat . '" is not supported');
216
-		}
217
-
218
-		$cipher = $this->getCipher();
219
-
220
-		$header = self::HEADER_START
221
-			. ':cipher:' . $cipher
222
-			. ':keyFormat:' . $keyFormat
223
-			. ':' . self::HEADER_END;
224
-
225
-		return $header;
226
-	}
227
-
228
-	/**
229
-	 * @param string $plainContent
230
-	 * @param string $iv
231
-	 * @param string $passPhrase
232
-	 * @param string $cipher
233
-	 * @return string
234
-	 * @throws EncryptionFailedException
235
-	 */
236
-	private function encrypt($plainContent, $iv, $passPhrase = '', $cipher = self::DEFAULT_CIPHER) {
237
-		$encryptedContent = openssl_encrypt($plainContent,
238
-			$cipher,
239
-			$passPhrase,
240
-			false,
241
-			$iv);
242
-
243
-		if (!$encryptedContent) {
244
-			$error = 'Encryption (symmetric) of content failed';
245
-			$this->logger->error($error . openssl_error_string(),
246
-				['app' => 'encryption']);
247
-			throw new EncryptionFailedException($error);
248
-		}
249
-
250
-		return $encryptedContent;
251
-	}
252
-
253
-	/**
254
-	 * return Cipher either from config.php or the default cipher defined in
255
-	 * this class
256
-	 *
257
-	 * @return string
258
-	 */
259
-	public function getCipher() {
260
-		$cipher = $this->config->getSystemValue('cipher', self::DEFAULT_CIPHER);
261
-		if (!isset($this->supportedCiphersAndKeySize[$cipher])) {
262
-			$this->logger->warning(
263
-					sprintf(
264
-							'Unsupported cipher (%s) defined in config.php supported. Falling back to %s',
265
-							$cipher,
266
-							self::DEFAULT_CIPHER
267
-					),
268
-				['app' => 'encryption']);
269
-			$cipher = self::DEFAULT_CIPHER;
270
-		}
271
-
272
-		// Workaround for OpenSSL 0.9.8. Fallback to an old cipher that should work.
273
-		if (OPENSSL_VERSION_NUMBER < 0x1000101f) {
274
-			if ($cipher === 'AES-256-CTR' || $cipher === 'AES-128-CTR') {
275
-				$cipher = self::LEGACY_CIPHER;
276
-			}
277
-		}
278
-
279
-		return $cipher;
280
-	}
281
-
282
-	/**
283
-	 * get key size depending on the cipher
284
-	 *
285
-	 * @param string $cipher
286
-	 * @return int
287
-	 * @throws \InvalidArgumentException
288
-	 */
289
-	protected function getKeySize($cipher) {
290
-		if (isset($this->supportedCiphersAndKeySize[$cipher])) {
291
-			return $this->supportedCiphersAndKeySize[$cipher];
292
-		}
293
-
294
-		throw new \InvalidArgumentException(
295
-			sprintf(
296
-					'Unsupported cipher (%s) defined.',
297
-					$cipher
298
-			)
299
-		);
300
-	}
301
-
302
-	/**
303
-	 * get legacy cipher
304
-	 *
305
-	 * @return string
306
-	 */
307
-	public function getLegacyCipher() {
308
-		if (!$this->supportLegacy) {
309
-			throw new ServerNotAvailableException('Legacy cipher is no longer supported!');
310
-		}
311
-
312
-		return self::LEGACY_CIPHER;
313
-	}
314
-
315
-	/**
316
-	 * @param string $encryptedContent
317
-	 * @param string $iv
318
-	 * @return string
319
-	 */
320
-	private function concatIV($encryptedContent, $iv) {
321
-		return $encryptedContent . '00iv00' . $iv;
322
-	}
323
-
324
-	/**
325
-	 * @param string $encryptedContent
326
-	 * @param string $signature
327
-	 * @return string
328
-	 */
329
-	private function concatSig($encryptedContent, $signature) {
330
-		return $encryptedContent . '00sig00' . $signature;
331
-	}
332
-
333
-	/**
334
-	 * Note: This is _NOT_ a padding used for encryption purposes. It is solely
335
-	 * used to achieve the PHP stream size. It has _NOTHING_ to do with the
336
-	 * encrypted content and is not used in any crypto primitive.
337
-	 *
338
-	 * @param string $data
339
-	 * @return string
340
-	 */
341
-	private function addPadding($data) {
342
-		return $data . 'xxx';
343
-	}
344
-
345
-	/**
346
-	 * generate password hash used to encrypt the users private key
347
-	 *
348
-	 * @param string $password
349
-	 * @param string $cipher
350
-	 * @param string $uid only used for user keys
351
-	 * @return string
352
-	 */
353
-	protected function generatePasswordHash($password, $cipher, $uid = '') {
354
-		$instanceId = $this->config->getSystemValue('instanceid');
355
-		$instanceSecret = $this->config->getSystemValue('secret');
356
-		$salt = hash('sha256', $uid . $instanceId . $instanceSecret, true);
357
-		$keySize = $this->getKeySize($cipher);
358
-
359
-		$hash = hash_pbkdf2(
360
-			'sha256',
361
-			$password,
362
-			$salt,
363
-			100000,
364
-			$keySize,
365
-			true
366
-		);
367
-
368
-		return $hash;
369
-	}
370
-
371
-	/**
372
-	 * encrypt private key
373
-	 *
374
-	 * @param string $privateKey
375
-	 * @param string $password
376
-	 * @param string $uid for regular users, empty for system keys
377
-	 * @return false|string
378
-	 */
379
-	public function encryptPrivateKey($privateKey, $password, $uid = '') {
380
-		$cipher = $this->getCipher();
381
-		$hash = $this->generatePasswordHash($password, $cipher, $uid);
382
-		$encryptedKey = $this->symmetricEncryptFileContent(
383
-			$privateKey,
384
-			$hash,
385
-			0,
386
-			0
387
-		);
388
-
389
-		return $encryptedKey;
390
-	}
391
-
392
-	/**
393
-	 * @param string $privateKey
394
-	 * @param string $password
395
-	 * @param string $uid for regular users, empty for system keys
396
-	 * @return false|string
397
-	 */
398
-	public function decryptPrivateKey($privateKey, $password = '', $uid = '') {
399
-		$header = $this->parseHeader($privateKey);
400
-
401
-		if (isset($header['cipher'])) {
402
-			$cipher = $header['cipher'];
403
-		} else {
404
-			$cipher = $this->getLegacyCipher();
405
-		}
406
-
407
-		if (isset($header['keyFormat'])) {
408
-			$keyFormat = $header['keyFormat'];
409
-		} else {
410
-			$keyFormat = self::LEGACY_KEY_FORMAT;
411
-		}
412
-
413
-		if ($keyFormat === 'hash') {
414
-			$password = $this->generatePasswordHash($password, $cipher, $uid);
415
-		}
416
-
417
-		// If we found a header we need to remove it from the key we want to decrypt
418
-		if (!empty($header)) {
419
-			$privateKey = substr($privateKey,
420
-				strpos($privateKey,
421
-					self::HEADER_END) + strlen(self::HEADER_END));
422
-		}
423
-
424
-		$plainKey = $this->symmetricDecryptFileContent(
425
-			$privateKey,
426
-			$password,
427
-			$cipher,
428
-			0
429
-		);
430
-
431
-		if ($this->isValidPrivateKey($plainKey) === false) {
432
-			return false;
433
-		}
434
-
435
-		return $plainKey;
436
-	}
437
-
438
-	/**
439
-	 * check if it is a valid private key
440
-	 *
441
-	 * @param string $plainKey
442
-	 * @return bool
443
-	 */
444
-	protected function isValidPrivateKey($plainKey) {
445
-		$res = openssl_get_privatekey($plainKey);
446
-		if (is_resource($res)) {
447
-			$sslInfo = openssl_pkey_get_details($res);
448
-			if (isset($sslInfo['key'])) {
449
-				return true;
450
-			}
451
-		}
452
-
453
-		return false;
454
-	}
455
-
456
-	/**
457
-	 * @param string $keyFileContents
458
-	 * @param string $passPhrase
459
-	 * @param string $cipher
460
-	 * @param int $version
461
-	 * @param int $position
462
-	 * @return string
463
-	 * @throws DecryptionFailedException
464
-	 */
465
-	public function symmetricDecryptFileContent($keyFileContents, $passPhrase, $cipher = self::DEFAULT_CIPHER, $version = 0, $position = 0) {
466
-		if ($keyFileContents == '') {
467
-			return '';
468
-		}
469
-
470
-		$catFile = $this->splitMetaData($keyFileContents, $cipher);
471
-
472
-		if ($catFile['signature'] !== false) {
473
-			try {
474
-				// First try the new format
475
-				$this->checkSignature($catFile['encrypted'], $passPhrase . '_' . $version . '_' . $position, $catFile['signature']);
476
-			} catch (GenericEncryptionException $e) {
477
-				// For compatibility with old files check the version without _
478
-				$this->checkSignature($catFile['encrypted'], $passPhrase . $version . $position, $catFile['signature']);
479
-			}
480
-		}
481
-
482
-		return $this->decrypt($catFile['encrypted'],
483
-			$catFile['iv'],
484
-			$passPhrase,
485
-			$cipher);
486
-	}
487
-
488
-	/**
489
-	 * check for valid signature
490
-	 *
491
-	 * @param string $data
492
-	 * @param string $passPhrase
493
-	 * @param string $expectedSignature
494
-	 * @throws GenericEncryptionException
495
-	 */
496
-	private function checkSignature($data, $passPhrase, $expectedSignature) {
497
-		$enforceSignature = !$this->config->getSystemValue('encryption_skip_signature_check', false);
498
-
499
-		$signature = $this->createSignature($data, $passPhrase);
500
-		$isCorrectHash = hash_equals($expectedSignature, $signature);
501
-
502
-		if (!$isCorrectHash && $enforceSignature) {
503
-			throw new GenericEncryptionException('Bad Signature', $this->l->t('Bad Signature'));
504
-		} elseif (!$isCorrectHash && !$enforceSignature) {
505
-			$this->logger->info("Signature check skipped", ['app' => 'encryption']);
506
-		}
507
-	}
508
-
509
-	/**
510
-	 * create signature
511
-	 *
512
-	 * @param string $data
513
-	 * @param string $passPhrase
514
-	 * @return string
515
-	 */
516
-	private function createSignature($data, $passPhrase) {
517
-		$passPhrase = hash('sha512', $passPhrase . 'a', true);
518
-		return hash_hmac('sha256', $data, $passPhrase);
519
-	}
520
-
521
-
522
-	/**
523
-	 * remove padding
524
-	 *
525
-	 * @param string $padded
526
-	 * @param bool $hasSignature did the block contain a signature, in this case we use a different padding
527
-	 * @return string|false
528
-	 */
529
-	private function removePadding($padded, $hasSignature = false) {
530
-		if ($hasSignature === false && substr($padded, -2) === 'xx') {
531
-			return substr($padded, 0, -2);
532
-		} elseif ($hasSignature === true && substr($padded, -3) === 'xxx') {
533
-			return substr($padded, 0, -3);
534
-		}
535
-		return false;
536
-	}
537
-
538
-	/**
539
-	 * split meta data from encrypted file
540
-	 * Note: for now, we assume that the meta data always start with the iv
541
-	 *       followed by the signature, if available
542
-	 *
543
-	 * @param string $catFile
544
-	 * @param string $cipher
545
-	 * @return array
546
-	 */
547
-	private function splitMetaData($catFile, $cipher) {
548
-		if ($this->hasSignature($catFile, $cipher)) {
549
-			$catFile = $this->removePadding($catFile, true);
550
-			$meta = substr($catFile, -93);
551
-			$iv = substr($meta, strlen('00iv00'), 16);
552
-			$sig = substr($meta, 22 + strlen('00sig00'));
553
-			$encrypted = substr($catFile, 0, -93);
554
-		} else {
555
-			$catFile = $this->removePadding($catFile);
556
-			$meta = substr($catFile, -22);
557
-			$iv = substr($meta, -16);
558
-			$sig = false;
559
-			$encrypted = substr($catFile, 0, -22);
560
-		}
561
-
562
-		return [
563
-			'encrypted' => $encrypted,
564
-			'iv' => $iv,
565
-			'signature' => $sig
566
-		];
567
-	}
568
-
569
-	/**
570
-	 * check if encrypted block is signed
571
-	 *
572
-	 * @param string $catFile
573
-	 * @param string $cipher
574
-	 * @return bool
575
-	 * @throws GenericEncryptionException
576
-	 */
577
-	private function hasSignature($catFile, $cipher) {
578
-		$skipSignatureCheck = $this->config->getSystemValue('encryption_skip_signature_check', false);
579
-
580
-		$meta = substr($catFile, -93);
581
-		$signaturePosition = strpos($meta, '00sig00');
582
-
583
-		// If we no longer support the legacy format then everything needs a signature
584
-		if (!$skipSignatureCheck && !$this->supportLegacy && $signaturePosition === false) {
585
-			throw new GenericEncryptionException('Missing Signature', $this->l->t('Missing Signature'));
586
-		}
587
-
588
-		// enforce signature for the new 'CTR' ciphers
589
-		if (!$skipSignatureCheck && $signaturePosition === false && stripos($cipher, 'ctr') !== false) {
590
-			throw new GenericEncryptionException('Missing Signature', $this->l->t('Missing Signature'));
591
-		}
592
-
593
-		return ($signaturePosition !== false);
594
-	}
595
-
596
-
597
-	/**
598
-	 * @param string $encryptedContent
599
-	 * @param string $iv
600
-	 * @param string $passPhrase
601
-	 * @param string $cipher
602
-	 * @return string
603
-	 * @throws DecryptionFailedException
604
-	 */
605
-	private function decrypt($encryptedContent, $iv, $passPhrase = '', $cipher = self::DEFAULT_CIPHER) {
606
-		$plainContent = openssl_decrypt($encryptedContent,
607
-			$cipher,
608
-			$passPhrase,
609
-			false,
610
-			$iv);
611
-
612
-		if ($plainContent) {
613
-			return $plainContent;
614
-		} else {
615
-			throw new DecryptionFailedException('Encryption library: Decryption (symmetric) of content failed: ' . openssl_error_string());
616
-		}
617
-	}
618
-
619
-	/**
620
-	 * @param string $data
621
-	 * @return array
622
-	 */
623
-	protected function parseHeader($data) {
624
-		$result = [];
625
-
626
-		if (substr($data, 0, strlen(self::HEADER_START)) === self::HEADER_START) {
627
-			$endAt = strpos($data, self::HEADER_END);
628
-			$header = substr($data, 0, $endAt + strlen(self::HEADER_END));
629
-
630
-			// +1 not to start with an ':' which would result in empty element at the beginning
631
-			$exploded = explode(':',
632
-				substr($header, strlen(self::HEADER_START) + 1));
633
-
634
-			$element = array_shift($exploded);
635
-
636
-			while ($element !== self::HEADER_END) {
637
-				$result[$element] = array_shift($exploded);
638
-				$element = array_shift($exploded);
639
-			}
640
-		}
641
-
642
-		return $result;
643
-	}
644
-
645
-	/**
646
-	 * generate initialization vector
647
-	 *
648
-	 * @return string
649
-	 * @throws GenericEncryptionException
650
-	 */
651
-	private function generateIv() {
652
-		return random_bytes(16);
653
-	}
654
-
655
-	/**
656
-	 * Generate a cryptographically secure pseudo-random 256-bit ASCII key, used
657
-	 * as file key
658
-	 *
659
-	 * @return string
660
-	 * @throws \Exception
661
-	 */
662
-	public function generateFileKey() {
663
-		return random_bytes(32);
664
-	}
665
-
666
-	/**
667
-	 * @param $encKeyFile
668
-	 * @param $shareKey
669
-	 * @param $privateKey
670
-	 * @return string
671
-	 * @throws MultiKeyDecryptException
672
-	 */
673
-	public function multiKeyDecrypt($encKeyFile, $shareKey, $privateKey) {
674
-		if (!$encKeyFile) {
675
-			throw new MultiKeyDecryptException('Cannot multikey decrypt empty plain content');
676
-		}
677
-
678
-		if (openssl_open($encKeyFile, $plainContent, $shareKey, $privateKey)) {
679
-			return $plainContent;
680
-		} else {
681
-			throw new MultiKeyDecryptException('multikeydecrypt with share key failed:' . openssl_error_string());
682
-		}
683
-	}
684
-
685
-	/**
686
-	 * @param string $plainContent
687
-	 * @param array $keyFiles
688
-	 * @return array
689
-	 * @throws MultiKeyEncryptException
690
-	 */
691
-	public function multiKeyEncrypt($plainContent, array $keyFiles) {
692
-		// openssl_seal returns false without errors if plaincontent is empty
693
-		// so trigger our own error
694
-		if (empty($plainContent)) {
695
-			throw new MultiKeyEncryptException('Cannot multikeyencrypt empty plain content');
696
-		}
697
-
698
-		// Set empty vars to be set by openssl by reference
699
-		$sealed = '';
700
-		$shareKeys = [];
701
-		$mappedShareKeys = [];
702
-
703
-		if (openssl_seal($plainContent, $sealed, $shareKeys, $keyFiles)) {
704
-			$i = 0;
705
-
706
-			// Ensure each shareKey is labelled with its corresponding key id
707
-			foreach ($keyFiles as $userId => $publicKey) {
708
-				$mappedShareKeys[$userId] = $shareKeys[$i];
709
-				$i++;
710
-			}
711
-
712
-			return [
713
-				'keys' => $mappedShareKeys,
714
-				'data' => $sealed
715
-			];
716
-		} else {
717
-			throw new MultiKeyEncryptException('multikeyencryption failed ' . openssl_error_string());
718
-		}
719
-	}
59
+    public const DEFAULT_CIPHER = 'AES-256-CTR';
60
+    // default cipher from old Nextcloud versions
61
+    public const LEGACY_CIPHER = 'AES-128-CFB';
62
+
63
+    // default key format, old Nextcloud version encrypted the private key directly
64
+    // with the user password
65
+    public const LEGACY_KEY_FORMAT = 'password';
66
+
67
+    public const HEADER_START = 'HBEGIN';
68
+    public const HEADER_END = 'HEND';
69
+
70
+    /** @var ILogger */
71
+    private $logger;
72
+
73
+    /** @var string */
74
+    private $user;
75
+
76
+    /** @var IConfig */
77
+    private $config;
78
+
79
+    /** @var array */
80
+    private $supportedKeyFormats;
81
+
82
+    /** @var IL10N */
83
+    private $l;
84
+
85
+    /** @var array */
86
+    private $supportedCiphersAndKeySize = [
87
+        'AES-256-CTR' => 32,
88
+        'AES-128-CTR' => 16,
89
+        'AES-256-CFB' => 32,
90
+        'AES-128-CFB' => 16,
91
+    ];
92
+
93
+    /** @var bool */
94
+    private $supportLegacy;
95
+
96
+    /**
97
+     * @param ILogger $logger
98
+     * @param IUserSession $userSession
99
+     * @param IConfig $config
100
+     * @param IL10N $l
101
+     */
102
+    public function __construct(ILogger $logger, IUserSession $userSession, IConfig $config, IL10N $l) {
103
+        $this->logger = $logger;
104
+        $this->user = $userSession && $userSession->isLoggedIn() ? $userSession->getUser()->getUID() : '"no user given"';
105
+        $this->config = $config;
106
+        $this->l = $l;
107
+        $this->supportedKeyFormats = ['hash', 'password'];
108
+
109
+        $this->supportLegacy = $this->config->getSystemValueBool('encryption.legacy_format_support', false);
110
+    }
111
+
112
+    /**
113
+     * create new private/public key-pair for user
114
+     *
115
+     * @return array|bool
116
+     */
117
+    public function createKeyPair() {
118
+        $log = $this->logger;
119
+        $res = $this->getOpenSSLPKey();
120
+
121
+        if (!$res) {
122
+            $log->error("Encryption Library couldn't generate users key-pair for {$this->user}",
123
+                ['app' => 'encryption']);
124
+
125
+            if (openssl_error_string()) {
126
+                $log->error('Encryption library openssl_pkey_new() fails: ' . openssl_error_string(),
127
+                    ['app' => 'encryption']);
128
+            }
129
+        } elseif (openssl_pkey_export($res,
130
+            $privateKey,
131
+            null,
132
+            $this->getOpenSSLConfig())) {
133
+            $keyDetails = openssl_pkey_get_details($res);
134
+            $publicKey = $keyDetails['key'];
135
+
136
+            return [
137
+                'publicKey' => $publicKey,
138
+                'privateKey' => $privateKey
139
+            ];
140
+        }
141
+        $log->error('Encryption library couldn\'t export users private key, please check your servers OpenSSL configuration.' . $this->user,
142
+            ['app' => 'encryption']);
143
+        if (openssl_error_string()) {
144
+            $log->error('Encryption Library:' . openssl_error_string(),
145
+                ['app' => 'encryption']);
146
+        }
147
+
148
+        return false;
149
+    }
150
+
151
+    /**
152
+     * Generates a new private key
153
+     *
154
+     * @return resource
155
+     */
156
+    public function getOpenSSLPKey() {
157
+        $config = $this->getOpenSSLConfig();
158
+        return openssl_pkey_new($config);
159
+    }
160
+
161
+    /**
162
+     * get openSSL Config
163
+     *
164
+     * @return array
165
+     */
166
+    private function getOpenSSLConfig() {
167
+        $config = ['private_key_bits' => 4096];
168
+        $config = array_merge(
169
+            $config,
170
+            $this->config->getSystemValue('openssl', [])
171
+        );
172
+        return $config;
173
+    }
174
+
175
+    /**
176
+     * @param string $plainContent
177
+     * @param string $passPhrase
178
+     * @param int $version
179
+     * @param int $position
180
+     * @return false|string
181
+     * @throws EncryptionFailedException
182
+     */
183
+    public function symmetricEncryptFileContent($plainContent, $passPhrase, $version, $position) {
184
+        if (!$plainContent) {
185
+            $this->logger->error('Encryption Library, symmetrical encryption failed no content given',
186
+                ['app' => 'encryption']);
187
+            return false;
188
+        }
189
+
190
+        $iv = $this->generateIv();
191
+
192
+        $encryptedContent = $this->encrypt($plainContent,
193
+            $iv,
194
+            $passPhrase,
195
+            $this->getCipher());
196
+
197
+        // Create a signature based on the key as well as the current version
198
+        $sig = $this->createSignature($encryptedContent, $passPhrase.'_'.$version.'_'.$position);
199
+
200
+        // combine content to encrypt the IV identifier and actual IV
201
+        $catFile = $this->concatIV($encryptedContent, $iv);
202
+        $catFile = $this->concatSig($catFile, $sig);
203
+        return $this->addPadding($catFile);
204
+    }
205
+
206
+    /**
207
+     * generate header for encrypted file
208
+     *
209
+     * @param string $keyFormat (can be 'hash' or 'password')
210
+     * @return string
211
+     * @throws \InvalidArgumentException
212
+     */
213
+    public function generateHeader($keyFormat = 'hash') {
214
+        if (in_array($keyFormat, $this->supportedKeyFormats, true) === false) {
215
+            throw new \InvalidArgumentException('key format "' . $keyFormat . '" is not supported');
216
+        }
217
+
218
+        $cipher = $this->getCipher();
219
+
220
+        $header = self::HEADER_START
221
+            . ':cipher:' . $cipher
222
+            . ':keyFormat:' . $keyFormat
223
+            . ':' . self::HEADER_END;
224
+
225
+        return $header;
226
+    }
227
+
228
+    /**
229
+     * @param string $plainContent
230
+     * @param string $iv
231
+     * @param string $passPhrase
232
+     * @param string $cipher
233
+     * @return string
234
+     * @throws EncryptionFailedException
235
+     */
236
+    private function encrypt($plainContent, $iv, $passPhrase = '', $cipher = self::DEFAULT_CIPHER) {
237
+        $encryptedContent = openssl_encrypt($plainContent,
238
+            $cipher,
239
+            $passPhrase,
240
+            false,
241
+            $iv);
242
+
243
+        if (!$encryptedContent) {
244
+            $error = 'Encryption (symmetric) of content failed';
245
+            $this->logger->error($error . openssl_error_string(),
246
+                ['app' => 'encryption']);
247
+            throw new EncryptionFailedException($error);
248
+        }
249
+
250
+        return $encryptedContent;
251
+    }
252
+
253
+    /**
254
+     * return Cipher either from config.php or the default cipher defined in
255
+     * this class
256
+     *
257
+     * @return string
258
+     */
259
+    public function getCipher() {
260
+        $cipher = $this->config->getSystemValue('cipher', self::DEFAULT_CIPHER);
261
+        if (!isset($this->supportedCiphersAndKeySize[$cipher])) {
262
+            $this->logger->warning(
263
+                    sprintf(
264
+                            'Unsupported cipher (%s) defined in config.php supported. Falling back to %s',
265
+                            $cipher,
266
+                            self::DEFAULT_CIPHER
267
+                    ),
268
+                ['app' => 'encryption']);
269
+            $cipher = self::DEFAULT_CIPHER;
270
+        }
271
+
272
+        // Workaround for OpenSSL 0.9.8. Fallback to an old cipher that should work.
273
+        if (OPENSSL_VERSION_NUMBER < 0x1000101f) {
274
+            if ($cipher === 'AES-256-CTR' || $cipher === 'AES-128-CTR') {
275
+                $cipher = self::LEGACY_CIPHER;
276
+            }
277
+        }
278
+
279
+        return $cipher;
280
+    }
281
+
282
+    /**
283
+     * get key size depending on the cipher
284
+     *
285
+     * @param string $cipher
286
+     * @return int
287
+     * @throws \InvalidArgumentException
288
+     */
289
+    protected function getKeySize($cipher) {
290
+        if (isset($this->supportedCiphersAndKeySize[$cipher])) {
291
+            return $this->supportedCiphersAndKeySize[$cipher];
292
+        }
293
+
294
+        throw new \InvalidArgumentException(
295
+            sprintf(
296
+                    'Unsupported cipher (%s) defined.',
297
+                    $cipher
298
+            )
299
+        );
300
+    }
301
+
302
+    /**
303
+     * get legacy cipher
304
+     *
305
+     * @return string
306
+     */
307
+    public function getLegacyCipher() {
308
+        if (!$this->supportLegacy) {
309
+            throw new ServerNotAvailableException('Legacy cipher is no longer supported!');
310
+        }
311
+
312
+        return self::LEGACY_CIPHER;
313
+    }
314
+
315
+    /**
316
+     * @param string $encryptedContent
317
+     * @param string $iv
318
+     * @return string
319
+     */
320
+    private function concatIV($encryptedContent, $iv) {
321
+        return $encryptedContent . '00iv00' . $iv;
322
+    }
323
+
324
+    /**
325
+     * @param string $encryptedContent
326
+     * @param string $signature
327
+     * @return string
328
+     */
329
+    private function concatSig($encryptedContent, $signature) {
330
+        return $encryptedContent . '00sig00' . $signature;
331
+    }
332
+
333
+    /**
334
+     * Note: This is _NOT_ a padding used for encryption purposes. It is solely
335
+     * used to achieve the PHP stream size. It has _NOTHING_ to do with the
336
+     * encrypted content and is not used in any crypto primitive.
337
+     *
338
+     * @param string $data
339
+     * @return string
340
+     */
341
+    private function addPadding($data) {
342
+        return $data . 'xxx';
343
+    }
344
+
345
+    /**
346
+     * generate password hash used to encrypt the users private key
347
+     *
348
+     * @param string $password
349
+     * @param string $cipher
350
+     * @param string $uid only used for user keys
351
+     * @return string
352
+     */
353
+    protected function generatePasswordHash($password, $cipher, $uid = '') {
354
+        $instanceId = $this->config->getSystemValue('instanceid');
355
+        $instanceSecret = $this->config->getSystemValue('secret');
356
+        $salt = hash('sha256', $uid . $instanceId . $instanceSecret, true);
357
+        $keySize = $this->getKeySize($cipher);
358
+
359
+        $hash = hash_pbkdf2(
360
+            'sha256',
361
+            $password,
362
+            $salt,
363
+            100000,
364
+            $keySize,
365
+            true
366
+        );
367
+
368
+        return $hash;
369
+    }
370
+
371
+    /**
372
+     * encrypt private key
373
+     *
374
+     * @param string $privateKey
375
+     * @param string $password
376
+     * @param string $uid for regular users, empty for system keys
377
+     * @return false|string
378
+     */
379
+    public function encryptPrivateKey($privateKey, $password, $uid = '') {
380
+        $cipher = $this->getCipher();
381
+        $hash = $this->generatePasswordHash($password, $cipher, $uid);
382
+        $encryptedKey = $this->symmetricEncryptFileContent(
383
+            $privateKey,
384
+            $hash,
385
+            0,
386
+            0
387
+        );
388
+
389
+        return $encryptedKey;
390
+    }
391
+
392
+    /**
393
+     * @param string $privateKey
394
+     * @param string $password
395
+     * @param string $uid for regular users, empty for system keys
396
+     * @return false|string
397
+     */
398
+    public function decryptPrivateKey($privateKey, $password = '', $uid = '') {
399
+        $header = $this->parseHeader($privateKey);
400
+
401
+        if (isset($header['cipher'])) {
402
+            $cipher = $header['cipher'];
403
+        } else {
404
+            $cipher = $this->getLegacyCipher();
405
+        }
406
+
407
+        if (isset($header['keyFormat'])) {
408
+            $keyFormat = $header['keyFormat'];
409
+        } else {
410
+            $keyFormat = self::LEGACY_KEY_FORMAT;
411
+        }
412
+
413
+        if ($keyFormat === 'hash') {
414
+            $password = $this->generatePasswordHash($password, $cipher, $uid);
415
+        }
416
+
417
+        // If we found a header we need to remove it from the key we want to decrypt
418
+        if (!empty($header)) {
419
+            $privateKey = substr($privateKey,
420
+                strpos($privateKey,
421
+                    self::HEADER_END) + strlen(self::HEADER_END));
422
+        }
423
+
424
+        $plainKey = $this->symmetricDecryptFileContent(
425
+            $privateKey,
426
+            $password,
427
+            $cipher,
428
+            0
429
+        );
430
+
431
+        if ($this->isValidPrivateKey($plainKey) === false) {
432
+            return false;
433
+        }
434
+
435
+        return $plainKey;
436
+    }
437
+
438
+    /**
439
+     * check if it is a valid private key
440
+     *
441
+     * @param string $plainKey
442
+     * @return bool
443
+     */
444
+    protected function isValidPrivateKey($plainKey) {
445
+        $res = openssl_get_privatekey($plainKey);
446
+        if (is_resource($res)) {
447
+            $sslInfo = openssl_pkey_get_details($res);
448
+            if (isset($sslInfo['key'])) {
449
+                return true;
450
+            }
451
+        }
452
+
453
+        return false;
454
+    }
455
+
456
+    /**
457
+     * @param string $keyFileContents
458
+     * @param string $passPhrase
459
+     * @param string $cipher
460
+     * @param int $version
461
+     * @param int $position
462
+     * @return string
463
+     * @throws DecryptionFailedException
464
+     */
465
+    public function symmetricDecryptFileContent($keyFileContents, $passPhrase, $cipher = self::DEFAULT_CIPHER, $version = 0, $position = 0) {
466
+        if ($keyFileContents == '') {
467
+            return '';
468
+        }
469
+
470
+        $catFile = $this->splitMetaData($keyFileContents, $cipher);
471
+
472
+        if ($catFile['signature'] !== false) {
473
+            try {
474
+                // First try the new format
475
+                $this->checkSignature($catFile['encrypted'], $passPhrase . '_' . $version . '_' . $position, $catFile['signature']);
476
+            } catch (GenericEncryptionException $e) {
477
+                // For compatibility with old files check the version without _
478
+                $this->checkSignature($catFile['encrypted'], $passPhrase . $version . $position, $catFile['signature']);
479
+            }
480
+        }
481
+
482
+        return $this->decrypt($catFile['encrypted'],
483
+            $catFile['iv'],
484
+            $passPhrase,
485
+            $cipher);
486
+    }
487
+
488
+    /**
489
+     * check for valid signature
490
+     *
491
+     * @param string $data
492
+     * @param string $passPhrase
493
+     * @param string $expectedSignature
494
+     * @throws GenericEncryptionException
495
+     */
496
+    private function checkSignature($data, $passPhrase, $expectedSignature) {
497
+        $enforceSignature = !$this->config->getSystemValue('encryption_skip_signature_check', false);
498
+
499
+        $signature = $this->createSignature($data, $passPhrase);
500
+        $isCorrectHash = hash_equals($expectedSignature, $signature);
501
+
502
+        if (!$isCorrectHash && $enforceSignature) {
503
+            throw new GenericEncryptionException('Bad Signature', $this->l->t('Bad Signature'));
504
+        } elseif (!$isCorrectHash && !$enforceSignature) {
505
+            $this->logger->info("Signature check skipped", ['app' => 'encryption']);
506
+        }
507
+    }
508
+
509
+    /**
510
+     * create signature
511
+     *
512
+     * @param string $data
513
+     * @param string $passPhrase
514
+     * @return string
515
+     */
516
+    private function createSignature($data, $passPhrase) {
517
+        $passPhrase = hash('sha512', $passPhrase . 'a', true);
518
+        return hash_hmac('sha256', $data, $passPhrase);
519
+    }
520
+
521
+
522
+    /**
523
+     * remove padding
524
+     *
525
+     * @param string $padded
526
+     * @param bool $hasSignature did the block contain a signature, in this case we use a different padding
527
+     * @return string|false
528
+     */
529
+    private function removePadding($padded, $hasSignature = false) {
530
+        if ($hasSignature === false && substr($padded, -2) === 'xx') {
531
+            return substr($padded, 0, -2);
532
+        } elseif ($hasSignature === true && substr($padded, -3) === 'xxx') {
533
+            return substr($padded, 0, -3);
534
+        }
535
+        return false;
536
+    }
537
+
538
+    /**
539
+     * split meta data from encrypted file
540
+     * Note: for now, we assume that the meta data always start with the iv
541
+     *       followed by the signature, if available
542
+     *
543
+     * @param string $catFile
544
+     * @param string $cipher
545
+     * @return array
546
+     */
547
+    private function splitMetaData($catFile, $cipher) {
548
+        if ($this->hasSignature($catFile, $cipher)) {
549
+            $catFile = $this->removePadding($catFile, true);
550
+            $meta = substr($catFile, -93);
551
+            $iv = substr($meta, strlen('00iv00'), 16);
552
+            $sig = substr($meta, 22 + strlen('00sig00'));
553
+            $encrypted = substr($catFile, 0, -93);
554
+        } else {
555
+            $catFile = $this->removePadding($catFile);
556
+            $meta = substr($catFile, -22);
557
+            $iv = substr($meta, -16);
558
+            $sig = false;
559
+            $encrypted = substr($catFile, 0, -22);
560
+        }
561
+
562
+        return [
563
+            'encrypted' => $encrypted,
564
+            'iv' => $iv,
565
+            'signature' => $sig
566
+        ];
567
+    }
568
+
569
+    /**
570
+     * check if encrypted block is signed
571
+     *
572
+     * @param string $catFile
573
+     * @param string $cipher
574
+     * @return bool
575
+     * @throws GenericEncryptionException
576
+     */
577
+    private function hasSignature($catFile, $cipher) {
578
+        $skipSignatureCheck = $this->config->getSystemValue('encryption_skip_signature_check', false);
579
+
580
+        $meta = substr($catFile, -93);
581
+        $signaturePosition = strpos($meta, '00sig00');
582
+
583
+        // If we no longer support the legacy format then everything needs a signature
584
+        if (!$skipSignatureCheck && !$this->supportLegacy && $signaturePosition === false) {
585
+            throw new GenericEncryptionException('Missing Signature', $this->l->t('Missing Signature'));
586
+        }
587
+
588
+        // enforce signature for the new 'CTR' ciphers
589
+        if (!$skipSignatureCheck && $signaturePosition === false && stripos($cipher, 'ctr') !== false) {
590
+            throw new GenericEncryptionException('Missing Signature', $this->l->t('Missing Signature'));
591
+        }
592
+
593
+        return ($signaturePosition !== false);
594
+    }
595
+
596
+
597
+    /**
598
+     * @param string $encryptedContent
599
+     * @param string $iv
600
+     * @param string $passPhrase
601
+     * @param string $cipher
602
+     * @return string
603
+     * @throws DecryptionFailedException
604
+     */
605
+    private function decrypt($encryptedContent, $iv, $passPhrase = '', $cipher = self::DEFAULT_CIPHER) {
606
+        $plainContent = openssl_decrypt($encryptedContent,
607
+            $cipher,
608
+            $passPhrase,
609
+            false,
610
+            $iv);
611
+
612
+        if ($plainContent) {
613
+            return $plainContent;
614
+        } else {
615
+            throw new DecryptionFailedException('Encryption library: Decryption (symmetric) of content failed: ' . openssl_error_string());
616
+        }
617
+    }
618
+
619
+    /**
620
+     * @param string $data
621
+     * @return array
622
+     */
623
+    protected function parseHeader($data) {
624
+        $result = [];
625
+
626
+        if (substr($data, 0, strlen(self::HEADER_START)) === self::HEADER_START) {
627
+            $endAt = strpos($data, self::HEADER_END);
628
+            $header = substr($data, 0, $endAt + strlen(self::HEADER_END));
629
+
630
+            // +1 not to start with an ':' which would result in empty element at the beginning
631
+            $exploded = explode(':',
632
+                substr($header, strlen(self::HEADER_START) + 1));
633
+
634
+            $element = array_shift($exploded);
635
+
636
+            while ($element !== self::HEADER_END) {
637
+                $result[$element] = array_shift($exploded);
638
+                $element = array_shift($exploded);
639
+            }
640
+        }
641
+
642
+        return $result;
643
+    }
644
+
645
+    /**
646
+     * generate initialization vector
647
+     *
648
+     * @return string
649
+     * @throws GenericEncryptionException
650
+     */
651
+    private function generateIv() {
652
+        return random_bytes(16);
653
+    }
654
+
655
+    /**
656
+     * Generate a cryptographically secure pseudo-random 256-bit ASCII key, used
657
+     * as file key
658
+     *
659
+     * @return string
660
+     * @throws \Exception
661
+     */
662
+    public function generateFileKey() {
663
+        return random_bytes(32);
664
+    }
665
+
666
+    /**
667
+     * @param $encKeyFile
668
+     * @param $shareKey
669
+     * @param $privateKey
670
+     * @return string
671
+     * @throws MultiKeyDecryptException
672
+     */
673
+    public function multiKeyDecrypt($encKeyFile, $shareKey, $privateKey) {
674
+        if (!$encKeyFile) {
675
+            throw new MultiKeyDecryptException('Cannot multikey decrypt empty plain content');
676
+        }
677
+
678
+        if (openssl_open($encKeyFile, $plainContent, $shareKey, $privateKey)) {
679
+            return $plainContent;
680
+        } else {
681
+            throw new MultiKeyDecryptException('multikeydecrypt with share key failed:' . openssl_error_string());
682
+        }
683
+    }
684
+
685
+    /**
686
+     * @param string $plainContent
687
+     * @param array $keyFiles
688
+     * @return array
689
+     * @throws MultiKeyEncryptException
690
+     */
691
+    public function multiKeyEncrypt($plainContent, array $keyFiles) {
692
+        // openssl_seal returns false without errors if plaincontent is empty
693
+        // so trigger our own error
694
+        if (empty($plainContent)) {
695
+            throw new MultiKeyEncryptException('Cannot multikeyencrypt empty plain content');
696
+        }
697
+
698
+        // Set empty vars to be set by openssl by reference
699
+        $sealed = '';
700
+        $shareKeys = [];
701
+        $mappedShareKeys = [];
702
+
703
+        if (openssl_seal($plainContent, $sealed, $shareKeys, $keyFiles)) {
704
+            $i = 0;
705
+
706
+            // Ensure each shareKey is labelled with its corresponding key id
707
+            foreach ($keyFiles as $userId => $publicKey) {
708
+                $mappedShareKeys[$userId] = $shareKeys[$i];
709
+                $i++;
710
+            }
711
+
712
+            return [
713
+                'keys' => $mappedShareKeys,
714
+                'data' => $sealed
715
+            ];
716
+        } else {
717
+            throw new MultiKeyEncryptException('multikeyencryption failed ' . openssl_error_string());
718
+        }
719
+    }
720 720
 }
Please login to merge, or discard this patch.
apps/encryption/lib/Command/ScanLegacyFormat.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -36,105 +36,105 @@
 block discarded – undo
36 36
 
37 37
 class ScanLegacyFormat extends Command {
38 38
 
39
-	/** @var Util */
40
-	protected $util;
41
-
42
-	/** @var IConfig */
43
-	protected $config;
44
-
45
-	/** @var  QuestionHelper */
46
-	protected $questionHelper;
47
-
48
-	/** @var IUserManager */
49
-	private $userManager;
50
-
51
-	/** @var View */
52
-	private $rootView;
53
-
54
-	/**
55
-	 * @param Util $util
56
-	 * @param IConfig $config
57
-	 * @param QuestionHelper $questionHelper
58
-	 */
59
-	public function __construct(Util $util,
60
-								IConfig $config,
61
-								QuestionHelper $questionHelper,
62
-								IUserManager $userManager) {
63
-		parent::__construct();
64
-
65
-		$this->util = $util;
66
-		$this->config = $config;
67
-		$this->questionHelper = $questionHelper;
68
-		$this->userManager = $userManager;
69
-		$this->rootView = new View();
70
-	}
71
-
72
-	protected function configure() {
73
-		$this
74
-			->setName('encryption:scan:legacy-format')
75
-			->setDescription('Scan the files for the legacy format');
76
-	}
77
-
78
-	protected function execute(InputInterface $input, OutputInterface $output): int {
79
-		$result = true;
80
-
81
-		$output->writeln('Scanning all files for legacy encryption');
82
-
83
-		foreach ($this->userManager->getBackends() as $backend) {
84
-			$limit = 500;
85
-			$offset = 0;
86
-			do {
87
-				$users = $backend->getUsers('', $limit, $offset);
88
-				foreach ($users as $user) {
89
-					$output->writeln('Scanning all files for ' . $user);
90
-					$this->setupUserFS($user);
91
-					$result &= $this->scanFolder($output, '/' . $user);
92
-				}
93
-				$offset += $limit;
94
-			} while (count($users) >= $limit);
95
-		}
96
-
97
-		if ($result) {
98
-			$output->writeln('All scanned files are propperly encrypted. You can disable the legacy compatibility mode.');
99
-			return 0;
100
-		}
101
-
102
-		return 1;
103
-	}
104
-
105
-	private function scanFolder(OutputInterface $output, string $folder): bool {
106
-		$clean = true;
107
-
108
-		foreach ($this->rootView->getDirectoryContent($folder) as $item) {
109
-			$path = $folder . '/' . $item['name'];
110
-			if ($this->rootView->is_dir($path)) {
111
-				if ($this->scanFolder($output, $path) === false) {
112
-					$clean = false;
113
-				}
114
-			} else {
115
-				if (!$item->isEncrypted()) {
116
-					// ignore
117
-					continue;
118
-				}
119
-
120
-				$stats = $this->rootView->stat($path);
121
-				if (!isset($stats['hasHeader']) || $stats['hasHeader'] === false) {
122
-					$clean = false;
123
-					$output->writeln($path . ' does not have a proper header');
124
-				}
125
-			}
126
-		}
127
-
128
-		return $clean;
129
-	}
130
-
131
-	/**
132
-	 * setup user file system
133
-	 *
134
-	 * @param string $uid
135
-	 */
136
-	protected function setupUserFS($uid) {
137
-		\OC_Util::tearDownFS();
138
-		\OC_Util::setupFS($uid);
139
-	}
39
+    /** @var Util */
40
+    protected $util;
41
+
42
+    /** @var IConfig */
43
+    protected $config;
44
+
45
+    /** @var  QuestionHelper */
46
+    protected $questionHelper;
47
+
48
+    /** @var IUserManager */
49
+    private $userManager;
50
+
51
+    /** @var View */
52
+    private $rootView;
53
+
54
+    /**
55
+     * @param Util $util
56
+     * @param IConfig $config
57
+     * @param QuestionHelper $questionHelper
58
+     */
59
+    public function __construct(Util $util,
60
+                                IConfig $config,
61
+                                QuestionHelper $questionHelper,
62
+                                IUserManager $userManager) {
63
+        parent::__construct();
64
+
65
+        $this->util = $util;
66
+        $this->config = $config;
67
+        $this->questionHelper = $questionHelper;
68
+        $this->userManager = $userManager;
69
+        $this->rootView = new View();
70
+    }
71
+
72
+    protected function configure() {
73
+        $this
74
+            ->setName('encryption:scan:legacy-format')
75
+            ->setDescription('Scan the files for the legacy format');
76
+    }
77
+
78
+    protected function execute(InputInterface $input, OutputInterface $output): int {
79
+        $result = true;
80
+
81
+        $output->writeln('Scanning all files for legacy encryption');
82
+
83
+        foreach ($this->userManager->getBackends() as $backend) {
84
+            $limit = 500;
85
+            $offset = 0;
86
+            do {
87
+                $users = $backend->getUsers('', $limit, $offset);
88
+                foreach ($users as $user) {
89
+                    $output->writeln('Scanning all files for ' . $user);
90
+                    $this->setupUserFS($user);
91
+                    $result &= $this->scanFolder($output, '/' . $user);
92
+                }
93
+                $offset += $limit;
94
+            } while (count($users) >= $limit);
95
+        }
96
+
97
+        if ($result) {
98
+            $output->writeln('All scanned files are propperly encrypted. You can disable the legacy compatibility mode.');
99
+            return 0;
100
+        }
101
+
102
+        return 1;
103
+    }
104
+
105
+    private function scanFolder(OutputInterface $output, string $folder): bool {
106
+        $clean = true;
107
+
108
+        foreach ($this->rootView->getDirectoryContent($folder) as $item) {
109
+            $path = $folder . '/' . $item['name'];
110
+            if ($this->rootView->is_dir($path)) {
111
+                if ($this->scanFolder($output, $path) === false) {
112
+                    $clean = false;
113
+                }
114
+            } else {
115
+                if (!$item->isEncrypted()) {
116
+                    // ignore
117
+                    continue;
118
+                }
119
+
120
+                $stats = $this->rootView->stat($path);
121
+                if (!isset($stats['hasHeader']) || $stats['hasHeader'] === false) {
122
+                    $clean = false;
123
+                    $output->writeln($path . ' does not have a proper header');
124
+                }
125
+            }
126
+        }
127
+
128
+        return $clean;
129
+    }
130
+
131
+    /**
132
+     * setup user file system
133
+     *
134
+     * @param string $uid
135
+     */
136
+    protected function setupUserFS($uid) {
137
+        \OC_Util::tearDownFS();
138
+        \OC_Util::setupFS($uid);
139
+    }
140 140
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,9 +86,9 @@  discard block
 block discarded – undo
86 86
 			do {
87 87
 				$users = $backend->getUsers('', $limit, $offset);
88 88
 				foreach ($users as $user) {
89
-					$output->writeln('Scanning all files for ' . $user);
89
+					$output->writeln('Scanning all files for '.$user);
90 90
 					$this->setupUserFS($user);
91
-					$result &= $this->scanFolder($output, '/' . $user);
91
+					$result &= $this->scanFolder($output, '/'.$user);
92 92
 				}
93 93
 				$offset += $limit;
94 94
 			} while (count($users) >= $limit);
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		$clean = true;
107 107
 
108 108
 		foreach ($this->rootView->getDirectoryContent($folder) as $item) {
109
-			$path = $folder . '/' . $item['name'];
109
+			$path = $folder.'/'.$item['name'];
110 110
 			if ($this->rootView->is_dir($path)) {
111 111
 				if ($this->scanFolder($output, $path) === false) {
112 112
 					$clean = false;
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 				$stats = $this->rootView->stat($path);
121 121
 				if (!isset($stats['hasHeader']) || $stats['hasHeader'] === false) {
122 122
 					$clean = false;
123
-					$output->writeln($path . ' does not have a proper header');
123
+					$output->writeln($path.' does not have a proper header');
124 124
 				}
125 125
 			}
126 126
 		}
Please login to merge, or discard this patch.
apps/settings/composer/composer/autoload_classmap.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -6,55 +6,55 @@
 block discarded – undo
6 6
 $baseDir = $vendorDir;
7 7
 
8 8
 return array(
9
-    'OCA\\Settings\\Activity\\GroupProvider' => $baseDir . '/../lib/Activity/GroupProvider.php',
10
-    'OCA\\Settings\\Activity\\GroupSetting' => $baseDir . '/../lib/Activity/GroupSetting.php',
11
-    'OCA\\Settings\\Activity\\Provider' => $baseDir . '/../lib/Activity/Provider.php',
12
-    'OCA\\Settings\\Activity\\SecurityFilter' => $baseDir . '/../lib/Activity/SecurityFilter.php',
13
-    'OCA\\Settings\\Activity\\SecurityProvider' => $baseDir . '/../lib/Activity/SecurityProvider.php',
14
-    'OCA\\Settings\\Activity\\SecuritySetting' => $baseDir . '/../lib/Activity/SecuritySetting.php',
15
-    'OCA\\Settings\\Activity\\Setting' => $baseDir . '/../lib/Activity/Setting.php',
16
-    'OCA\\Settings\\AppInfo\\Application' => $baseDir . '/../lib/AppInfo/Application.php',
17
-    'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => $baseDir . '/../lib/BackgroundJobs/VerifyUserData.php',
18
-    'OCA\\Settings\\Controller\\AdminSettingsController' => $baseDir . '/../lib/Controller/AdminSettingsController.php',
19
-    'OCA\\Settings\\Controller\\AppSettingsController' => $baseDir . '/../lib/Controller/AppSettingsController.php',
20
-    'OCA\\Settings\\Controller\\AuthSettingsController' => $baseDir . '/../lib/Controller/AuthSettingsController.php',
21
-    'OCA\\Settings\\Controller\\ChangePasswordController' => $baseDir . '/../lib/Controller/ChangePasswordController.php',
22
-    'OCA\\Settings\\Controller\\CheckSetupController' => $baseDir . '/../lib/Controller/CheckSetupController.php',
23
-    'OCA\\Settings\\Controller\\CommonSettingsTrait' => $baseDir . '/../lib/Controller/CommonSettingsTrait.php',
24
-    'OCA\\Settings\\Controller\\HelpController' => $baseDir . '/../lib/Controller/HelpController.php',
25
-    'OCA\\Settings\\Controller\\LogSettingsController' => $baseDir . '/../lib/Controller/LogSettingsController.php',
26
-    'OCA\\Settings\\Controller\\MailSettingsController' => $baseDir . '/../lib/Controller/MailSettingsController.php',
27
-    'OCA\\Settings\\Controller\\PersonalSettingsController' => $baseDir . '/../lib/Controller/PersonalSettingsController.php',
28
-    'OCA\\Settings\\Controller\\TwoFactorSettingsController' => $baseDir . '/../lib/Controller/TwoFactorSettingsController.php',
29
-    'OCA\\Settings\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php',
30
-    'OCA\\Settings\\Controller\\WebAuthnController' => $baseDir . '/../lib/Controller/WebAuthnController.php',
31
-    'OCA\\Settings\\Hooks' => $baseDir . '/../lib/Hooks.php',
32
-    'OCA\\Settings\\Mailer\\NewUserMailHelper' => $baseDir . '/../lib/Mailer/NewUserMailHelper.php',
33
-    'OCA\\Settings\\Middleware\\SubadminMiddleware' => $baseDir . '/../lib/Middleware/SubadminMiddleware.php',
34
-    'OCA\\Settings\\Search\\AppSearch' => $baseDir . '/../lib/Search/AppSearch.php',
35
-    'OCA\\Settings\\Search\\SectionSearch' => $baseDir . '/../lib/Search/SectionSearch.php',
36
-    'OCA\\Settings\\Sections\\Admin\\Additional' => $baseDir . '/../lib/Sections/Admin/Additional.php',
37
-    'OCA\\Settings\\Sections\\Admin\\Groupware' => $baseDir . '/../lib/Sections/Admin/Groupware.php',
38
-    'OCA\\Settings\\Sections\\Admin\\Overview' => $baseDir . '/../lib/Sections/Admin/Overview.php',
39
-    'OCA\\Settings\\Sections\\Admin\\Security' => $baseDir . '/../lib/Sections/Admin/Security.php',
40
-    'OCA\\Settings\\Sections\\Admin\\Server' => $baseDir . '/../lib/Sections/Admin/Server.php',
41
-    'OCA\\Settings\\Sections\\Admin\\Sharing' => $baseDir . '/../lib/Sections/Admin/Sharing.php',
42
-    'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir . '/../lib/Sections/Personal/PersonalInfo.php',
43
-    'OCA\\Settings\\Sections\\Personal\\Security' => $baseDir . '/../lib/Sections/Personal/Security.php',
44
-    'OCA\\Settings\\Sections\\Personal\\SyncClients' => $baseDir . '/../lib/Sections/Personal/SyncClients.php',
45
-    'OCA\\Settings\\Settings\\Admin\\Mail' => $baseDir . '/../lib/Settings/Admin/Mail.php',
46
-    'OCA\\Settings\\Settings\\Admin\\Overview' => $baseDir . '/../lib/Settings/Admin/Overview.php',
47
-    'OCA\\Settings\\Settings\\Admin\\Security' => $baseDir . '/../lib/Settings/Admin/Security.php',
48
-    'OCA\\Settings\\Settings\\Admin\\Server' => $baseDir . '/../lib/Settings/Admin/Server.php',
49
-    'OCA\\Settings\\Settings\\Admin\\Sharing' => $baseDir . '/../lib/Settings/Admin/Sharing.php',
50
-    'OCA\\Settings\\Settings\\Personal\\Additional' => $baseDir . '/../lib/Settings/Personal/Additional.php',
51
-    'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => $baseDir . '/../lib/Settings/Personal/PersonalInfo.php',
52
-    'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => $baseDir . '/../lib/Settings/Personal/Security/Authtokens.php',
53
-    'OCA\\Settings\\Settings\\Personal\\Security\\Password' => $baseDir . '/../lib/Settings/Personal/Security/Password.php',
54
-    'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => $baseDir . '/../lib/Settings/Personal/Security/TwoFactor.php',
55
-    'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => $baseDir . '/../lib/Settings/Personal/Security/WebAuthn.php',
56
-    'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir . '/../lib/Settings/Personal/ServerDevNotice.php',
57
-    'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
58
-    'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir . '/../lib/SetupChecks/PhpDefaultCharset.php',
59
-    'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir . '/../lib/SetupChecks/PhpOutputBuffering.php',
9
+    'OCA\\Settings\\Activity\\GroupProvider' => $baseDir.'/../lib/Activity/GroupProvider.php',
10
+    'OCA\\Settings\\Activity\\GroupSetting' => $baseDir.'/../lib/Activity/GroupSetting.php',
11
+    'OCA\\Settings\\Activity\\Provider' => $baseDir.'/../lib/Activity/Provider.php',
12
+    'OCA\\Settings\\Activity\\SecurityFilter' => $baseDir.'/../lib/Activity/SecurityFilter.php',
13
+    'OCA\\Settings\\Activity\\SecurityProvider' => $baseDir.'/../lib/Activity/SecurityProvider.php',
14
+    'OCA\\Settings\\Activity\\SecuritySetting' => $baseDir.'/../lib/Activity/SecuritySetting.php',
15
+    'OCA\\Settings\\Activity\\Setting' => $baseDir.'/../lib/Activity/Setting.php',
16
+    'OCA\\Settings\\AppInfo\\Application' => $baseDir.'/../lib/AppInfo/Application.php',
17
+    'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => $baseDir.'/../lib/BackgroundJobs/VerifyUserData.php',
18
+    'OCA\\Settings\\Controller\\AdminSettingsController' => $baseDir.'/../lib/Controller/AdminSettingsController.php',
19
+    'OCA\\Settings\\Controller\\AppSettingsController' => $baseDir.'/../lib/Controller/AppSettingsController.php',
20
+    'OCA\\Settings\\Controller\\AuthSettingsController' => $baseDir.'/../lib/Controller/AuthSettingsController.php',
21
+    'OCA\\Settings\\Controller\\ChangePasswordController' => $baseDir.'/../lib/Controller/ChangePasswordController.php',
22
+    'OCA\\Settings\\Controller\\CheckSetupController' => $baseDir.'/../lib/Controller/CheckSetupController.php',
23
+    'OCA\\Settings\\Controller\\CommonSettingsTrait' => $baseDir.'/../lib/Controller/CommonSettingsTrait.php',
24
+    'OCA\\Settings\\Controller\\HelpController' => $baseDir.'/../lib/Controller/HelpController.php',
25
+    'OCA\\Settings\\Controller\\LogSettingsController' => $baseDir.'/../lib/Controller/LogSettingsController.php',
26
+    'OCA\\Settings\\Controller\\MailSettingsController' => $baseDir.'/../lib/Controller/MailSettingsController.php',
27
+    'OCA\\Settings\\Controller\\PersonalSettingsController' => $baseDir.'/../lib/Controller/PersonalSettingsController.php',
28
+    'OCA\\Settings\\Controller\\TwoFactorSettingsController' => $baseDir.'/../lib/Controller/TwoFactorSettingsController.php',
29
+    'OCA\\Settings\\Controller\\UsersController' => $baseDir.'/../lib/Controller/UsersController.php',
30
+    'OCA\\Settings\\Controller\\WebAuthnController' => $baseDir.'/../lib/Controller/WebAuthnController.php',
31
+    'OCA\\Settings\\Hooks' => $baseDir.'/../lib/Hooks.php',
32
+    'OCA\\Settings\\Mailer\\NewUserMailHelper' => $baseDir.'/../lib/Mailer/NewUserMailHelper.php',
33
+    'OCA\\Settings\\Middleware\\SubadminMiddleware' => $baseDir.'/../lib/Middleware/SubadminMiddleware.php',
34
+    'OCA\\Settings\\Search\\AppSearch' => $baseDir.'/../lib/Search/AppSearch.php',
35
+    'OCA\\Settings\\Search\\SectionSearch' => $baseDir.'/../lib/Search/SectionSearch.php',
36
+    'OCA\\Settings\\Sections\\Admin\\Additional' => $baseDir.'/../lib/Sections/Admin/Additional.php',
37
+    'OCA\\Settings\\Sections\\Admin\\Groupware' => $baseDir.'/../lib/Sections/Admin/Groupware.php',
38
+    'OCA\\Settings\\Sections\\Admin\\Overview' => $baseDir.'/../lib/Sections/Admin/Overview.php',
39
+    'OCA\\Settings\\Sections\\Admin\\Security' => $baseDir.'/../lib/Sections/Admin/Security.php',
40
+    'OCA\\Settings\\Sections\\Admin\\Server' => $baseDir.'/../lib/Sections/Admin/Server.php',
41
+    'OCA\\Settings\\Sections\\Admin\\Sharing' => $baseDir.'/../lib/Sections/Admin/Sharing.php',
42
+    'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => $baseDir.'/../lib/Sections/Personal/PersonalInfo.php',
43
+    'OCA\\Settings\\Sections\\Personal\\Security' => $baseDir.'/../lib/Sections/Personal/Security.php',
44
+    'OCA\\Settings\\Sections\\Personal\\SyncClients' => $baseDir.'/../lib/Sections/Personal/SyncClients.php',
45
+    'OCA\\Settings\\Settings\\Admin\\Mail' => $baseDir.'/../lib/Settings/Admin/Mail.php',
46
+    'OCA\\Settings\\Settings\\Admin\\Overview' => $baseDir.'/../lib/Settings/Admin/Overview.php',
47
+    'OCA\\Settings\\Settings\\Admin\\Security' => $baseDir.'/../lib/Settings/Admin/Security.php',
48
+    'OCA\\Settings\\Settings\\Admin\\Server' => $baseDir.'/../lib/Settings/Admin/Server.php',
49
+    'OCA\\Settings\\Settings\\Admin\\Sharing' => $baseDir.'/../lib/Settings/Admin/Sharing.php',
50
+    'OCA\\Settings\\Settings\\Personal\\Additional' => $baseDir.'/../lib/Settings/Personal/Additional.php',
51
+    'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => $baseDir.'/../lib/Settings/Personal/PersonalInfo.php',
52
+    'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => $baseDir.'/../lib/Settings/Personal/Security/Authtokens.php',
53
+    'OCA\\Settings\\Settings\\Personal\\Security\\Password' => $baseDir.'/../lib/Settings/Personal/Security/Password.php',
54
+    'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => $baseDir.'/../lib/Settings/Personal/Security/TwoFactor.php',
55
+    'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => $baseDir.'/../lib/Settings/Personal/Security/WebAuthn.php',
56
+    'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => $baseDir.'/../lib/Settings/Personal/ServerDevNotice.php',
57
+    'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => $baseDir.'/../lib/SetupChecks/LegacySSEKeyFormat.php',
58
+    'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => $baseDir.'/../lib/SetupChecks/PhpDefaultCharset.php',
59
+    'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => $baseDir.'/../lib/SetupChecks/PhpOutputBuffering.php',
60 60
 );
Please login to merge, or discard this patch.
apps/settings/composer/composer/autoload_static.php 1 patch
Spacing   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -6,77 +6,77 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInitSettings
8 8
 {
9
-    public static $prefixLengthsPsr4 = array (
9
+    public static $prefixLengthsPsr4 = array(
10 10
         'O' => 
11
-        array (
11
+        array(
12 12
             'OCA\\Settings\\' => 13,
13 13
         ),
14 14
     );
15 15
 
16
-    public static $prefixDirsPsr4 = array (
16
+    public static $prefixDirsPsr4 = array(
17 17
         'OCA\\Settings\\' => 
18
-        array (
19
-            0 => __DIR__ . '/..' . '/../lib',
18
+        array(
19
+            0 => __DIR__.'/..'.'/../lib',
20 20
         ),
21 21
     );
22 22
 
23
-    public static $classMap = array (
24
-        'OCA\\Settings\\Activity\\GroupProvider' => __DIR__ . '/..' . '/../lib/Activity/GroupProvider.php',
25
-        'OCA\\Settings\\Activity\\GroupSetting' => __DIR__ . '/..' . '/../lib/Activity/GroupSetting.php',
26
-        'OCA\\Settings\\Activity\\Provider' => __DIR__ . '/..' . '/../lib/Activity/Provider.php',
27
-        'OCA\\Settings\\Activity\\SecurityFilter' => __DIR__ . '/..' . '/../lib/Activity/SecurityFilter.php',
28
-        'OCA\\Settings\\Activity\\SecurityProvider' => __DIR__ . '/..' . '/../lib/Activity/SecurityProvider.php',
29
-        'OCA\\Settings\\Activity\\SecuritySetting' => __DIR__ . '/..' . '/../lib/Activity/SecuritySetting.php',
30
-        'OCA\\Settings\\Activity\\Setting' => __DIR__ . '/..' . '/../lib/Activity/Setting.php',
31
-        'OCA\\Settings\\AppInfo\\Application' => __DIR__ . '/..' . '/../lib/AppInfo/Application.php',
32
-        'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => __DIR__ . '/..' . '/../lib/BackgroundJobs/VerifyUserData.php',
33
-        'OCA\\Settings\\Controller\\AdminSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AdminSettingsController.php',
34
-        'OCA\\Settings\\Controller\\AppSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AppSettingsController.php',
35
-        'OCA\\Settings\\Controller\\AuthSettingsController' => __DIR__ . '/..' . '/../lib/Controller/AuthSettingsController.php',
36
-        'OCA\\Settings\\Controller\\ChangePasswordController' => __DIR__ . '/..' . '/../lib/Controller/ChangePasswordController.php',
37
-        'OCA\\Settings\\Controller\\CheckSetupController' => __DIR__ . '/..' . '/../lib/Controller/CheckSetupController.php',
38
-        'OCA\\Settings\\Controller\\CommonSettingsTrait' => __DIR__ . '/..' . '/../lib/Controller/CommonSettingsTrait.php',
39
-        'OCA\\Settings\\Controller\\HelpController' => __DIR__ . '/..' . '/../lib/Controller/HelpController.php',
40
-        'OCA\\Settings\\Controller\\LogSettingsController' => __DIR__ . '/..' . '/../lib/Controller/LogSettingsController.php',
41
-        'OCA\\Settings\\Controller\\MailSettingsController' => __DIR__ . '/..' . '/../lib/Controller/MailSettingsController.php',
42
-        'OCA\\Settings\\Controller\\PersonalSettingsController' => __DIR__ . '/..' . '/../lib/Controller/PersonalSettingsController.php',
43
-        'OCA\\Settings\\Controller\\TwoFactorSettingsController' => __DIR__ . '/..' . '/../lib/Controller/TwoFactorSettingsController.php',
44
-        'OCA\\Settings\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
45
-        'OCA\\Settings\\Controller\\WebAuthnController' => __DIR__ . '/..' . '/../lib/Controller/WebAuthnController.php',
46
-        'OCA\\Settings\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
47
-        'OCA\\Settings\\Mailer\\NewUserMailHelper' => __DIR__ . '/..' . '/../lib/Mailer/NewUserMailHelper.php',
48
-        'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/SubadminMiddleware.php',
49
-        'OCA\\Settings\\Search\\AppSearch' => __DIR__ . '/..' . '/../lib/Search/AppSearch.php',
50
-        'OCA\\Settings\\Search\\SectionSearch' => __DIR__ . '/..' . '/../lib/Search/SectionSearch.php',
51
-        'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__ . '/..' . '/../lib/Sections/Admin/Additional.php',
52
-        'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__ . '/..' . '/../lib/Sections/Admin/Groupware.php',
53
-        'OCA\\Settings\\Sections\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Sections/Admin/Overview.php',
54
-        'OCA\\Settings\\Sections\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Sections/Admin/Security.php',
55
-        'OCA\\Settings\\Sections\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Sections/Admin/Server.php',
56
-        'OCA\\Settings\\Sections\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Sections/Admin/Sharing.php',
57
-        'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Sections/Personal/PersonalInfo.php',
58
-        'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__ . '/..' . '/../lib/Sections/Personal/Security.php',
59
-        'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__ . '/..' . '/../lib/Sections/Personal/SyncClients.php',
60
-        'OCA\\Settings\\Settings\\Admin\\Mail' => __DIR__ . '/..' . '/../lib/Settings/Admin/Mail.php',
61
-        'OCA\\Settings\\Settings\\Admin\\Overview' => __DIR__ . '/..' . '/../lib/Settings/Admin/Overview.php',
62
-        'OCA\\Settings\\Settings\\Admin\\Security' => __DIR__ . '/..' . '/../lib/Settings/Admin/Security.php',
63
-        'OCA\\Settings\\Settings\\Admin\\Server' => __DIR__ . '/..' . '/../lib/Settings/Admin/Server.php',
64
-        'OCA\\Settings\\Settings\\Admin\\Sharing' => __DIR__ . '/..' . '/../lib/Settings/Admin/Sharing.php',
65
-        'OCA\\Settings\\Settings\\Personal\\Additional' => __DIR__ . '/..' . '/../lib/Settings/Personal/Additional.php',
66
-        'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => __DIR__ . '/..' . '/../lib/Settings/Personal/PersonalInfo.php',
67
-        'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Authtokens.php',
68
-        'OCA\\Settings\\Settings\\Personal\\Security\\Password' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/Password.php',
69
-        'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/TwoFactor.php',
70
-        'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => __DIR__ . '/..' . '/../lib/Settings/Personal/Security/WebAuthn.php',
71
-        'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__ . '/..' . '/../lib/Settings/Personal/ServerDevNotice.php',
72
-        'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__ . '/..' . '/../lib/SetupChecks/LegacySSEKeyFormat.php',
73
-        'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpDefaultCharset.php',
74
-        'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__ . '/..' . '/../lib/SetupChecks/PhpOutputBuffering.php',
23
+    public static $classMap = array(
24
+        'OCA\\Settings\\Activity\\GroupProvider' => __DIR__.'/..'.'/../lib/Activity/GroupProvider.php',
25
+        'OCA\\Settings\\Activity\\GroupSetting' => __DIR__.'/..'.'/../lib/Activity/GroupSetting.php',
26
+        'OCA\\Settings\\Activity\\Provider' => __DIR__.'/..'.'/../lib/Activity/Provider.php',
27
+        'OCA\\Settings\\Activity\\SecurityFilter' => __DIR__.'/..'.'/../lib/Activity/SecurityFilter.php',
28
+        'OCA\\Settings\\Activity\\SecurityProvider' => __DIR__.'/..'.'/../lib/Activity/SecurityProvider.php',
29
+        'OCA\\Settings\\Activity\\SecuritySetting' => __DIR__.'/..'.'/../lib/Activity/SecuritySetting.php',
30
+        'OCA\\Settings\\Activity\\Setting' => __DIR__.'/..'.'/../lib/Activity/Setting.php',
31
+        'OCA\\Settings\\AppInfo\\Application' => __DIR__.'/..'.'/../lib/AppInfo/Application.php',
32
+        'OCA\\Settings\\BackgroundJobs\\VerifyUserData' => __DIR__.'/..'.'/../lib/BackgroundJobs/VerifyUserData.php',
33
+        'OCA\\Settings\\Controller\\AdminSettingsController' => __DIR__.'/..'.'/../lib/Controller/AdminSettingsController.php',
34
+        'OCA\\Settings\\Controller\\AppSettingsController' => __DIR__.'/..'.'/../lib/Controller/AppSettingsController.php',
35
+        'OCA\\Settings\\Controller\\AuthSettingsController' => __DIR__.'/..'.'/../lib/Controller/AuthSettingsController.php',
36
+        'OCA\\Settings\\Controller\\ChangePasswordController' => __DIR__.'/..'.'/../lib/Controller/ChangePasswordController.php',
37
+        'OCA\\Settings\\Controller\\CheckSetupController' => __DIR__.'/..'.'/../lib/Controller/CheckSetupController.php',
38
+        'OCA\\Settings\\Controller\\CommonSettingsTrait' => __DIR__.'/..'.'/../lib/Controller/CommonSettingsTrait.php',
39
+        'OCA\\Settings\\Controller\\HelpController' => __DIR__.'/..'.'/../lib/Controller/HelpController.php',
40
+        'OCA\\Settings\\Controller\\LogSettingsController' => __DIR__.'/..'.'/../lib/Controller/LogSettingsController.php',
41
+        'OCA\\Settings\\Controller\\MailSettingsController' => __DIR__.'/..'.'/../lib/Controller/MailSettingsController.php',
42
+        'OCA\\Settings\\Controller\\PersonalSettingsController' => __DIR__.'/..'.'/../lib/Controller/PersonalSettingsController.php',
43
+        'OCA\\Settings\\Controller\\TwoFactorSettingsController' => __DIR__.'/..'.'/../lib/Controller/TwoFactorSettingsController.php',
44
+        'OCA\\Settings\\Controller\\UsersController' => __DIR__.'/..'.'/../lib/Controller/UsersController.php',
45
+        'OCA\\Settings\\Controller\\WebAuthnController' => __DIR__.'/..'.'/../lib/Controller/WebAuthnController.php',
46
+        'OCA\\Settings\\Hooks' => __DIR__.'/..'.'/../lib/Hooks.php',
47
+        'OCA\\Settings\\Mailer\\NewUserMailHelper' => __DIR__.'/..'.'/../lib/Mailer/NewUserMailHelper.php',
48
+        'OCA\\Settings\\Middleware\\SubadminMiddleware' => __DIR__.'/..'.'/../lib/Middleware/SubadminMiddleware.php',
49
+        'OCA\\Settings\\Search\\AppSearch' => __DIR__.'/..'.'/../lib/Search/AppSearch.php',
50
+        'OCA\\Settings\\Search\\SectionSearch' => __DIR__.'/..'.'/../lib/Search/SectionSearch.php',
51
+        'OCA\\Settings\\Sections\\Admin\\Additional' => __DIR__.'/..'.'/../lib/Sections/Admin/Additional.php',
52
+        'OCA\\Settings\\Sections\\Admin\\Groupware' => __DIR__.'/..'.'/../lib/Sections/Admin/Groupware.php',
53
+        'OCA\\Settings\\Sections\\Admin\\Overview' => __DIR__.'/..'.'/../lib/Sections/Admin/Overview.php',
54
+        'OCA\\Settings\\Sections\\Admin\\Security' => __DIR__.'/..'.'/../lib/Sections/Admin/Security.php',
55
+        'OCA\\Settings\\Sections\\Admin\\Server' => __DIR__.'/..'.'/../lib/Sections/Admin/Server.php',
56
+        'OCA\\Settings\\Sections\\Admin\\Sharing' => __DIR__.'/..'.'/../lib/Sections/Admin/Sharing.php',
57
+        'OCA\\Settings\\Sections\\Personal\\PersonalInfo' => __DIR__.'/..'.'/../lib/Sections/Personal/PersonalInfo.php',
58
+        'OCA\\Settings\\Sections\\Personal\\Security' => __DIR__.'/..'.'/../lib/Sections/Personal/Security.php',
59
+        'OCA\\Settings\\Sections\\Personal\\SyncClients' => __DIR__.'/..'.'/../lib/Sections/Personal/SyncClients.php',
60
+        'OCA\\Settings\\Settings\\Admin\\Mail' => __DIR__.'/..'.'/../lib/Settings/Admin/Mail.php',
61
+        'OCA\\Settings\\Settings\\Admin\\Overview' => __DIR__.'/..'.'/../lib/Settings/Admin/Overview.php',
62
+        'OCA\\Settings\\Settings\\Admin\\Security' => __DIR__.'/..'.'/../lib/Settings/Admin/Security.php',
63
+        'OCA\\Settings\\Settings\\Admin\\Server' => __DIR__.'/..'.'/../lib/Settings/Admin/Server.php',
64
+        'OCA\\Settings\\Settings\\Admin\\Sharing' => __DIR__.'/..'.'/../lib/Settings/Admin/Sharing.php',
65
+        'OCA\\Settings\\Settings\\Personal\\Additional' => __DIR__.'/..'.'/../lib/Settings/Personal/Additional.php',
66
+        'OCA\\Settings\\Settings\\Personal\\PersonalInfo' => __DIR__.'/..'.'/../lib/Settings/Personal/PersonalInfo.php',
67
+        'OCA\\Settings\\Settings\\Personal\\Security\\Authtokens' => __DIR__.'/..'.'/../lib/Settings/Personal/Security/Authtokens.php',
68
+        'OCA\\Settings\\Settings\\Personal\\Security\\Password' => __DIR__.'/..'.'/../lib/Settings/Personal/Security/Password.php',
69
+        'OCA\\Settings\\Settings\\Personal\\Security\\TwoFactor' => __DIR__.'/..'.'/../lib/Settings/Personal/Security/TwoFactor.php',
70
+        'OCA\\Settings\\Settings\\Personal\\Security\\WebAuthn' => __DIR__.'/..'.'/../lib/Settings/Personal/Security/WebAuthn.php',
71
+        'OCA\\Settings\\Settings\\Personal\\ServerDevNotice' => __DIR__.'/..'.'/../lib/Settings/Personal/ServerDevNotice.php',
72
+        'OCA\\Settings\\SetupChecks\\LegacySSEKeyFormat' => __DIR__.'/..'.'/../lib/SetupChecks/LegacySSEKeyFormat.php',
73
+        'OCA\\Settings\\SetupChecks\\PhpDefaultCharset' => __DIR__.'/..'.'/../lib/SetupChecks/PhpDefaultCharset.php',
74
+        'OCA\\Settings\\SetupChecks\\PhpOutputBuffering' => __DIR__.'/..'.'/../lib/SetupChecks/PhpOutputBuffering.php',
75 75
     );
76 76
 
77 77
     public static function getInitializer(ClassLoader $loader)
78 78
     {
79
-        return \Closure::bind(function () use ($loader) {
79
+        return \Closure::bind(function() use ($loader) {
80 80
             $loader->prefixLengthsPsr4 = ComposerStaticInitSettings::$prefixLengthsPsr4;
81 81
             $loader->prefixDirsPsr4 = ComposerStaticInitSettings::$prefixDirsPsr4;
82 82
             $loader->classMap = ComposerStaticInitSettings::$classMap;
Please login to merge, or discard this patch.
apps/settings/lib/Controller/CheckSetupController.php 1 patch
Indentation   +650 added lines, -650 removed lines patch added patch discarded remove patch
@@ -74,288 +74,288 @@  discard block
 block discarded – undo
74 74
 use Symfony\Component\EventDispatcher\GenericEvent;
75 75
 
76 76
 class CheckSetupController extends Controller {
77
-	/** @var IConfig */
78
-	private $config;
79
-	/** @var IClientService */
80
-	private $clientService;
81
-	/** @var IURLGenerator */
82
-	private $urlGenerator;
83
-	/** @var IL10N */
84
-	private $l10n;
85
-	/** @var Checker */
86
-	private $checker;
87
-	/** @var ILogger */
88
-	private $logger;
89
-	/** @var EventDispatcherInterface */
90
-	private $dispatcher;
91
-	/** @var IDBConnection|Connection */
92
-	private $db;
93
-	/** @var ILockingProvider */
94
-	private $lockingProvider;
95
-	/** @var IDateTimeFormatter */
96
-	private $dateTimeFormatter;
97
-	/** @var MemoryInfo */
98
-	private $memoryInfo;
99
-	/** @var ISecureRandom */
100
-	private $secureRandom;
101
-
102
-	public function __construct($AppName,
103
-								IRequest $request,
104
-								IConfig $config,
105
-								IClientService $clientService,
106
-								IURLGenerator $urlGenerator,
107
-								IL10N $l10n,
108
-								Checker $checker,
109
-								ILogger $logger,
110
-								EventDispatcherInterface $dispatcher,
111
-								IDBConnection $db,
112
-								ILockingProvider $lockingProvider,
113
-								IDateTimeFormatter $dateTimeFormatter,
114
-								MemoryInfo $memoryInfo,
115
-								ISecureRandom $secureRandom) {
116
-		parent::__construct($AppName, $request);
117
-		$this->config = $config;
118
-		$this->clientService = $clientService;
119
-		$this->urlGenerator = $urlGenerator;
120
-		$this->l10n = $l10n;
121
-		$this->checker = $checker;
122
-		$this->logger = $logger;
123
-		$this->dispatcher = $dispatcher;
124
-		$this->db = $db;
125
-		$this->lockingProvider = $lockingProvider;
126
-		$this->dateTimeFormatter = $dateTimeFormatter;
127
-		$this->memoryInfo = $memoryInfo;
128
-		$this->secureRandom = $secureRandom;
129
-	}
130
-
131
-	/**
132
-	 * Checks if the server can connect to the internet using HTTPS and HTTP
133
-	 * @return bool
134
-	 */
135
-	private function hasInternetConnectivityProblems(): bool {
136
-		if ($this->config->getSystemValue('has_internet_connection', true) === false) {
137
-			return false;
138
-		}
139
-
140
-		$siteArray = $this->config->getSystemValue('connectivity_check_domains', [
141
-			'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
142
-		]);
143
-
144
-		foreach ($siteArray as $site) {
145
-			if ($this->isSiteReachable($site)) {
146
-				return false;
147
-			}
148
-		}
149
-		return true;
150
-	}
151
-
152
-	/**
153
-	 * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
154
-	 * @return bool
155
-	 */
156
-	private function isSiteReachable($sitename) {
157
-		$httpSiteName = 'http://' . $sitename . '/';
158
-		$httpsSiteName = 'https://' . $sitename . '/';
159
-
160
-		try {
161
-			$client = $this->clientService->newClient();
162
-			$client->get($httpSiteName);
163
-			$client->get($httpsSiteName);
164
-		} catch (\Exception $e) {
165
-			$this->logger->logException($e, ['app' => 'internet_connection_check']);
166
-			return false;
167
-		}
168
-		return true;
169
-	}
170
-
171
-	/**
172
-	 * Checks whether a local memcache is installed or not
173
-	 * @return bool
174
-	 */
175
-	private function isMemcacheConfigured() {
176
-		return $this->config->getSystemValue('memcache.local', null) !== null;
177
-	}
178
-
179
-	/**
180
-	 * Whether PHP can generate "secure" pseudorandom integers
181
-	 *
182
-	 * @return bool
183
-	 */
184
-	private function isRandomnessSecure() {
185
-		try {
186
-			$this->secureRandom->generate(1);
187
-		} catch (\Exception $ex) {
188
-			return false;
189
-		}
190
-		return true;
191
-	}
192
-
193
-	/**
194
-	 * Public for the sake of unit-testing
195
-	 *
196
-	 * @return array
197
-	 */
198
-	protected function getCurlVersion() {
199
-		return curl_version();
200
-	}
201
-
202
-	/**
203
-	 * Check if the used  SSL lib is outdated. Older OpenSSL and NSS versions do
204
-	 * have multiple bugs which likely lead to problems in combination with
205
-	 * functionality required by ownCloud such as SNI.
206
-	 *
207
-	 * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
208
-	 * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
209
-	 * @return string
210
-	 */
211
-	private function isUsedTlsLibOutdated() {
212
-		// Don't run check when:
213
-		// 1. Server has `has_internet_connection` set to false
214
-		// 2. AppStore AND S2S is disabled
215
-		if (!$this->config->getSystemValue('has_internet_connection', true)) {
216
-			return '';
217
-		}
218
-		if (!$this->config->getSystemValue('appstoreenabled', true)
219
-			&& $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
220
-			&& $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
221
-			return '';
222
-		}
223
-
224
-		$versionString = $this->getCurlVersion();
225
-		if (isset($versionString['ssl_version'])) {
226
-			$versionString = $versionString['ssl_version'];
227
-		} else {
228
-			return '';
229
-		}
230
-
231
-		$features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
232
-		if (!$this->config->getSystemValue('appstoreenabled', true)) {
233
-			$features = (string)$this->l10n->t('Federated Cloud Sharing');
234
-		}
235
-
236
-		// Check if at least OpenSSL after 1.01d or 1.0.2b
237
-		if (strpos($versionString, 'OpenSSL/') === 0) {
238
-			$majorVersion = substr($versionString, 8, 5);
239
-			$patchRelease = substr($versionString, 13, 6);
240
-
241
-			if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
242
-				($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
243
-				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]);
244
-			}
245
-		}
246
-
247
-		// Check if NSS and perform heuristic check
248
-		if (strpos($versionString, 'NSS/') === 0) {
249
-			try {
250
-				$firstClient = $this->clientService->newClient();
251
-				$firstClient->get('https://nextcloud.com/');
252
-
253
-				$secondClient = $this->clientService->newClient();
254
-				$secondClient->get('https://nextcloud.com/');
255
-			} catch (ClientException $e) {
256
-				if ($e->getResponse()->getStatusCode() === 400) {
257
-					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]);
258
-				}
259
-			}
260
-		}
261
-
262
-		return '';
263
-	}
264
-
265
-	/**
266
-	 * Whether the version is outdated
267
-	 *
268
-	 * @return bool
269
-	 */
270
-	protected function isPhpOutdated(): bool {
271
-		return PHP_VERSION_ID < 70300;
272
-	}
273
-
274
-	/**
275
-	 * Whether the php version is still supported (at time of release)
276
-	 * according to: https://secure.php.net/supported-versions.php
277
-	 *
278
-	 * @return array
279
-	 */
280
-	private function isPhpSupported(): array {
281
-		return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
282
-	}
283
-
284
-	/**
285
-	 * Check if the reverse proxy configuration is working as expected
286
-	 *
287
-	 * @return bool
288
-	 */
289
-	private function forwardedForHeadersWorking() {
290
-		$trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
291
-		$remoteAddress = $this->request->getHeader('REMOTE_ADDR');
292
-
293
-		if (empty($trustedProxies) && $this->request->getHeader('X-Forwarded-Host') !== '') {
294
-			return false;
295
-		}
296
-
297
-		if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies, true)) {
298
-			return $remoteAddress !== $this->request->getRemoteAddress();
299
-		}
300
-
301
-		// either not enabled or working correctly
302
-		return true;
303
-	}
304
-
305
-	/**
306
-	 * Checks if the correct memcache module for PHP is installed. Only
307
-	 * fails if memcached is configured and the working module is not installed.
308
-	 *
309
-	 * @return bool
310
-	 */
311
-	private function isCorrectMemcachedPHPModuleInstalled() {
312
-		if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
313
-			return true;
314
-		}
315
-
316
-		// there are two different memcached modules for PHP
317
-		// we only support memcached and not memcache
318
-		// https://code.google.com/p/memcached/wiki/PHPClientComparison
319
-		return !(!extension_loaded('memcached') && extension_loaded('memcache'));
320
-	}
321
-
322
-	/**
323
-	 * Checks if set_time_limit is not disabled.
324
-	 *
325
-	 * @return bool
326
-	 */
327
-	private function isSettimelimitAvailable() {
328
-		if (function_exists('set_time_limit')
329
-			&& strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
330
-			return true;
331
-		}
332
-
333
-		return false;
334
-	}
335
-
336
-	/**
337
-	 * @return RedirectResponse
338
-	 */
339
-	public function rescanFailedIntegrityCheck() {
340
-		$this->checker->runInstanceVerification();
341
-		return new RedirectResponse(
342
-			$this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview'])
343
-		);
344
-	}
345
-
346
-	/**
347
-	 * @NoCSRFRequired
348
-	 * @return DataResponse
349
-	 */
350
-	public function getFailedIntegrityCheckFiles() {
351
-		if (!$this->checker->isCodeCheckEnforced()) {
352
-			return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
353
-		}
354
-
355
-		$completeResults = $this->checker->getResults();
356
-
357
-		if (!empty($completeResults)) {
358
-			$formattedTextResponse = 'Technical information
77
+    /** @var IConfig */
78
+    private $config;
79
+    /** @var IClientService */
80
+    private $clientService;
81
+    /** @var IURLGenerator */
82
+    private $urlGenerator;
83
+    /** @var IL10N */
84
+    private $l10n;
85
+    /** @var Checker */
86
+    private $checker;
87
+    /** @var ILogger */
88
+    private $logger;
89
+    /** @var EventDispatcherInterface */
90
+    private $dispatcher;
91
+    /** @var IDBConnection|Connection */
92
+    private $db;
93
+    /** @var ILockingProvider */
94
+    private $lockingProvider;
95
+    /** @var IDateTimeFormatter */
96
+    private $dateTimeFormatter;
97
+    /** @var MemoryInfo */
98
+    private $memoryInfo;
99
+    /** @var ISecureRandom */
100
+    private $secureRandom;
101
+
102
+    public function __construct($AppName,
103
+                                IRequest $request,
104
+                                IConfig $config,
105
+                                IClientService $clientService,
106
+                                IURLGenerator $urlGenerator,
107
+                                IL10N $l10n,
108
+                                Checker $checker,
109
+                                ILogger $logger,
110
+                                EventDispatcherInterface $dispatcher,
111
+                                IDBConnection $db,
112
+                                ILockingProvider $lockingProvider,
113
+                                IDateTimeFormatter $dateTimeFormatter,
114
+                                MemoryInfo $memoryInfo,
115
+                                ISecureRandom $secureRandom) {
116
+        parent::__construct($AppName, $request);
117
+        $this->config = $config;
118
+        $this->clientService = $clientService;
119
+        $this->urlGenerator = $urlGenerator;
120
+        $this->l10n = $l10n;
121
+        $this->checker = $checker;
122
+        $this->logger = $logger;
123
+        $this->dispatcher = $dispatcher;
124
+        $this->db = $db;
125
+        $this->lockingProvider = $lockingProvider;
126
+        $this->dateTimeFormatter = $dateTimeFormatter;
127
+        $this->memoryInfo = $memoryInfo;
128
+        $this->secureRandom = $secureRandom;
129
+    }
130
+
131
+    /**
132
+     * Checks if the server can connect to the internet using HTTPS and HTTP
133
+     * @return bool
134
+     */
135
+    private function hasInternetConnectivityProblems(): bool {
136
+        if ($this->config->getSystemValue('has_internet_connection', true) === false) {
137
+            return false;
138
+        }
139
+
140
+        $siteArray = $this->config->getSystemValue('connectivity_check_domains', [
141
+            'www.nextcloud.com', 'www.startpage.com', 'www.eff.org', 'www.edri.org'
142
+        ]);
143
+
144
+        foreach ($siteArray as $site) {
145
+            if ($this->isSiteReachable($site)) {
146
+                return false;
147
+            }
148
+        }
149
+        return true;
150
+    }
151
+
152
+    /**
153
+     * Checks if the Nextcloud server can connect to a specific URL using both HTTPS and HTTP
154
+     * @return bool
155
+     */
156
+    private function isSiteReachable($sitename) {
157
+        $httpSiteName = 'http://' . $sitename . '/';
158
+        $httpsSiteName = 'https://' . $sitename . '/';
159
+
160
+        try {
161
+            $client = $this->clientService->newClient();
162
+            $client->get($httpSiteName);
163
+            $client->get($httpsSiteName);
164
+        } catch (\Exception $e) {
165
+            $this->logger->logException($e, ['app' => 'internet_connection_check']);
166
+            return false;
167
+        }
168
+        return true;
169
+    }
170
+
171
+    /**
172
+     * Checks whether a local memcache is installed or not
173
+     * @return bool
174
+     */
175
+    private function isMemcacheConfigured() {
176
+        return $this->config->getSystemValue('memcache.local', null) !== null;
177
+    }
178
+
179
+    /**
180
+     * Whether PHP can generate "secure" pseudorandom integers
181
+     *
182
+     * @return bool
183
+     */
184
+    private function isRandomnessSecure() {
185
+        try {
186
+            $this->secureRandom->generate(1);
187
+        } catch (\Exception $ex) {
188
+            return false;
189
+        }
190
+        return true;
191
+    }
192
+
193
+    /**
194
+     * Public for the sake of unit-testing
195
+     *
196
+     * @return array
197
+     */
198
+    protected function getCurlVersion() {
199
+        return curl_version();
200
+    }
201
+
202
+    /**
203
+     * Check if the used  SSL lib is outdated. Older OpenSSL and NSS versions do
204
+     * have multiple bugs which likely lead to problems in combination with
205
+     * functionality required by ownCloud such as SNI.
206
+     *
207
+     * @link https://github.com/owncloud/core/issues/17446#issuecomment-122877546
208
+     * @link https://bugzilla.redhat.com/show_bug.cgi?id=1241172
209
+     * @return string
210
+     */
211
+    private function isUsedTlsLibOutdated() {
212
+        // Don't run check when:
213
+        // 1. Server has `has_internet_connection` set to false
214
+        // 2. AppStore AND S2S is disabled
215
+        if (!$this->config->getSystemValue('has_internet_connection', true)) {
216
+            return '';
217
+        }
218
+        if (!$this->config->getSystemValue('appstoreenabled', true)
219
+            && $this->config->getAppValue('files_sharing', 'outgoing_server2server_share_enabled', 'yes') === 'no'
220
+            && $this->config->getAppValue('files_sharing', 'incoming_server2server_share_enabled', 'yes') === 'no') {
221
+            return '';
222
+        }
223
+
224
+        $versionString = $this->getCurlVersion();
225
+        if (isset($versionString['ssl_version'])) {
226
+            $versionString = $versionString['ssl_version'];
227
+        } else {
228
+            return '';
229
+        }
230
+
231
+        $features = (string)$this->l10n->t('installing and updating apps via the app store or Federated Cloud Sharing');
232
+        if (!$this->config->getSystemValue('appstoreenabled', true)) {
233
+            $features = (string)$this->l10n->t('Federated Cloud Sharing');
234
+        }
235
+
236
+        // Check if at least OpenSSL after 1.01d or 1.0.2b
237
+        if (strpos($versionString, 'OpenSSL/') === 0) {
238
+            $majorVersion = substr($versionString, 8, 5);
239
+            $patchRelease = substr($versionString, 13, 6);
240
+
241
+            if (($majorVersion === '1.0.1' && ord($patchRelease) < ord('d')) ||
242
+                ($majorVersion === '1.0.2' && ord($patchRelease) < ord('b'))) {
243
+                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]);
244
+            }
245
+        }
246
+
247
+        // Check if NSS and perform heuristic check
248
+        if (strpos($versionString, 'NSS/') === 0) {
249
+            try {
250
+                $firstClient = $this->clientService->newClient();
251
+                $firstClient->get('https://nextcloud.com/');
252
+
253
+                $secondClient = $this->clientService->newClient();
254
+                $secondClient->get('https://nextcloud.com/');
255
+            } catch (ClientException $e) {
256
+                if ($e->getResponse()->getStatusCode() === 400) {
257
+                    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]);
258
+                }
259
+            }
260
+        }
261
+
262
+        return '';
263
+    }
264
+
265
+    /**
266
+     * Whether the version is outdated
267
+     *
268
+     * @return bool
269
+     */
270
+    protected function isPhpOutdated(): bool {
271
+        return PHP_VERSION_ID < 70300;
272
+    }
273
+
274
+    /**
275
+     * Whether the php version is still supported (at time of release)
276
+     * according to: https://secure.php.net/supported-versions.php
277
+     *
278
+     * @return array
279
+     */
280
+    private function isPhpSupported(): array {
281
+        return ['eol' => $this->isPhpOutdated(), 'version' => PHP_VERSION];
282
+    }
283
+
284
+    /**
285
+     * Check if the reverse proxy configuration is working as expected
286
+     *
287
+     * @return bool
288
+     */
289
+    private function forwardedForHeadersWorking() {
290
+        $trustedProxies = $this->config->getSystemValue('trusted_proxies', []);
291
+        $remoteAddress = $this->request->getHeader('REMOTE_ADDR');
292
+
293
+        if (empty($trustedProxies) && $this->request->getHeader('X-Forwarded-Host') !== '') {
294
+            return false;
295
+        }
296
+
297
+        if (\is_array($trustedProxies) && \in_array($remoteAddress, $trustedProxies, true)) {
298
+            return $remoteAddress !== $this->request->getRemoteAddress();
299
+        }
300
+
301
+        // either not enabled or working correctly
302
+        return true;
303
+    }
304
+
305
+    /**
306
+     * Checks if the correct memcache module for PHP is installed. Only
307
+     * fails if memcached is configured and the working module is not installed.
308
+     *
309
+     * @return bool
310
+     */
311
+    private function isCorrectMemcachedPHPModuleInstalled() {
312
+        if ($this->config->getSystemValue('memcache.distributed', null) !== '\OC\Memcache\Memcached') {
313
+            return true;
314
+        }
315
+
316
+        // there are two different memcached modules for PHP
317
+        // we only support memcached and not memcache
318
+        // https://code.google.com/p/memcached/wiki/PHPClientComparison
319
+        return !(!extension_loaded('memcached') && extension_loaded('memcache'));
320
+    }
321
+
322
+    /**
323
+     * Checks if set_time_limit is not disabled.
324
+     *
325
+     * @return bool
326
+     */
327
+    private function isSettimelimitAvailable() {
328
+        if (function_exists('set_time_limit')
329
+            && strpos(@ini_get('disable_functions'), 'set_time_limit') === false) {
330
+            return true;
331
+        }
332
+
333
+        return false;
334
+    }
335
+
336
+    /**
337
+     * @return RedirectResponse
338
+     */
339
+    public function rescanFailedIntegrityCheck() {
340
+        $this->checker->runInstanceVerification();
341
+        return new RedirectResponse(
342
+            $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'overview'])
343
+        );
344
+    }
345
+
346
+    /**
347
+     * @NoCSRFRequired
348
+     * @return DataResponse
349
+     */
350
+    public function getFailedIntegrityCheckFiles() {
351
+        if (!$this->checker->isCodeCheckEnforced()) {
352
+            return new DataDisplayResponse('Integrity checker has been disabled. Integrity cannot be verified.');
353
+        }
354
+
355
+        $completeResults = $this->checker->getResults();
356
+
357
+        if (!empty($completeResults)) {
358
+            $formattedTextResponse = 'Technical information
359 359
 =====================
360 360
 The following list covers which files have failed the integrity check. Please read
361 361
 the previous linked documentation to learn more about the errors and how to fix
@@ -364,375 +364,375 @@  discard block
 block discarded – undo
364 364
 Results
365 365
 =======
366 366
 ';
367
-			foreach ($completeResults as $context => $contextResult) {
368
-				$formattedTextResponse .= "- $context\n";
369
-
370
-				foreach ($contextResult as $category => $result) {
371
-					$formattedTextResponse .= "\t- $category\n";
372
-					if ($category !== 'EXCEPTION') {
373
-						foreach ($result as $key => $results) {
374
-							$formattedTextResponse .= "\t\t- $key\n";
375
-						}
376
-					} else {
377
-						foreach ($result as $key => $results) {
378
-							$formattedTextResponse .= "\t\t- $results\n";
379
-						}
380
-					}
381
-				}
382
-			}
383
-
384
-			$formattedTextResponse .= '
367
+            foreach ($completeResults as $context => $contextResult) {
368
+                $formattedTextResponse .= "- $context\n";
369
+
370
+                foreach ($contextResult as $category => $result) {
371
+                    $formattedTextResponse .= "\t- $category\n";
372
+                    if ($category !== 'EXCEPTION') {
373
+                        foreach ($result as $key => $results) {
374
+                            $formattedTextResponse .= "\t\t- $key\n";
375
+                        }
376
+                    } else {
377
+                        foreach ($result as $key => $results) {
378
+                            $formattedTextResponse .= "\t\t- $results\n";
379
+                        }
380
+                    }
381
+                }
382
+            }
383
+
384
+            $formattedTextResponse .= '
385 385
 Raw output
386 386
 ==========
387 387
 ';
388
-			$formattedTextResponse .= print_r($completeResults, true);
389
-		} else {
390
-			$formattedTextResponse = 'No errors have been found.';
391
-		}
392
-
393
-
394
-		$response = new DataDisplayResponse(
395
-			$formattedTextResponse,
396
-			Http::STATUS_OK,
397
-			[
398
-				'Content-Type' => 'text/plain',
399
-			]
400
-		);
401
-
402
-		return $response;
403
-	}
404
-
405
-	/**
406
-	 * Checks whether a PHP opcache is properly set up
407
-	 * @return bool
408
-	 */
409
-	protected function isOpcacheProperlySetup() {
410
-		$iniWrapper = new IniGetWrapper();
411
-
412
-		if (!$iniWrapper->getBool('opcache.enable')) {
413
-			return false;
414
-		}
415
-
416
-		if (!$iniWrapper->getBool('opcache.save_comments')) {
417
-			return false;
418
-		}
419
-
420
-		if ($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
421
-			return false;
422
-		}
423
-
424
-		if ($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
425
-			return false;
426
-		}
427
-
428
-		if ($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
429
-			return false;
430
-		}
431
-
432
-		return true;
433
-	}
434
-
435
-	/**
436
-	 * Check if the required FreeType functions are present
437
-	 * @return bool
438
-	 */
439
-	protected function hasFreeTypeSupport() {
440
-		return function_exists('imagettfbbox') && function_exists('imagettftext');
441
-	}
442
-
443
-	protected function hasMissingIndexes(): array {
444
-		$indexInfo = new MissingIndexInformation();
445
-		// Dispatch event so apps can also hint for pending index updates if needed
446
-		$event = new GenericEvent($indexInfo);
447
-		$this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
448
-
449
-		return $indexInfo->getListOfMissingIndexes();
450
-	}
451
-
452
-	protected function hasMissingColumns(): array {
453
-		$indexInfo = new MissingColumnInformation();
454
-		// Dispatch event so apps can also hint for pending index updates if needed
455
-		$event = new GenericEvent($indexInfo);
456
-		$this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, $event);
457
-
458
-		return $indexInfo->getListOfMissingColumns();
459
-	}
460
-
461
-	protected function isSqliteUsed() {
462
-		return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
463
-	}
464
-
465
-	protected function isReadOnlyConfig(): bool {
466
-		return \OC_Helper::isReadOnlyConfigEnabled();
467
-	}
468
-
469
-	protected function hasValidTransactionIsolationLevel(): bool {
470
-		try {
471
-			if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
472
-				return true;
473
-			}
474
-
475
-			return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED;
476
-		} catch (DBALException $e) {
477
-			// ignore
478
-		}
479
-
480
-		return true;
481
-	}
482
-
483
-	protected function hasFileinfoInstalled(): bool {
484
-		return \OC_Util::fileInfoLoaded();
485
-	}
486
-
487
-	protected function hasWorkingFileLocking(): bool {
488
-		return !($this->lockingProvider instanceof NoopLockingProvider);
489
-	}
490
-
491
-	protected function getSuggestedOverwriteCliURL(): string {
492
-		$suggestedOverwriteCliUrl = '';
493
-		if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
494
-			$suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
495
-			if (!$this->config->getSystemValue('config_is_read_only', false)) {
496
-				// Set the overwrite URL when it was not set yet.
497
-				$this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
498
-				$suggestedOverwriteCliUrl = '';
499
-			}
500
-		}
501
-		return $suggestedOverwriteCliUrl;
502
-	}
503
-
504
-	protected function getLastCronInfo(): array {
505
-		$lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
506
-		return [
507
-			'diffInSeconds' => time() - $lastCronRun,
508
-			'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
509
-			'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
510
-		];
511
-	}
512
-
513
-	protected function getCronErrors() {
514
-		$errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
515
-
516
-		if (is_array($errors)) {
517
-			return $errors;
518
-		}
519
-
520
-		return [];
521
-	}
522
-
523
-	protected function isPHPMailerUsed(): bool {
524
-		return $this->config->getSystemValue('mail_smtpmode', 'smtp') === 'php';
525
-	}
526
-
527
-	protected function hasOpcacheLoaded(): bool {
528
-		return extension_loaded('Zend OPcache');
529
-	}
530
-
531
-	/**
532
-	 * Iterates through the configured app roots and
533
-	 * tests if the subdirectories are owned by the same user than the current user.
534
-	 *
535
-	 * @return array
536
-	 */
537
-	protected function getAppDirsWithDifferentOwner(): array {
538
-		$currentUser = posix_getuid();
539
-		$appDirsWithDifferentOwner = [[]];
540
-
541
-		foreach (OC::$APPSROOTS as $appRoot) {
542
-			if ($appRoot['writable'] === true) {
543
-				$appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
544
-			}
545
-		}
546
-
547
-		$appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
548
-		sort($appDirsWithDifferentOwner);
549
-
550
-		return $appDirsWithDifferentOwner;
551
-	}
552
-
553
-	/**
554
-	 * Tests if the directories for one apps directory are writable by the current user.
555
-	 *
556
-	 * @param int $currentUser The current user
557
-	 * @param array $appRoot The app root config
558
-	 * @return string[] The none writable directory paths inside the app root
559
-	 */
560
-	private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
561
-		$appDirsWithDifferentOwner = [];
562
-		$appsPath = $appRoot['path'];
563
-		$appsDir = new DirectoryIterator($appRoot['path']);
564
-
565
-		foreach ($appsDir as $fileInfo) {
566
-			if ($fileInfo->isDir() && !$fileInfo->isDot()) {
567
-				$absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
568
-				$appDirUser = fileowner($absAppPath);
569
-				if ($appDirUser !== $currentUser) {
570
-					$appDirsWithDifferentOwner[] = $absAppPath;
571
-				}
572
-			}
573
-		}
574
-
575
-		return $appDirsWithDifferentOwner;
576
-	}
577
-
578
-	/**
579
-	 * Checks for potential PHP modules that would improve the instance
580
-	 *
581
-	 * @return string[] A list of PHP modules that is recommended
582
-	 */
583
-	protected function hasRecommendedPHPModules(): array {
584
-		$recommendedPHPModules = [];
585
-
586
-		if (!extension_loaded('intl')) {
587
-			$recommendedPHPModules[] = 'intl';
588
-		}
589
-
590
-		if (!extension_loaded('bcmath')) {
591
-			$recommendedPHPModules[] = 'bcmath';
592
-		}
593
-
594
-		if (!extension_loaded('gmp')) {
595
-			$recommendedPHPModules[] = 'gmp';
596
-		}
597
-
598
-		if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
599
-			if (!extension_loaded('imagick')) {
600
-				$recommendedPHPModules[] = 'imagick';
601
-			}
602
-		}
603
-
604
-		return $recommendedPHPModules;
605
-	}
606
-
607
-	protected function isMysqlUsedWithoutUTF8MB4(): bool {
608
-		return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
609
-	}
610
-
611
-	protected function hasBigIntConversionPendingColumns(): array {
612
-		// copy of ConvertFilecacheBigInt::getColumnsByTable()
613
-		$tables = [
614
-			'activity' => ['activity_id', 'object_id'],
615
-			'activity_mq' => ['mail_id'],
616
-			'authtoken' => ['id'],
617
-			'bruteforce_attempts' => ['id'],
618
-			'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
619
-			'file_locks' => ['id'],
620
-			'jobs' => ['id'],
621
-			'mimetypes' => ['id'],
622
-			'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
623
-			'storages' => ['numeric_id'],
624
-		];
625
-
626
-		$schema = new SchemaWrapper($this->db);
627
-		$isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
628
-		$pendingColumns = [];
629
-
630
-		foreach ($tables as $tableName => $columns) {
631
-			if (!$schema->hasTable($tableName)) {
632
-				continue;
633
-			}
634
-
635
-			$table = $schema->getTable($tableName);
636
-			foreach ($columns as $columnName) {
637
-				$column = $table->getColumn($columnName);
638
-				$isAutoIncrement = $column->getAutoincrement();
639
-				$isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
640
-				if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
641
-					$pendingColumns[] = $tableName . '.' . $columnName;
642
-				}
643
-			}
644
-		}
645
-
646
-		return $pendingColumns;
647
-	}
648
-
649
-	protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
650
-		$objectStore = $this->config->getSystemValue('objectstore', null);
651
-		$objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
652
-
653
-		if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
654
-			return true;
655
-		}
656
-
657
-		if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
658
-			return true;
659
-		}
660
-
661
-		if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
662
-			return true;
663
-		}
664
-
665
-		$tempPath = sys_get_temp_dir();
666
-		if (!is_dir($tempPath)) {
667
-			$this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
668
-			return false;
669
-		}
670
-		$freeSpaceInTemp = disk_free_space($tempPath);
671
-		if ($freeSpaceInTemp === false) {
672
-			$this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
673
-			return false;
674
-		}
675
-
676
-		$freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
677
-		if ($freeSpaceInTempInGB > 50) {
678
-			return true;
679
-		}
680
-
681
-		$this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
682
-		return false;
683
-	}
684
-
685
-	/**
686
-	 * @return DataResponse
687
-	 */
688
-	public function check() {
689
-		$phpDefaultCharset = new PhpDefaultCharset();
690
-		$phpOutputBuffering = new PhpOutputBuffering();
691
-		$legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
692
-		return new DataResponse(
693
-			[
694
-				'isGetenvServerWorking' => !empty(getenv('PATH')),
695
-				'isReadOnlyConfig' => $this->isReadOnlyConfig(),
696
-				'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
697
-				'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
698
-				'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
699
-				'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
700
-				'cronInfo' => $this->getLastCronInfo(),
701
-				'cronErrors' => $this->getCronErrors(),
702
-				'serverHasInternetConnectionProblems' => $this->hasInternetConnectivityProblems(),
703
-				'isMemcacheConfigured' => $this->isMemcacheConfigured(),
704
-				'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
705
-				'isRandomnessSecure' => $this->isRandomnessSecure(),
706
-				'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
707
-				'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
708
-				'phpSupported' => $this->isPhpSupported(),
709
-				'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
710
-				'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
711
-				'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
712
-				'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
713
-				'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
714
-				'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
715
-				'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
716
-				'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
717
-				'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
718
-				'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
719
-				'missingIndexes' => $this->hasMissingIndexes(),
720
-				'missingColumns' => $this->hasMissingColumns(),
721
-				'isSqliteUsed' => $this->isSqliteUsed(),
722
-				'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
723
-				'isPHPMailerUsed' => $this->isPHPMailerUsed(),
724
-				'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
725
-				'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
726
-				'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
727
-				'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
728
-				'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
729
-				'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
730
-				'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
731
-				'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
732
-				PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()],
733
-				PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()],
734
-				LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()],
735
-			]
736
-		);
737
-	}
388
+            $formattedTextResponse .= print_r($completeResults, true);
389
+        } else {
390
+            $formattedTextResponse = 'No errors have been found.';
391
+        }
392
+
393
+
394
+        $response = new DataDisplayResponse(
395
+            $formattedTextResponse,
396
+            Http::STATUS_OK,
397
+            [
398
+                'Content-Type' => 'text/plain',
399
+            ]
400
+        );
401
+
402
+        return $response;
403
+    }
404
+
405
+    /**
406
+     * Checks whether a PHP opcache is properly set up
407
+     * @return bool
408
+     */
409
+    protected function isOpcacheProperlySetup() {
410
+        $iniWrapper = new IniGetWrapper();
411
+
412
+        if (!$iniWrapper->getBool('opcache.enable')) {
413
+            return false;
414
+        }
415
+
416
+        if (!$iniWrapper->getBool('opcache.save_comments')) {
417
+            return false;
418
+        }
419
+
420
+        if ($iniWrapper->getNumeric('opcache.max_accelerated_files') < 10000) {
421
+            return false;
422
+        }
423
+
424
+        if ($iniWrapper->getNumeric('opcache.memory_consumption') < 128) {
425
+            return false;
426
+        }
427
+
428
+        if ($iniWrapper->getNumeric('opcache.interned_strings_buffer') < 8) {
429
+            return false;
430
+        }
431
+
432
+        return true;
433
+    }
434
+
435
+    /**
436
+     * Check if the required FreeType functions are present
437
+     * @return bool
438
+     */
439
+    protected function hasFreeTypeSupport() {
440
+        return function_exists('imagettfbbox') && function_exists('imagettftext');
441
+    }
442
+
443
+    protected function hasMissingIndexes(): array {
444
+        $indexInfo = new MissingIndexInformation();
445
+        // Dispatch event so apps can also hint for pending index updates if needed
446
+        $event = new GenericEvent($indexInfo);
447
+        $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_INDEXES_EVENT, $event);
448
+
449
+        return $indexInfo->getListOfMissingIndexes();
450
+    }
451
+
452
+    protected function hasMissingColumns(): array {
453
+        $indexInfo = new MissingColumnInformation();
454
+        // Dispatch event so apps can also hint for pending index updates if needed
455
+        $event = new GenericEvent($indexInfo);
456
+        $this->dispatcher->dispatch(IDBConnection::CHECK_MISSING_COLUMNS_EVENT, $event);
457
+
458
+        return $indexInfo->getListOfMissingColumns();
459
+    }
460
+
461
+    protected function isSqliteUsed() {
462
+        return strpos($this->config->getSystemValue('dbtype'), 'sqlite') !== false;
463
+    }
464
+
465
+    protected function isReadOnlyConfig(): bool {
466
+        return \OC_Helper::isReadOnlyConfigEnabled();
467
+    }
468
+
469
+    protected function hasValidTransactionIsolationLevel(): bool {
470
+        try {
471
+            if ($this->db->getDatabasePlatform() instanceof SqlitePlatform) {
472
+                return true;
473
+            }
474
+
475
+            return $this->db->getTransactionIsolation() === Connection::TRANSACTION_READ_COMMITTED;
476
+        } catch (DBALException $e) {
477
+            // ignore
478
+        }
479
+
480
+        return true;
481
+    }
482
+
483
+    protected function hasFileinfoInstalled(): bool {
484
+        return \OC_Util::fileInfoLoaded();
485
+    }
486
+
487
+    protected function hasWorkingFileLocking(): bool {
488
+        return !($this->lockingProvider instanceof NoopLockingProvider);
489
+    }
490
+
491
+    protected function getSuggestedOverwriteCliURL(): string {
492
+        $suggestedOverwriteCliUrl = '';
493
+        if ($this->config->getSystemValue('overwrite.cli.url', '') === '') {
494
+            $suggestedOverwriteCliUrl = $this->request->getServerProtocol() . '://' . $this->request->getInsecureServerHost() . \OC::$WEBROOT;
495
+            if (!$this->config->getSystemValue('config_is_read_only', false)) {
496
+                // Set the overwrite URL when it was not set yet.
497
+                $this->config->setSystemValue('overwrite.cli.url', $suggestedOverwriteCliUrl);
498
+                $suggestedOverwriteCliUrl = '';
499
+            }
500
+        }
501
+        return $suggestedOverwriteCliUrl;
502
+    }
503
+
504
+    protected function getLastCronInfo(): array {
505
+        $lastCronRun = $this->config->getAppValue('core', 'lastcron', 0);
506
+        return [
507
+            'diffInSeconds' => time() - $lastCronRun,
508
+            'relativeTime' => $this->dateTimeFormatter->formatTimeSpan($lastCronRun),
509
+            'backgroundJobsUrl' => $this->urlGenerator->linkToRoute('settings.AdminSettings.index', ['section' => 'server']) . '#backgroundjobs',
510
+        ];
511
+    }
512
+
513
+    protected function getCronErrors() {
514
+        $errors = json_decode($this->config->getAppValue('core', 'cronErrors', ''), true);
515
+
516
+        if (is_array($errors)) {
517
+            return $errors;
518
+        }
519
+
520
+        return [];
521
+    }
522
+
523
+    protected function isPHPMailerUsed(): bool {
524
+        return $this->config->getSystemValue('mail_smtpmode', 'smtp') === 'php';
525
+    }
526
+
527
+    protected function hasOpcacheLoaded(): bool {
528
+        return extension_loaded('Zend OPcache');
529
+    }
530
+
531
+    /**
532
+     * Iterates through the configured app roots and
533
+     * tests if the subdirectories are owned by the same user than the current user.
534
+     *
535
+     * @return array
536
+     */
537
+    protected function getAppDirsWithDifferentOwner(): array {
538
+        $currentUser = posix_getuid();
539
+        $appDirsWithDifferentOwner = [[]];
540
+
541
+        foreach (OC::$APPSROOTS as $appRoot) {
542
+            if ($appRoot['writable'] === true) {
543
+                $appDirsWithDifferentOwner[] = $this->getAppDirsWithDifferentOwnerForAppRoot($currentUser, $appRoot);
544
+            }
545
+        }
546
+
547
+        $appDirsWithDifferentOwner = array_merge(...$appDirsWithDifferentOwner);
548
+        sort($appDirsWithDifferentOwner);
549
+
550
+        return $appDirsWithDifferentOwner;
551
+    }
552
+
553
+    /**
554
+     * Tests if the directories for one apps directory are writable by the current user.
555
+     *
556
+     * @param int $currentUser The current user
557
+     * @param array $appRoot The app root config
558
+     * @return string[] The none writable directory paths inside the app root
559
+     */
560
+    private function getAppDirsWithDifferentOwnerForAppRoot(int $currentUser, array $appRoot): array {
561
+        $appDirsWithDifferentOwner = [];
562
+        $appsPath = $appRoot['path'];
563
+        $appsDir = new DirectoryIterator($appRoot['path']);
564
+
565
+        foreach ($appsDir as $fileInfo) {
566
+            if ($fileInfo->isDir() && !$fileInfo->isDot()) {
567
+                $absAppPath = $appsPath . DIRECTORY_SEPARATOR . $fileInfo->getFilename();
568
+                $appDirUser = fileowner($absAppPath);
569
+                if ($appDirUser !== $currentUser) {
570
+                    $appDirsWithDifferentOwner[] = $absAppPath;
571
+                }
572
+            }
573
+        }
574
+
575
+        return $appDirsWithDifferentOwner;
576
+    }
577
+
578
+    /**
579
+     * Checks for potential PHP modules that would improve the instance
580
+     *
581
+     * @return string[] A list of PHP modules that is recommended
582
+     */
583
+    protected function hasRecommendedPHPModules(): array {
584
+        $recommendedPHPModules = [];
585
+
586
+        if (!extension_loaded('intl')) {
587
+            $recommendedPHPModules[] = 'intl';
588
+        }
589
+
590
+        if (!extension_loaded('bcmath')) {
591
+            $recommendedPHPModules[] = 'bcmath';
592
+        }
593
+
594
+        if (!extension_loaded('gmp')) {
595
+            $recommendedPHPModules[] = 'gmp';
596
+        }
597
+
598
+        if ($this->config->getAppValue('theming', 'enabled', 'no') === 'yes') {
599
+            if (!extension_loaded('imagick')) {
600
+                $recommendedPHPModules[] = 'imagick';
601
+            }
602
+        }
603
+
604
+        return $recommendedPHPModules;
605
+    }
606
+
607
+    protected function isMysqlUsedWithoutUTF8MB4(): bool {
608
+        return ($this->config->getSystemValue('dbtype', 'sqlite') === 'mysql') && ($this->config->getSystemValue('mysql.utf8mb4', false) === false);
609
+    }
610
+
611
+    protected function hasBigIntConversionPendingColumns(): array {
612
+        // copy of ConvertFilecacheBigInt::getColumnsByTable()
613
+        $tables = [
614
+            'activity' => ['activity_id', 'object_id'],
615
+            'activity_mq' => ['mail_id'],
616
+            'authtoken' => ['id'],
617
+            'bruteforce_attempts' => ['id'],
618
+            'filecache' => ['fileid', 'storage', 'parent', 'mimetype', 'mimepart', 'mtime', 'storage_mtime'],
619
+            'file_locks' => ['id'],
620
+            'jobs' => ['id'],
621
+            'mimetypes' => ['id'],
622
+            'mounts' => ['id', 'storage_id', 'root_id', 'mount_id'],
623
+            'storages' => ['numeric_id'],
624
+        ];
625
+
626
+        $schema = new SchemaWrapper($this->db);
627
+        $isSqlite = $this->db->getDatabasePlatform() instanceof SqlitePlatform;
628
+        $pendingColumns = [];
629
+
630
+        foreach ($tables as $tableName => $columns) {
631
+            if (!$schema->hasTable($tableName)) {
632
+                continue;
633
+            }
634
+
635
+            $table = $schema->getTable($tableName);
636
+            foreach ($columns as $columnName) {
637
+                $column = $table->getColumn($columnName);
638
+                $isAutoIncrement = $column->getAutoincrement();
639
+                $isAutoIncrementOnSqlite = $isSqlite && $isAutoIncrement;
640
+                if ($column->getType()->getName() !== Types::BIGINT && !$isAutoIncrementOnSqlite) {
641
+                    $pendingColumns[] = $tableName . '.' . $columnName;
642
+                }
643
+            }
644
+        }
645
+
646
+        return $pendingColumns;
647
+    }
648
+
649
+    protected function isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(): bool {
650
+        $objectStore = $this->config->getSystemValue('objectstore', null);
651
+        $objectStoreMultibucket = $this->config->getSystemValue('objectstore_multibucket', null);
652
+
653
+        if (!isset($objectStoreMultibucket) && !isset($objectStore)) {
654
+            return true;
655
+        }
656
+
657
+        if (isset($objectStoreMultibucket['class']) && $objectStoreMultibucket['class'] !== 'OC\\Files\\ObjectStore\\S3') {
658
+            return true;
659
+        }
660
+
661
+        if (isset($objectStore['class']) && $objectStore['class'] !== 'OC\\Files\\ObjectStore\\S3') {
662
+            return true;
663
+        }
664
+
665
+        $tempPath = sys_get_temp_dir();
666
+        if (!is_dir($tempPath)) {
667
+            $this->logger->error('Error while checking the temporary PHP path - it was not properly set to a directory. value: ' . $tempPath);
668
+            return false;
669
+        }
670
+        $freeSpaceInTemp = disk_free_space($tempPath);
671
+        if ($freeSpaceInTemp === false) {
672
+            $this->logger->error('Error while checking the available disk space of temporary PHP path - no free disk space returned. temporary path: ' . $tempPath);
673
+            return false;
674
+        }
675
+
676
+        $freeSpaceInTempInGB = $freeSpaceInTemp / 1024 / 1024 / 1024;
677
+        if ($freeSpaceInTempInGB > 50) {
678
+            return true;
679
+        }
680
+
681
+        $this->logger->warning('Checking the available space in the temporary path resulted in ' . round($freeSpaceInTempInGB, 1) . ' GB instead of the recommended 50GB. Path: ' . $tempPath);
682
+        return false;
683
+    }
684
+
685
+    /**
686
+     * @return DataResponse
687
+     */
688
+    public function check() {
689
+        $phpDefaultCharset = new PhpDefaultCharset();
690
+        $phpOutputBuffering = new PhpOutputBuffering();
691
+        $legacySSEKeyFormat = new LegacySSEKeyFormat($this->l10n, $this->config, $this->urlGenerator);
692
+        return new DataResponse(
693
+            [
694
+                'isGetenvServerWorking' => !empty(getenv('PATH')),
695
+                'isReadOnlyConfig' => $this->isReadOnlyConfig(),
696
+                'hasValidTransactionIsolationLevel' => $this->hasValidTransactionIsolationLevel(),
697
+                'hasFileinfoInstalled' => $this->hasFileinfoInstalled(),
698
+                'hasWorkingFileLocking' => $this->hasWorkingFileLocking(),
699
+                'suggestedOverwriteCliURL' => $this->getSuggestedOverwriteCliURL(),
700
+                'cronInfo' => $this->getLastCronInfo(),
701
+                'cronErrors' => $this->getCronErrors(),
702
+                'serverHasInternetConnectionProblems' => $this->hasInternetConnectivityProblems(),
703
+                'isMemcacheConfigured' => $this->isMemcacheConfigured(),
704
+                'memcacheDocs' => $this->urlGenerator->linkToDocs('admin-performance'),
705
+                'isRandomnessSecure' => $this->isRandomnessSecure(),
706
+                'securityDocs' => $this->urlGenerator->linkToDocs('admin-security'),
707
+                'isUsedTlsLibOutdated' => $this->isUsedTlsLibOutdated(),
708
+                'phpSupported' => $this->isPhpSupported(),
709
+                'forwardedForHeadersWorking' => $this->forwardedForHeadersWorking(),
710
+                'reverseProxyDocs' => $this->urlGenerator->linkToDocs('admin-reverse-proxy'),
711
+                'isCorrectMemcachedPHPModuleInstalled' => $this->isCorrectMemcachedPHPModuleInstalled(),
712
+                'hasPassedCodeIntegrityCheck' => $this->checker->hasPassedCheck(),
713
+                'codeIntegrityCheckerDocumentation' => $this->urlGenerator->linkToDocs('admin-code-integrity'),
714
+                'isOpcacheProperlySetup' => $this->isOpcacheProperlySetup(),
715
+                'hasOpcacheLoaded' => $this->hasOpcacheLoaded(),
716
+                'phpOpcacheDocumentation' => $this->urlGenerator->linkToDocs('admin-php-opcache'),
717
+                'isSettimelimitAvailable' => $this->isSettimelimitAvailable(),
718
+                'hasFreeTypeSupport' => $this->hasFreeTypeSupport(),
719
+                'missingIndexes' => $this->hasMissingIndexes(),
720
+                'missingColumns' => $this->hasMissingColumns(),
721
+                'isSqliteUsed' => $this->isSqliteUsed(),
722
+                'databaseConversionDocumentation' => $this->urlGenerator->linkToDocs('admin-db-conversion'),
723
+                'isPHPMailerUsed' => $this->isPHPMailerUsed(),
724
+                'mailSettingsDocumentation' => $this->urlGenerator->getAbsoluteURL('index.php/settings/admin'),
725
+                'isMemoryLimitSufficient' => $this->memoryInfo->isMemoryLimitSufficient(),
726
+                'appDirsWithDifferentOwner' => $this->getAppDirsWithDifferentOwner(),
727
+                'recommendedPHPModules' => $this->hasRecommendedPHPModules(),
728
+                'pendingBigIntConversionColumns' => $this->hasBigIntConversionPendingColumns(),
729
+                'isMysqlUsedWithoutUTF8MB4' => $this->isMysqlUsedWithoutUTF8MB4(),
730
+                'isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed' => $this->isEnoughTempSpaceAvailableIfS3PrimaryStorageIsUsed(),
731
+                'reverseProxyGeneratedURL' => $this->urlGenerator->getAbsoluteURL('index.php'),
732
+                PhpDefaultCharset::class => ['pass' => $phpDefaultCharset->run(), 'description' => $phpDefaultCharset->description(), 'severity' => $phpDefaultCharset->severity()],
733
+                PhpOutputBuffering::class => ['pass' => $phpOutputBuffering->run(), 'description' => $phpOutputBuffering->description(), 'severity' => $phpOutputBuffering->severity()],
734
+                LegacySSEKeyFormat::class => ['pass' => $legacySSEKeyFormat->run(), 'description' => $legacySSEKeyFormat->description(), 'severity' => $legacySSEKeyFormat->severity(), 'linkToDocumentation' => $legacySSEKeyFormat->linkToDocumentation()],
735
+            ]
736
+        );
737
+    }
738 738
 }
Please login to merge, or discard this patch.
apps/settings/lib/SetupChecks/LegacySSEKeyFormat.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -32,32 +32,32 @@
 block discarded – undo
32 32
 use OCP\IURLGenerator;
33 33
 
34 34
 class LegacySSEKeyFormat {
35
-	/** @var IL10N */
36
-	private $l10n;
37
-	/** @var IConfig */
38
-	private $config;
39
-	/** @var IURLGenerator */
40
-	private $urlGenerator;
41
-
42
-	public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) {
43
-		$this->l10n = $l10n;
44
-		$this->config = $config;
45
-		$this->urlGenerator = $urlGenerator;
46
-	}
47
-
48
-	public function description(): string {
49
-		return $this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.');
50
-	}
51
-
52
-	public function severity(): string {
53
-		return 'warning';
54
-	}
55
-
56
-	public function run(): bool {
57
-		return $this->config->getSystemValueBool('encryption.legacy_format_support', false) === false;
58
-	}
59
-
60
-	public function linkToDocumentation(): string {
61
-		return $this->urlGenerator->linkToDocs('admin-sse-legacy-format');
62
-	}
35
+    /** @var IL10N */
36
+    private $l10n;
37
+    /** @var IConfig */
38
+    private $config;
39
+    /** @var IURLGenerator */
40
+    private $urlGenerator;
41
+
42
+    public function __construct(IL10N $l10n, IConfig $config, IURLGenerator $urlGenerator) {
43
+        $this->l10n = $l10n;
44
+        $this->config = $config;
45
+        $this->urlGenerator = $urlGenerator;
46
+    }
47
+
48
+    public function description(): string {
49
+        return $this->l10n->t('The old server-side-encryption format is enabled. We recommend disabling this.');
50
+    }
51
+
52
+    public function severity(): string {
53
+        return 'warning';
54
+    }
55
+
56
+    public function run(): bool {
57
+        return $this->config->getSystemValueBool('encryption.legacy_format_support', false) === false;
58
+    }
59
+
60
+    public function linkToDocumentation(): string {
61
+        return $this->urlGenerator->linkToDocs('admin-sse-legacy-format');
62
+    }
63 63
 }
Please login to merge, or discard this patch.
lib/private/Repair.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -68,177 +68,177 @@
 block discarded – undo
68 68
 
69 69
 class Repair implements IOutput {
70 70
 
71
-	/** @var IRepairStep[] */
72
-	private $repairSteps;
73
-
74
-	/** @var EventDispatcherInterface */
75
-	private $dispatcher;
76
-
77
-	/** @var string */
78
-	private $currentStep;
79
-
80
-	/**
81
-	 * Creates a new repair step runner
82
-	 *
83
-	 * @param IRepairStep[] $repairSteps array of RepairStep instances
84
-	 * @param EventDispatcherInterface $dispatcher
85
-	 */
86
-	public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
87
-		$this->repairSteps = $repairSteps;
88
-		$this->dispatcher  = $dispatcher;
89
-	}
90
-
91
-	/**
92
-	 * Run a series of repair steps for common problems
93
-	 */
94
-	public function run() {
95
-		if (count($this->repairSteps) === 0) {
96
-			$this->emit('\OC\Repair', 'info', ['No repair steps available']);
97
-
98
-			return;
99
-		}
100
-		// run each repair step
101
-		foreach ($this->repairSteps as $step) {
102
-			$this->currentStep = $step->getName();
103
-			$this->emit('\OC\Repair', 'step', [$this->currentStep]);
104
-			$step->run($this);
105
-		}
106
-	}
107
-
108
-	/**
109
-	 * Add repair step
110
-	 *
111
-	 * @param IRepairStep|string $repairStep repair step
112
-	 * @throws \Exception
113
-	 */
114
-	public function addStep($repairStep) {
115
-		if (is_string($repairStep)) {
116
-			try {
117
-				$s = \OC::$server->query($repairStep);
118
-			} catch (QueryException $e) {
119
-				if (class_exists($repairStep)) {
120
-					$s = new $repairStep();
121
-				} else {
122
-					throw new \Exception("Repair step '$repairStep' is unknown");
123
-				}
124
-			}
125
-
126
-			if ($s instanceof IRepairStep) {
127
-				$this->repairSteps[] = $s;
128
-			} else {
129
-				throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
130
-			}
131
-		} else {
132
-			$this->repairSteps[] = $repairStep;
133
-		}
134
-	}
135
-
136
-	/**
137
-	 * Returns the default repair steps to be run on the
138
-	 * command line or after an upgrade.
139
-	 *
140
-	 * @return IRepairStep[]
141
-	 */
142
-	public static function getRepairSteps() {
143
-		return [
144
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
145
-			new RepairMimeTypes(\OC::$server->getConfig()),
146
-			new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
147
-			new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
148
-			new MoveUpdaterStepFile(\OC::$server->getConfig()),
149
-			new FixMountStorages(\OC::$server->getDatabaseConnection()),
150
-			new AddLogRotateJob(\OC::$server->getJobList()),
151
-			new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
152
-			new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
153
-			new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
154
-			new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
155
-			new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
156
-			new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
157
-			new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
158
-			new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)),
159
-			\OC::$server->query(ResetGeneratedAvatarFlag::class),
160
-			\OC::$server->query(EncryptionLegacyCipher::class),
161
-		];
162
-	}
163
-
164
-	/**
165
-	 * Returns expensive repair steps to be run on the
166
-	 * command line with a special option.
167
-	 *
168
-	 * @return IRepairStep[]
169
-	 */
170
-	public static function getExpensiveRepairSteps() {
171
-		return [
172
-			new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
173
-		];
174
-	}
175
-
176
-	/**
177
-	 * Returns the repair steps to be run before an
178
-	 * upgrade.
179
-	 *
180
-	 * @return IRepairStep[]
181
-	 */
182
-	public static function getBeforeUpgradeRepairSteps() {
183
-		$connection = \OC::$server->getDatabaseConnection();
184
-		$config     = \OC::$server->getConfig();
185
-		$steps      = [
186
-			new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
187
-			new SqliteAutoincrement($connection),
188
-			new SaveAccountsTableData($connection, $config),
189
-			new DropAccountTermsTable($connection)
190
-		];
191
-
192
-		return $steps;
193
-	}
194
-
195
-	/**
196
-	 * @param string $scope
197
-	 * @param string $method
198
-	 * @param array $arguments
199
-	 */
200
-	public function emit($scope, $method, array $arguments = []) {
201
-		if (!is_null($this->dispatcher)) {
202
-			$this->dispatcher->dispatch("$scope::$method",
203
-				new GenericEvent("$scope::$method", $arguments));
204
-		}
205
-	}
206
-
207
-	public function info($string) {
208
-		// for now just emit as we did in the past
209
-		$this->emit('\OC\Repair', 'info', [$string]);
210
-	}
211
-
212
-	/**
213
-	 * @param string $message
214
-	 */
215
-	public function warning($message) {
216
-		// for now just emit as we did in the past
217
-		$this->emit('\OC\Repair', 'warning', [$message]);
218
-	}
219
-
220
-	/**
221
-	 * @param int $max
222
-	 */
223
-	public function startProgress($max = 0) {
224
-		// for now just emit as we did in the past
225
-		$this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
226
-	}
227
-
228
-	/**
229
-	 * @param int $step
230
-	 * @param string $description
231
-	 */
232
-	public function advance($step = 1, $description = '') {
233
-		// for now just emit as we did in the past
234
-		$this->emit('\OC\Repair', 'advance', [$step, $description]);
235
-	}
236
-
237
-	/**
238
-	 * @param int $max
239
-	 */
240
-	public function finishProgress() {
241
-		// for now just emit as we did in the past
242
-		$this->emit('\OC\Repair', 'finishProgress', []);
243
-	}
71
+    /** @var IRepairStep[] */
72
+    private $repairSteps;
73
+
74
+    /** @var EventDispatcherInterface */
75
+    private $dispatcher;
76
+
77
+    /** @var string */
78
+    private $currentStep;
79
+
80
+    /**
81
+     * Creates a new repair step runner
82
+     *
83
+     * @param IRepairStep[] $repairSteps array of RepairStep instances
84
+     * @param EventDispatcherInterface $dispatcher
85
+     */
86
+    public function __construct(array $repairSteps, EventDispatcherInterface $dispatcher) {
87
+        $this->repairSteps = $repairSteps;
88
+        $this->dispatcher  = $dispatcher;
89
+    }
90
+
91
+    /**
92
+     * Run a series of repair steps for common problems
93
+     */
94
+    public function run() {
95
+        if (count($this->repairSteps) === 0) {
96
+            $this->emit('\OC\Repair', 'info', ['No repair steps available']);
97
+
98
+            return;
99
+        }
100
+        // run each repair step
101
+        foreach ($this->repairSteps as $step) {
102
+            $this->currentStep = $step->getName();
103
+            $this->emit('\OC\Repair', 'step', [$this->currentStep]);
104
+            $step->run($this);
105
+        }
106
+    }
107
+
108
+    /**
109
+     * Add repair step
110
+     *
111
+     * @param IRepairStep|string $repairStep repair step
112
+     * @throws \Exception
113
+     */
114
+    public function addStep($repairStep) {
115
+        if (is_string($repairStep)) {
116
+            try {
117
+                $s = \OC::$server->query($repairStep);
118
+            } catch (QueryException $e) {
119
+                if (class_exists($repairStep)) {
120
+                    $s = new $repairStep();
121
+                } else {
122
+                    throw new \Exception("Repair step '$repairStep' is unknown");
123
+                }
124
+            }
125
+
126
+            if ($s instanceof IRepairStep) {
127
+                $this->repairSteps[] = $s;
128
+            } else {
129
+                throw new \Exception("Repair step '$repairStep' is not of type \\OCP\\Migration\\IRepairStep");
130
+            }
131
+        } else {
132
+            $this->repairSteps[] = $repairStep;
133
+        }
134
+    }
135
+
136
+    /**
137
+     * Returns the default repair steps to be run on the
138
+     * command line or after an upgrade.
139
+     *
140
+     * @return IRepairStep[]
141
+     */
142
+    public static function getRepairSteps() {
143
+        return [
144
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), \OC::$server->getDatabaseConnection(), false),
145
+            new RepairMimeTypes(\OC::$server->getConfig()),
146
+            new CleanTags(\OC::$server->getDatabaseConnection(), \OC::$server->getUserManager()),
147
+            new RepairInvalidShares(\OC::$server->getConfig(), \OC::$server->getDatabaseConnection()),
148
+            new MoveUpdaterStepFile(\OC::$server->getConfig()),
149
+            new FixMountStorages(\OC::$server->getDatabaseConnection()),
150
+            new AddLogRotateJob(\OC::$server->getJobList()),
151
+            new ClearFrontendCaches(\OC::$server->getMemCacheFactory(), \OC::$server->query(SCSSCacher::class), \OC::$server->query(JSCombiner::class)),
152
+            new ClearGeneratedAvatarCache(\OC::$server->getConfig(), \OC::$server->query(AvatarManager::class)),
153
+            new AddPreviewBackgroundCleanupJob(\OC::$server->getJobList()),
154
+            new AddCleanupUpdaterBackupsJob(\OC::$server->getJobList()),
155
+            new CleanupCardDAVPhotoCache(\OC::$server->getConfig(), \OC::$server->getAppDataDir('dav-photocache'), \OC::$server->getLogger()),
156
+            new AddClenupLoginFlowV2BackgroundJob(\OC::$server->getJobList()),
157
+            new RemoveLinkShares(\OC::$server->getDatabaseConnection(), \OC::$server->getConfig(), \OC::$server->getGroupManager(), \OC::$server->getNotificationManager(), \OC::$server->query(ITimeFactory::class)),
158
+            new ClearCollectionsAccessCache(\OC::$server->getConfig(), \OC::$server->query(IManager::class)),
159
+            \OC::$server->query(ResetGeneratedAvatarFlag::class),
160
+            \OC::$server->query(EncryptionLegacyCipher::class),
161
+        ];
162
+    }
163
+
164
+    /**
165
+     * Returns expensive repair steps to be run on the
166
+     * command line with a special option.
167
+     *
168
+     * @return IRepairStep[]
169
+     */
170
+    public static function getExpensiveRepairSteps() {
171
+        return [
172
+            new OldGroupMembershipShares(\OC::$server->getDatabaseConnection(), \OC::$server->getGroupManager())
173
+        ];
174
+    }
175
+
176
+    /**
177
+     * Returns the repair steps to be run before an
178
+     * upgrade.
179
+     *
180
+     * @return IRepairStep[]
181
+     */
182
+    public static function getBeforeUpgradeRepairSteps() {
183
+        $connection = \OC::$server->getDatabaseConnection();
184
+        $config     = \OC::$server->getConfig();
185
+        $steps      = [
186
+            new Collation(\OC::$server->getConfig(), \OC::$server->getLogger(), $connection, true),
187
+            new SqliteAutoincrement($connection),
188
+            new SaveAccountsTableData($connection, $config),
189
+            new DropAccountTermsTable($connection)
190
+        ];
191
+
192
+        return $steps;
193
+    }
194
+
195
+    /**
196
+     * @param string $scope
197
+     * @param string $method
198
+     * @param array $arguments
199
+     */
200
+    public function emit($scope, $method, array $arguments = []) {
201
+        if (!is_null($this->dispatcher)) {
202
+            $this->dispatcher->dispatch("$scope::$method",
203
+                new GenericEvent("$scope::$method", $arguments));
204
+        }
205
+    }
206
+
207
+    public function info($string) {
208
+        // for now just emit as we did in the past
209
+        $this->emit('\OC\Repair', 'info', [$string]);
210
+    }
211
+
212
+    /**
213
+     * @param string $message
214
+     */
215
+    public function warning($message) {
216
+        // for now just emit as we did in the past
217
+        $this->emit('\OC\Repair', 'warning', [$message]);
218
+    }
219
+
220
+    /**
221
+     * @param int $max
222
+     */
223
+    public function startProgress($max = 0) {
224
+        // for now just emit as we did in the past
225
+        $this->emit('\OC\Repair', 'startProgress', [$max, $this->currentStep]);
226
+    }
227
+
228
+    /**
229
+     * @param int $step
230
+     * @param string $description
231
+     */
232
+    public function advance($step = 1, $description = '') {
233
+        // for now just emit as we did in the past
234
+        $this->emit('\OC\Repair', 'advance', [$step, $description]);
235
+    }
236
+
237
+    /**
238
+     * @param int $max
239
+     */
240
+    public function finishProgress() {
241
+        // for now just emit as we did in the past
242
+        $this->emit('\OC\Repair', 'finishProgress', []);
243
+    }
244 244
 }
Please login to merge, or discard this patch.