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 482367E578 for ; Wed, 10 Nov 2021 15:11:48 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 463811DB63 for ; Wed, 10 Nov 2021 15:11:48 +0100 (CET) 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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 929631DB51 for ; Wed, 10 Nov 2021 15:11:47 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 64DE244B71 for ; Wed, 10 Nov 2021 15:11:47 +0100 (CET) From: Wolfgang Bumiller To: pve-devel@lists.proxmox.com Date: Wed, 10 Nov 2021 15:11:45 +0100 Message-Id: <20211110141146.210803-2-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211110141146.210803-1-w.bumiller@proxmox.com> References: <20211110141146.210803-1-w.bumiller@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.479 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 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. [accesscontrol.pm] Subject: [pve-devel] [PATCH access-control 1/1] implement version checks for tfa 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, 10 Nov 2021 14:11:48 -0000 Signed-off-by: Wolfgang Bumiller --- src/PVE/AccessControl.pm | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/PVE/AccessControl.pm b/src/PVE/AccessControl.pm index cbf643d..f39ac9c 100644 --- a/src/PVE/AccessControl.pm +++ b/src/PVE/AccessControl.pm @@ -1581,8 +1581,8 @@ sub parse_priv_tfa_config { sub write_priv_tfa_config { my ($filename, $cfg) = @_; - # FIXME: Only allow this if the complete cluster has been upgraded to understand the json - # config format. + assert_new_tfa_config_available(); + return $cfg->write(); } @@ -1765,7 +1765,31 @@ my $USER_CONTROLLED_TFA_TYPES = { }; sub assert_new_tfa_config_available() { - # FIXME: Assert cluster-wide new-tfa-config support! + PVE::Cluster::cfs_update(); + my $version_info = PVE::Cluster::get_node_kv('version-info'); + die "cannot update tfa config, please make sure all cluster nodes are up to date\n" + if !$version_info; + my $members = PVE::Cluster::get_members(); + my $old = ''; + foreach my $node (keys $members->%*) { + my $info = $version_info->{$node}; + if (!$info) { + $old .= "cluster node '$node' is too old, did not broadcast its version info\n"; + next; + } + $info = from_json($info); + my $ver = $info->{version}; + if ($ver !~ /^(\d+\.\d+)-(\d+)$/) { + $old .= "cluster node '$node' provided an invalid version string: '$ver'\n"; + next; + } + my ($maj, $rel) = ($1, $2); + if (!($maj > 7.0 || ($maj == 7.0 && $rel >= 15))) { + $old .= "cluster node '$node' is too old\n"; + next; + } + } + die $old if length($old); } sub user_remove_tfa : prototype($) { -- 2.30.2