diff options
author | Morris Jobke <hey@morrisjobke.de> | 2019-05-22 22:32:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-22 22:32:13 +0200 |
commit | 9a733b7f501d2176ca85d8e3ecf6b583cc36fe06 (patch) | |
tree | 2bb9fb1ebe018b970edf5ebdd40e9f66e573e7f6 /core | |
parent | daaa14e92141353dfa5e55c8c77e3af11c8e3ad8 (diff) | |
parent | 98047e8c1cd8c741f4a3d63b970f7e15fa76c128 (diff) | |
download | nextcloud-server-9a733b7f501d2176ca85d8e3ecf6b583cc36fe06.tar.gz nextcloud-server-9a733b7f501d2176ca85d8e3ecf6b583cc36fe06.zip |
Merge pull request #12114 from RubenHoms/master
Stop decryption when maintenance mode is enabled
Diffstat (limited to 'core')
-rw-r--r-- | core/Command/Encryption/DecryptAll.php | 9 | ||||
-rw-r--r-- | core/Command/Encryption/ListModules.php | 18 | ||||
-rw-r--r-- | core/Command/Encryption/SetDefaultModule.php | 18 | ||||
-rw-r--r-- | core/register_command.php | 4 |
4 files changed, 45 insertions, 4 deletions
diff --git a/core/Command/Encryption/DecryptAll.php b/core/Command/Encryption/DecryptAll.php index 6ae90196963..2d45689d1b3 100644 --- a/core/Command/Encryption/DecryptAll.php +++ b/core/Command/Encryption/DecryptAll.php @@ -132,6 +132,15 @@ class DecryptAll extends Command { return; } + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); + if ($isMaintenanceModeEnabled) { + $output->writeln("Maintenance mode must be disabled when starting decryption,"); + $output->writeln("in order to load the relevant encryption modules correctly."); + $output->writeln("Your instance will automatically be put to maintenance mode"); + $output->writeln("during the actual decryption of the files."); + return; + } + try { if ($this->encryptionManager->isEnabled() === true) { $output->write('Disable server side encryption... '); diff --git a/core/Command/Encryption/ListModules.php b/core/Command/Encryption/ListModules.php index 82a2e5f50f7..2b1402ed5ef 100644 --- a/core/Command/Encryption/ListModules.php +++ b/core/Command/Encryption/ListModules.php @@ -24,6 +24,7 @@ namespace OC\Core\Command\Encryption; use OC\Core\Command\Base; use OCP\Encryption\IManager; +use OCP\IConfig; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -31,12 +32,20 @@ class ListModules extends Base { /** @var IManager */ protected $encryptionManager; + /** @var IConfig */ + protected $config; + /** * @param IManager $encryptionManager + * @param IConfig $config */ - public function __construct(IManager $encryptionManager) { + public function __construct( + IManager $encryptionManager, + IConfig $config + ) { parent::__construct(); $this->encryptionManager = $encryptionManager; + $this->config = $config; } protected function configure() { @@ -49,6 +58,13 @@ class ListModules extends Base { } protected function execute(InputInterface $input, OutputInterface $output) { + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); + if ($isMaintenanceModeEnabled) { + $output->writeln("Maintenance mode must be disabled when listing modules"); + $output->writeln("in order to list the relevant encryption modules correctly."); + return; + } + $encryptionModules = $this->encryptionManager->getEncryptionModules(); $defaultEncryptionModuleId = $this->encryptionManager->getDefaultEncryptionModuleId(); diff --git a/core/Command/Encryption/SetDefaultModule.php b/core/Command/Encryption/SetDefaultModule.php index 1a008c7724a..3399bd45b25 100644 --- a/core/Command/Encryption/SetDefaultModule.php +++ b/core/Command/Encryption/SetDefaultModule.php @@ -24,6 +24,7 @@ namespace OC\Core\Command\Encryption; use OCP\Encryption\IManager; +use OCP\IConfig; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -33,12 +34,20 @@ class SetDefaultModule extends Command { /** @var IManager */ protected $encryptionManager; + /** @var IConfig */ + protected $config; + /** * @param IManager $encryptionManager + * @param IConfig $config */ - public function __construct(IManager $encryptionManager) { + public function __construct( + IManager $encryptionManager, + IConfig $config + ) { parent::__construct(); $this->encryptionManager = $encryptionManager; + $this->config = $config; } protected function configure() { @@ -56,6 +65,13 @@ class SetDefaultModule extends Command { } protected function execute(InputInterface $input, OutputInterface $output) { + $isMaintenanceModeEnabled = $this->config->getSystemValue('maintenance', false); + if ($isMaintenanceModeEnabled) { + $output->writeln("Maintenance mode must be disabled when setting default module,"); + $output->writeln("in order to load the relevant encryption modules correctly."); + return; + } + $moduleId = $input->getArgument('module'); if ($moduleId === $this->encryptionManager->getDefaultEncryptionModuleId()) { diff --git a/core/register_command.php b/core/register_command.php index 6bd1b1b18a9..8690e1d1cba 100644 --- a/core/register_command.php +++ b/core/register_command.php @@ -99,8 +99,8 @@ if (\OC::$server->getConfig()->getSystemValue('installed', false)) { $application->add(new OC\Core\Command\Encryption\Disable(\OC::$server->getConfig())); $application->add(new OC\Core\Command\Encryption\Enable(\OC::$server->getConfig(), \OC::$server->getEncryptionManager())); - $application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager())); - $application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager())); + $application->add(new OC\Core\Command\Encryption\ListModules(\OC::$server->getEncryptionManager(), \OC::$server->getConfig())); + $application->add(new OC\Core\Command\Encryption\SetDefaultModule(\OC::$server->getEncryptionManager(), \OC::$server->getConfig())); $application->add(new OC\Core\Command\Encryption\Status(\OC::$server->getEncryptionManager())); $application->add(new OC\Core\Command\Encryption\EncryptAll(\OC::$server->getEncryptionManager(), \OC::$server->getAppManager(), \OC::$server->getConfig(), new \Symfony\Component\Console\Helper\QuestionHelper())); $application->add(new OC\Core\Command\Encryption\DecryptAll( |