Skip to content

Commit d6e9087

Browse files
authored
Merge pull request #724 from nextcloud/backport/723/stable33
[stable33] fix: verify integrity with URL override but allow to disable if needed
2 parents 544cae1 + 12bd187 commit d6e9087

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ Keep in mind that for the update/upgrade process there are some additional compo
239239
- Handles database upgrade migrations
240240
- Handles app updates (i.e. for compatibility with a new major version of Server)
241241

242-
### Dependences needed for building
242+
### Dependencies needed for building
243243

244244
#### box
245245

index.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -830,19 +830,14 @@ private function getDownloadedFilePath(): string {
830830
*
831831
* @throws \Exception
832832
*/
833-
public function verifyIntegrity(string $urlOverride = ''): void {
833+
public function verifyIntegrity(): void {
834834
$this->silentLog('[info] verifyIntegrity()');
835835

836836
if ($this->getCurrentReleaseChannel() === 'daily') {
837837
$this->silentLog('[info] current channel is "daily" which is not signed. Skipping verification.');
838838
return;
839839
}
840840

841-
if ($urlOverride !== '') {
842-
$this->silentLog('[info] custom download url provided, cannot verify signature');
843-
return;
844-
}
845-
846841
$response = $this->getUpdateServerResponse();
847842
if (empty($response['signature'])) {
848843
throw new \Exception('No signature specified for defined update');

lib/UpdateCommand.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ class UpdateCommand extends Command {
2828

2929
protected bool $ignoreState = false;
3030

31+
protected bool $skipIntegrityCheck = false;
32+
3133
protected string $urlOverride = '';
3234

3335
/** Strings of text for stages of updater */
@@ -57,6 +59,7 @@ protected function configure(): void {
5759
->addOption('no-upgrade', null, InputOption::VALUE_NONE, "Don't automatically run occ upgrade")
5860
->addOption('url', null, InputOption::VALUE_OPTIONAL, 'The URL of the Nextcloud release to download')
5961
->addOption('ignore-state', null, InputOption::VALUE_NONE, 'Ignore known state from .step file, do a complete update')
62+
->addOption('no-verify', null, InputOption::VALUE_OPTIONAL, 'Skip integrity verification of the downloaded file')
6063
;
6164
}
6265

@@ -73,6 +76,7 @@ public static function getUpdaterVersion(): string {
7376
protected function execute(InputInterface $input, OutputInterface $output): int {
7477
$this->skipBackup = (bool)$input->getOption('no-backup');
7578
$this->skipUpgrade = (bool)$input->getOption('no-upgrade');
79+
$this->skipIntegrityCheck = (bool)$input->getOption('no-verify');
7680
$this->urlOverride = (string)$input->getOption('url');
7781
$this->ignoreState = (bool)$input->getOption('ignore-state');
7882

@@ -166,6 +170,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
166170
$updateString = $this->updater->checkForUpdate();
167171
}
168172

173+
if ($this->skipIntegrityCheck) {
174+
$this->updater->log('[warn] Integrity check of the downloaded file will be skipped');
175+
$output->writeln('Integrity check of the downloaded file will be skipped.');
176+
}
177+
169178
$output->writeln('');
170179

171180
$lines = explode('<br />', $updateString);
@@ -450,7 +459,11 @@ protected function executeStep(int $step, OutputInterface $output): array {
450459
});
451460
break;
452461
case 5:
453-
$this->updater->verifyIntegrity($this->urlOverride);
462+
if ($this->skipIntegrityCheck) {
463+
$this->updater->silentLog('[info] Skipping integrity check as requested');
464+
break;
465+
}
466+
$this->updater->verifyIntegrity();
454467
break;
455468
case 6:
456469
$this->updater->extractDownload();

lib/Updater.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -814,19 +814,14 @@ private function getDownloadedFilePath(): string {
814814
*
815815
* @throws \Exception
816816
*/
817-
public function verifyIntegrity(string $urlOverride = ''): void {
817+
public function verifyIntegrity(): void {
818818
$this->silentLog('[info] verifyIntegrity()');
819819

820820
if ($this->getCurrentReleaseChannel() === 'daily') {
821821
$this->silentLog('[info] current channel is "daily" which is not signed. Skipping verification.');
822822
return;
823823
}
824824

825-
if ($urlOverride !== '') {
826-
$this->silentLog('[info] custom download url provided, cannot verify signature');
827-
return;
828-
}
829-
830825
$response = $this->getUpdateServerResponse();
831826
if (empty($response['signature'])) {
832827
throw new \Exception('No signature specified for defined update');

updater.phar

3.88 KB
Binary file not shown.

0 commit comments

Comments
 (0)