refactor sensitive parameter handling

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller
2020-07-09 10:25:43 +02:00
committed by Thomas Lamprecht
parent 76bb5febc7
commit 72385de9e2
3 changed files with 41 additions and 32 deletions

View File

@ -161,6 +161,9 @@ sub on_add_hook {
if (defined($param{password})) {
cifs_set_credentials($param{password}, $storeid);
if (!exists($scfg->{username})) {
warn "ignoring password parameter\n";
}
} else {
cifs_delete_credentials($storeid);
}
@ -173,6 +176,9 @@ sub on_update_hook {
if (defined($param{password})) {
cifs_set_credentials($param{password}, $storeid);
if (!exists($scfg->{username})) {
warn "ignoring password parameter\n";
}
} else {
cifs_delete_credentials($storeid);
}

View File

@ -266,7 +266,7 @@ sub on_add_hook {
pbs_delete_password($scfg, $storeid);
}
if (defined(my $encryption_key = delete($scfg->{encryption_key}))) {
if (defined(my $encryption_key = $param{encryption_key})) {
pbs_set_encryption_key($scfg, $storeid, $encryption_key);
} else {
pbs_delete_encryption_key($scfg, $storeid);
@ -284,8 +284,8 @@ sub on_update_hook {
}
}
if (exists($scfg->{encryption_key})) {
if (defined(my $encryption_key = delete($scfg->{encryption_key}))) {
if (exists($param{encryption_key})) {
if (defined(my $encryption_key = delete($param{encryption_key}))) {
pbs_set_encryption_key($scfg, $storeid, $encryption_key);
} else {
pbs_delete_encryption_key($scfg, $storeid);