]> git.proxmox.com Git - pve-storage.git/commitdiff
pbs: detect mismatch of encryption settings and key
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Tue, 16 Aug 2022 10:33:53 +0000 (12:33 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 16 Aug 2022 11:51:38 +0000 (13:51 +0200)
if the key file doesn't exist (anymore), but the storage.cfg references
one, die on commands that should use encryption instead of falling back
to plain-text operations.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
Tested-by: Stoiko Ivanov <s.ivanov@proxmox.com>
PVE/Storage/PBSPlugin.pm

index 56632caa63c0dd40c7205bc39205498641f30dc0..b90a2ddb7e262e81b3016d451fef6c40f73c83a4 100644 (file)
@@ -155,7 +155,12 @@ sub pbs_open_encryption_key {
 
     my $keyfd;
     if (!open($keyfd, '<', $encryption_key_file)) {
-       return undef if $! == ENOENT;
+       if ($! == ENOENT) {
+           my $encryption_fp = $scfg->{'encryption-key'};
+           die "encryption configured ('$encryption_fp') but no encryption key file found!\n"
+               if $encryption_fp;
+           return undef;
+       }
        die "failed to open encryption key: $encryption_key_file: $!\n";
     }