From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 6F6E3705AB for ; Fri, 2 Apr 2021 14:59:11 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5CCA4F099 for ; Fri, 2 Apr 2021 14:58:41 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 7E78BF08F for ; Fri, 2 Apr 2021 14:58:40 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 43E924594D for ; Fri, 2 Apr 2021 14:58:40 +0200 (CEST) Message-ID: <89ccc8a8-9337-ae32-2e97-e65211e6eaeb@proxmox.com> Date: Fri, 2 Apr 2021 14:58:39 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:88.0) Gecko/20100101 Thunderbird/88.0 Content-Language: en-US To: Fabian Ebner , Proxmox VE development discussion References: <20210311092208.27221-1-f.ebner@proxmox.com> <20210311092208.27221-2-f.ebner@proxmox.com> From: Thomas Lamprecht In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL -0.043 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.001 Looks like a legit reply (A) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox.com] Subject: Re: [pve-devel] [PATCH v3 manager 2/4] api: vzdump: add call to get currently configured vzdump defaults X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Apr 2021 12:59:11 -0000 On 02.04.21 14:27, Fabian Ebner wrote: > Am 01.04.21 um 15:40 schrieb Thomas Lamprecht: >> On 11.03.21 10:22, Fabian Ebner wrote: >>> +=C2=A0=C2=A0=C2=A0 user =3D> 'all', >>> +=C2=A0=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0=C2=A0 proxyto =3D> 'node', >>> +=C2=A0=C2=A0=C2=A0 parameters =3D> { >>> +=C2=A0=C2=A0=C2=A0 additionalProperties =3D> 0, >>> +=C2=A0=C2=A0=C2=A0 properties =3D> { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 node =3D> get_standard_op= tion('pve-node'), >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 storage =3D> get_standard= _option('pve-storage-id', { optional =3D> 1 }), >>> +=C2=A0=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0=C2=A0 returns =3D> { >>> +=C2=A0=C2=A0=C2=A0 type =3D> 'object', >>> +=C2=A0=C2=A0=C2=A0 additionalProperties =3D> 0, >>> +=C2=A0=C2=A0=C2=A0 properties =3D> PVE::VZDump::Common::json_config_= properties(), >> >> above may suggest that all those properties are returned, but we delet= e some >> out flat, so even if one would access this as root@pam they won't get = all of >> those and may get confused due to API schema/return value mismatch. >> >> Maybe we could derive a hash from above list at module scope, and dele= te those >> keys that never will be returned. That list could also be reused below=20 for >> filtering out those unwanted keys too then. >> >=20 > The only key that is always dropped is the deprecated 'size' key. For p= rivileged users, all others are returned. And the schema says that all pr= operties are optional. We could create a new hash and drop the 'optional'=20 for those with a default value that are never dropped, but not sure if th= at's worth it... hmm, yeah in that case it's probably not worth it... >=20 >>> +=C2=A0=C2=A0=C2=A0 }, >>> +=C2=A0=C2=A0=C2=A0 code =3D> sub { >>> +=C2=A0=C2=A0=C2=A0 my ($param) =3D @_; >>> + >>> +=C2=A0=C2=A0=C2=A0 my $node =3D extract_param($param, 'node'); >>> +=C2=A0=C2=A0=C2=A0 my $storage =3D extract_param($param, 'storage');= >>> + >>> +=C2=A0=C2=A0=C2=A0 my $rpcenv =3D PVE::RPCEnvironment::get(); >>> +=C2=A0=C2=A0=C2=A0 my $authuser =3D $rpcenv->get_user(); >>> + >>> +=C2=A0=C2=A0=C2=A0 my $res =3D PVE::VZDump::read_vzdump_defaults(); >>> + >>> +=C2=A0=C2=A0=C2=A0 $res->{storage} =3D $storage if defined($storage)= ; >>> + >>> +=C2=A0=C2=A0=C2=A0 if (!defined($res->{dumpdir}) && !defined($res->{= storage})) { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $res->{storage} =3D 'loca= l'; >>> +=C2=A0=C2=A0=C2=A0 } >>> + >>> +=C2=A0=C2=A0=C2=A0 if (defined($res->{storage})) { >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $rpcenv->check_any( >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 $authuser, >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 "/storage/$res->{storage}= ", >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ['Datastore.Audit', 'Data= store.AllocateSpace'], >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ); >>> + >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 my $info =3D PVE::VZDump:= :storage_info($res->{storage}); >>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 foreach my $key (qw(dumpd= ir prune-backups)) { >> >> style nit, for new code use `for`, `foreach` has no additional value/f= unctionality >> over `for` since a long time (if ever, actually not too sure from top = of my head). >> >=20 > Will do, but might be worth updating the style guide: > "use either of foreach or for when looping over a list of elements." >=20 > https://pve.proxmox.com/wiki/Perl_Style_Guide#Perl_syntax_choices good catch, done!