From d3eeecba54fc891da20093c88648e5f10ed0e706 Mon Sep 17 00:00:00 2001 From: Vincent Petry Date: Tue, 29 Jun 2021 20:44:07 +0200 Subject: Prevent running FixEncryptedVersion without master key Return an error when running occ encryption:fix-encrypted-version when master key encryption is not enabled. Signed-off-by: Vincent Petry --- apps/encryption/lib/Command/FixEncryptedVersion.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'apps/encryption/lib') diff --git a/apps/encryption/lib/Command/FixEncryptedVersion.php b/apps/encryption/lib/Command/FixEncryptedVersion.php index e2181f9a229..a85a96258fc 100644 --- a/apps/encryption/lib/Command/FixEncryptedVersion.php +++ b/apps/encryption/lib/Command/FixEncryptedVersion.php @@ -24,6 +24,7 @@ namespace OCA\Encryption\Command; use OC\Files\View; use OC\HintException; +use OCA\Encryption\Util; use OCP\Files\IRootFolder; use OCP\IConfig; use OCP\ILogger; @@ -46,14 +47,25 @@ class FixEncryptedVersion extends Command { /** @var IUserManager */ private $userManager; + /** @var Util */ + private $util; + /** @var View */ private $view; - public function __construct(IConfig $config, ILogger $logger, IRootFolder $rootFolder, IUserManager $userManager, View $view) { + public function __construct( + IConfig $config, + ILogger $logger, + IRootFolder $rootFolder, + IUserManager $userManager, + Util $util, + View $view + ) { $this->config = $config; $this->logger = $logger; $this->rootFolder = $rootFolder; $this->userManager = $userManager; + $this->util = $util; $this->view = $view; parent::__construct(); } @@ -89,6 +101,11 @@ class FixEncryptedVersion extends Command { return 1; } + if (!$this->util->isMasterKeyEnabled()) { + $output->writeln("Repairing only works with master key encryption.\n"); + return 1; + } + $user = (string)$input->getArgument('user'); $pathToWalk = "/$user/files"; -- cgit v1.2.3