]> git.proxmox.com Git - pve-storage.git/commitdiff
pbs: add/update: return enc. key, if newly set or auto-generated
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Nov 2020 17:05:26 +0000 (18:05 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 12 Nov 2020 17:05:28 +0000 (18:05 +0100)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/Storage/PBSPlugin.pm

index f3bf01620de4161836aebeb3bacaee9afd1febd8..41d5b89730c0647570f0c95b889e3f40730c22f4 100644 (file)
@@ -371,6 +371,8 @@ my $autogen_encryption_key = sub {
 sub on_add_hook {
     my ($class, $storeid, $scfg, %param) = @_;
 
+    my $res = {};
+
     if (defined(my $password = $param{password})) {
        pbs_set_password($scfg, $storeid, $password);
     } else {
@@ -379,19 +381,24 @@ sub on_add_hook {
 
     if (defined(my $encryption_key = $param{'encryption-key'})) {
        if ($encryption_key eq 'autogen') {
-           $autogen_encryption_key->($scfg, $storeid);
+           $res->{'encryption-key'} = $autogen_encryption_key->($scfg, $storeid);
        } else {
            pbs_set_encryption_key($scfg, $storeid, $encryption_key);
+           $res->{'encryption-key'} = $encryption_key;
        }
        $scfg->{'encryption-key'} = 1;
     } else {
        pbs_delete_encryption_key($scfg, $storeid);
     }
+
+    return $res;
 }
 
 sub on_update_hook {
     my ($class, $storeid, $scfg, %param) = @_;
 
+    my $res = {};
+
     if (exists($param{password})) {
        if (defined($param{password})) {
            pbs_set_password($scfg, $storeid, $param{password});
@@ -403,15 +410,18 @@ sub on_update_hook {
     if (exists($param{'encryption-key'})) {
        if (defined(my $encryption_key = delete($param{'encryption-key'}))) {
            if ($encryption_key eq 'autogen') {
-               $autogen_encryption_key->($scfg, $storeid);
+               $res->{'encryption-key'} = $autogen_encryption_key->($scfg, $storeid);
            } else {
                pbs_set_encryption_key($scfg, $storeid, $encryption_key);
+               $res->{'encryption-key'} = $encryption_key;
            }
            $scfg->{'encryption-key'} = 1;
        } else {
            pbs_delete_encryption_key($scfg, $storeid);
        }
     }
+
+    return $res;
 }
 
 sub on_delete_hook {