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 BE6C272A69 for ; Wed, 16 Jun 2021 14:50:32 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 7DB2611735 for ; Wed, 16 Jun 2021 14:50:02 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 AF3641172A for ; Wed, 16 Jun 2021 14:50:00 +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 7D78A4404F for ; Wed, 16 Jun 2021 14:50:00 +0200 (CEST) Message-ID: Date: Wed, 16 Jun 2021 14:49:55 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:90.0) Gecko/20100101 Thunderbird/90.0 Content-Language: en-US To: Proxmox VE development discussion , =?UTF-8?Q?Fabian_Gr=c3=bcnbichler?= References: <20210616121646.79435-1-l.stechauner@proxmox.com> <1623847161.ldx69rhpb4.astroid@nora.none> From: Thomas Lamprecht In-Reply-To: <1623847161.ldx69rhpb4.astroid@nora.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.920 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment NICE_REPLY_A -0.095 Looks like a legit reply (A) 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. [pve6to7.pm] Subject: Re: [pve-devel] [PATCH v2 manager] pve6to7: add check for pool permissions 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: Wed, 16 Jun 2021 12:50:32 -0000 On 16.06.21 14:45, Fabian Gr=C3=BCnbichler wrote: > On June 16, 2021 2:16 pm, Lorenz Stechauner wrote: >> the two checks make sure that: >> * no user defined role 'PVEPoolUser' exists >> * the user gets a hint for roles only containing Pool.Allocate and >> not Pool.Audit >> >> Signed-off-by: Lorenz Stechauner >> --- >> changes to v1: >> * rebased on master >> >> PVE/CLI/pve6to7.pm | 25 +++++++++++++++++++++++++ >> 1 file changed, 25 insertions(+) >> >> diff --git a/PVE/CLI/pve6to7.pm b/PVE/CLI/pve6to7.pm >> index 90f92a55..b391d006 100644 >> --- a/PVE/CLI/pve6to7.pm >> +++ b/PVE/CLI/pve6to7.pm >> @@ -9,6 +9,7 @@ use PVE::API2::LXC; >> use PVE::API2::Qemu; >> use PVE::API2::Certificates; >> =20 >> +use PVE::AccessControl; >> use PVE::Ceph::Tools; >> use PVE::Cluster; >> use PVE::Corosync; >> @@ -693,6 +694,30 @@ sub check_misc { >> =20 >> check_backup_retention_settings(); >> check_cifs_credential_location(); >> + >> + log_info("Check custom roles"); >> + my $usercfg =3D PVE::Cluster::cfs_read_file("user.cfg"); >> + foreach my $role (sort keys %{$usercfg->{roles}}) { >> + if (PVE::AccessControl::role_is_special($role)) { >> + next; >> + } >> + >> + if ($role eq "PVEPoolUser") { >> + # the user created a custom role named PVEPoolUser >> + log_fail("Custom role '$role' has a restricted name - a built-in= role 'PVEPoolUser' will be available with the upgrade"); >> + } else { >> + log_pass("Custom role '$role' has no restricted name"); >> + } >> + >> + my $perms =3D $usercfg->{roles}->{$role}; >> + if ($perms->{'Pool.Allocate'} && $perms->{'Pool.Audit'}) { >> + log_pass("Custom role '$role' contains updated pool permissions"= ); >=20 > that does not work for PVE 6.x, where Pool.Audit is not yet a valid=20 > privilege, so gets dropped on parsing user.cfg ;) >=20 > so either we add it as valid privilege (without using it for anything) = > in a new stable-6 branch, or we switch to lower-level parsing/checks=20 > here.. the file format is pretty simple, so the following should=20 > probably work for the purposes of the check: did not try, but in theory you could also just mock the relevant subs in = the pve 6 case to add that as valid priv there for this script only?