public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH storage 1/1] api: storage/config: use extract_sensitive_params from tools
Date: Wed,  2 Dec 2020 10:21:05 +0100	[thread overview]
Message-ID: <20201202092113.15911-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20201202092113.15911-1-d.csapak@proxmox.com>

we have a more general version there

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 PVE/API2/Storage/Config.pm | 29 ++++-------------------------
 1 file changed, 4 insertions(+), 25 deletions(-)

diff --git a/PVE/API2/Storage/Config.pm b/PVE/API2/Storage/Config.pm
index 6e23427..00abd13 100755
--- a/PVE/API2/Storage/Config.pm
+++ b/PVE/API2/Storage/Config.pm
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use PVE::SafeSyslog;
-use PVE::Tools qw(extract_param);
+use PVE::Tools qw(extract_param extract_sensitive_params);
 use PVE::Cluster qw(cfs_read_file cfs_write_file);
 use PVE::Storage;
 use PVE::Storage::Plugin;
@@ -112,28 +112,7 @@ __PACKAGE__->register_method ({
 	return &$api_storage_config($cfg, $param->{storage});
     }});
 
-my sub extract_sensitive_params :prototype($$) {
-    my ($param, $delete_list) = @_;
-
-    my $sensitive;
-
-    my %delete = map { $_ => 1 } ($delete_list || [])->@*;
-
-    # always extract pw and keys, so they don't get written to the www-data readable scfg
-    for my $opt (qw(password encryption-key)) {
-	# 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;
-}
+my $sensitive_params = [qw(password encryption-key)];
 
 __PACKAGE__->register_method ({
     name => 'create',
@@ -182,7 +161,7 @@ __PACKAGE__->register_method ({
 	# fix me in section config create never need an empty entity.
 	delete $param->{nodes} if !$param->{nodes};
 
-	my $sensitive = extract_sensitive_params($param, []);
+	my $sensitive = extract_sensitive_params($param, $sensitive_params, []);
 
 	my $plugin = PVE::Storage::Plugin->lookup($type);
 	my $opts = $plugin->check_config($storeid, $param, 1, 1);
@@ -282,7 +261,7 @@ __PACKAGE__->register_method ({
 	    my $scfg = PVE::Storage::storage_config($cfg, $storeid);
 	    $type = $scfg->{type};
 
-	    my $sensitive = extract_sensitive_params($param, $delete);
+	    my $sensitive = extract_sensitive_params($param, $sensitive_params, $delete);
 
 	    my $plugin = PVE::Storage::Plugin->lookup($type);
 	    my $opts = $plugin->check_config($storeid, $param, 0, 1);
-- 
2.20.1





  parent reply	other threads:[~2020-12-02  9:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  9:21 [pve-devel] [PATCH common/storage/manager/docs] implement http api for influxdb status plugin Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH common 1/1] tools: add extract_sensitive_params Dominik Csapak
2020-12-03  8:47   ` Thomas Lamprecht
2020-12-03  9:16     ` Wolfgang Bumiller
2020-12-03  9:35       ` Thomas Lamprecht
2020-12-03 15:52   ` [pve-devel] applied: " Thomas Lamprecht
2020-12-02  9:21 ` Dominik Csapak [this message]
2021-01-28 16:31   ` [pve-devel] applied: [PATCH storage 1/1] api: storage/config: use extract_sensitive_params from tools Thomas Lamprecht
2020-12-02  9:21 ` [pve-devel] [PATCH manager 1/7] api: cluster/metricserver: prevent simultaneosly setting and deleting of property Dominik Csapak
2020-12-03  9:05   ` Thomas Lamprecht
2020-12-04 11:30     ` Dominik Csapak
2020-12-04 11:57       ` Thomas Lamprecht
2020-12-04 12:45         ` Thomas Lamprecht
2020-12-02  9:21 ` [pve-devel] [PATCH manager 2/7] status/plugin: extend send/_connect/_disconnect/test_connection Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 3/7] status/plugin: extend with add/update/delete hooks Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 4/7] status/influxdb: implement influxdb 2.x http api Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 5/7] status/influxdb: remove unnecessary comment Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 6/7] ui: add necessary fields for influxdb http api Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH manager 7/7] ui: dc/MetricServerView: add onlineHelp to edit windows Dominik Csapak
2020-12-02  9:21 ` [pve-devel] [PATCH docs 1/1] external metrics server: extend docs to explain http api Dominik Csapak
2021-01-28 16:36 ` [pve-devel] applied-series: [PATCH common/storage/manager/docs] implement http api for influxdb status plugin Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201202092113.15911-3-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal