Skip to content

Commit

Permalink
Check disabled legacy cipher support when fixing
Browse files Browse the repository at this point in the history
When fixing encrypted version, make sure to not misdetect unencrypted
files when the legacy cipher support is still enabled.

Signed-off-by: Vincent Petry <[email protected]>
  • Loading branch information
PVince81 committed Aug 12, 2021
1 parent 25961e3 commit 6dad182
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/encryption/lib/Command/FixEncryptedVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ class FixEncryptedVersion extends Command {
/** @var View */
private $view;

/** @var bool */
private $supportLegacy;

public function __construct(
IConfig $config,
ILogger $logger,
Expand All @@ -68,6 +71,8 @@ public function __construct(
$this->userManager = $userManager;
$this->util = $util;
$this->view = $view;
$this->supportLegacy = false;

parent::__construct();
}

Expand Down Expand Up @@ -96,6 +101,7 @@ protected function configure(): void {
*/
protected function execute(InputInterface $input, OutputInterface $output): int {
$skipSignatureCheck = $this->config->getSystemValue('encryption_skip_signature_check', false);
$this->supportLegacy = $this->config->getSystemValueBool('encryption.legacy_format_support', 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");
Expand Down Expand Up @@ -191,7 +197,7 @@ private function verifyFileContent($path, OutputInterface $output, $ignoreCorrec
} catch (ServerNotAvailableException $e) {
// not a "bad signature" error and likely "legacy cipher" exception
// this could mean that the file is maybe not encrypted but the encrypted version is set
if ($ignoreCorrectEncVersionCall === true) {
if (!$this->supportLegacy && $ignoreCorrectEncVersionCall === true) {
$output->writeln("<info>Attempting to fix the path: \"$path\"</info>");
return $this->correctEncryptedVersion($path, $output, true);
}
Expand Down

0 comments on commit 6dad182

Please sign in to comment.