2020-06-22 13:35:52 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2020-08-24 12:54:25 +00:00
|
|
|
|
2020-06-22 13:35:52 +00:00
|
|
|
/**
|
2024-05-23 07:26:56 +00:00
|
|
|
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2020-06-22 13:35:52 +00:00
|
|
|
*/
|
|
|
|
namespace OC\Repair\NC20;
|
|
|
|
|
|
|
|
use OCP\Encryption\IManager;
|
|
|
|
use OCP\IConfig;
|
|
|
|
use OCP\Migration\IOutput;
|
|
|
|
use OCP\Migration\IRepairStep;
|
|
|
|
|
|
|
|
class EncryptionMigration implements IRepairStep {
|
|
|
|
/** @var IConfig */
|
|
|
|
private $config;
|
|
|
|
/** @var IManager */
|
|
|
|
private $manager;
|
|
|
|
|
|
|
|
public function __construct(IConfig $config,
|
|
|
|
IManager $manager) {
|
|
|
|
$this->config = $config;
|
|
|
|
$this->manager = $manager;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName(): string {
|
|
|
|
return 'Check encryption key format';
|
|
|
|
}
|
|
|
|
|
|
|
|
private function shouldRun(): bool {
|
2023-04-05 10:50:08 +00:00
|
|
|
$versionFromBeforeUpdate = $this->config->getSystemValueString('version', '0.0.0.0');
|
2020-06-22 13:35:52 +00:00
|
|
|
return version_compare($versionFromBeforeUpdate, '20.0.0.1', '<=');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run(IOutput $output): void {
|
2020-11-20 08:46:31 +00:00
|
|
|
if (!$this->shouldRun()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2020-11-27 09:01:34 +00:00
|
|
|
$masterKeyId = $this->config->getAppValue('encryption', 'masterKeyId');
|
|
|
|
if ($this->manager->isEnabled() || !empty($masterKeyId)) {
|
2020-06-22 13:35:52 +00:00
|
|
|
if ($this->config->getSystemValue('encryption.key_storage_migrated', '') === '') {
|
|
|
|
$this->config->setSystemValue('encryption.key_storage_migrated', false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|