]> git.proxmox.com Git - pve-storage.git/commitdiff
pbs: autogen key: rename old one if existing
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 24 Nov 2020 21:05:21 +0000 (22:05 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 24 Nov 2020 21:05:23 +0000 (22:05 +0100)
it could be debated do have some security implications and that
deletion is safer, but key deletion is a pretty hairy thing.

Should be documented, and people just should use delete instead of
autogen if they want to "destroy" a key.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/Storage/PBSPlugin.pm

index 7d3db34c9593e7ea3c08838e8371b3265d1ddd5e..e046e99f4831dfc0d63d1f30bfd501db5f007071 100644 (file)
@@ -371,6 +371,9 @@ sub prune_backups {
 my $autogen_encryption_key = sub {
     my ($scfg, $storeid) = @_;
     my $encfile = pbs_encryption_key_file_name($scfg, $storeid);
+    if (-f $encfile) {
+       rename $encfile, "$encfile.old";
+    }
     my $cmd = ['proxmox-backup-client', 'key', 'create', '--kdf', 'none', $encfile];
     run_command($cmd, errmsg => 'failed to create encryption key');
     return PVE::Tools::file_get_contents($encfile);