Skip to content

Commit

Permalink
Detect disabled signature check when reparing
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
PVince81 committed Jun 24, 2021
1 parent 68e54fe commit a9215f5
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion apps/encryption/lib/Command/FixEncryptedVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,17 @@
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;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class FixEncryptedVersion extends Command {
/** @var IConfig */
private $config;

/** @var IRootFolder */
private $rootFolder;

Expand All @@ -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;
Expand Down Expand Up @@ -72,6 +77,13 @@ protected function configure() {
* @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";

Expand Down

0 comments on commit a9215f5

Please sign in to comment.