mirror of
https://git.proxmox.com/git/pve-common
synced 2025-07-27 06:34:02 +00:00
tools: add extract_sensitive_params
moved and generalized from pve-storage, since we'll need it in more places Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
5640c3db26
commit
40682a697d
@ -48,6 +48,7 @@ template_replace
|
|||||||
safe_print
|
safe_print
|
||||||
trim
|
trim
|
||||||
extract_param
|
extract_param
|
||||||
|
extract_sensitive_params
|
||||||
file_copy
|
file_copy
|
||||||
get_host_arch
|
get_host_arch
|
||||||
O_PATH
|
O_PATH
|
||||||
@ -807,6 +808,29 @@ sub extract_param {
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub extract_sensitive_params :prototype($$$) {
|
||||||
|
my ($param, $sensitive_list, $delete_list) = @_;
|
||||||
|
|
||||||
|
my $sensitive;
|
||||||
|
|
||||||
|
my %delete = map { $_ => 1 } ($delete_list || [])->@*;
|
||||||
|
|
||||||
|
# always extract sensitive keys, so they don't get written to the www-data readable scfg
|
||||||
|
for my $opt (@$sensitive_list) {
|
||||||
|
# First handle deletions as explicitly setting `undef`, afterwards new values may override
|
||||||
|
# it.
|
||||||
|
if (exists($delete{$opt})) {
|
||||||
|
$sensitive->{$opt} = undef;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defined(my $value = extract_param($param, $opt))) {
|
||||||
|
$sensitive->{$opt} = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sensitive;
|
||||||
|
}
|
||||||
|
|
||||||
# Note: we use this to wait until vncterm/spiceterm is ready
|
# Note: we use this to wait until vncterm/spiceterm is ready
|
||||||
sub wait_for_vnc_port {
|
sub wait_for_vnc_port {
|
||||||
my ($port, $family, $timeout) = @_;
|
my ($port, $family, $timeout) = @_;
|
||||||
|
Loading…
Reference in New Issue
Block a user