]> source.dussan.org Git - nextcloud-server.git/commitdiff
Detect disabled signature check when reparing
authorVincent Petry <vincent@nextcloud.com>
Thu, 24 Jun 2021 07:31:52 +0000 (09:31 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Wed, 30 Jun 2021 12:23:31 +0000 (12:23 +0000)
When running occ encryption:fix-encrypted-version, detect whether the
setting 'encryption_skip_signature_check' is set and abort if it is,
because the repair cannot detect version mismatch errors with it
enabled.

Signed-off-by: Vincent Petry <vincent@nextcloud.com>
apps/encryption/lib/Command/FixEncryptedVersion.php

index 534ddc4c689934b816e0c85a54be5bb46432a27c..392399258504f97a3c2b030926a368fe0c7c14b5 100644 (file)
@@ -25,6 +25,7 @@ namespace OCA\Encryption\Command;
 use OC\Files\View;
 use OC\HintException;
 use OCP\Files\IRootFolder;
+use OCP\IConfig;
 use OCP\IUserManager;
 use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputArgument;
@@ -32,6 +33,9 @@ use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 
 class FixEncryptedVersion extends Command {
+       /** @var IConfig */
+       private $config;
+
        /** @var IRootFolder  */
        private $rootFolder;
 
@@ -41,7 +45,8 @@ class FixEncryptedVersion extends Command {
        /** @var View  */
        private $view;
 
-       public function __construct(IRootFolder $rootFolder, IUserManager $userManager, View $view) {
+       public function __construct(IConfig $config, IRootFolder $rootFolder, IUserManager $userManager, View $view) {
+               $this->config = $config;
                $this->rootFolder = $rootFolder;
                $this->userManager = $userManager;
                $this->view = $view;
@@ -72,6 +77,13 @@ class FixEncryptedVersion extends Command {
         * @return int
         */
        protected function execute(InputInterface $input, OutputInterface $output) {
+               $skipSignatureCheck = $this->config->getSystemValue('encryption_skip_signature_check', false);
+
+               if ($skipSignatureCheck) {
+                       $output->writeln("<error>Repairing is not possible when \"encryption_skip_signature_check\" is set. Please disable this flag in the configuration.</error>\n");
+                       return 1;
+               }
+
                $user = $input->getArgument('user');
                $pathToWalk = "/$user/files";