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 8AEA283BB1 for ; Tue, 7 Dec 2021 09:10:45 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 797E0285FA for ; Tue, 7 Dec 2021 09:10:15 +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 C0314285EC for ; Tue, 7 Dec 2021 09:10:14 +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 93A464431C for ; Tue, 7 Dec 2021 09:10:14 +0100 (CET) From: Wolfgang Bumiller To: pve-devel@lists.proxmox.com Date: Tue, 7 Dec 2021 09:10:12 +0100 Message-Id: <20211207081013.8995-1-w.bumiller@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.421 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. [tfa.pm] Subject: [pve-devel] [PATCH v2 access-control 1/2] tfa: when modifying others, verify the current user's password 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: Tue, 07 Dec 2021 08:10:45 -0000 this was wrong as it asked for the password of the to-be-edited user instead, which makes no sense Signed-off-by: Wolfgang Bumiller --- Changes to v1: * Fixed $ruid/$authuser parameter in the final auth call * Renamed $ruid to $auth_username to address Fabian's concerns. I did not go with just $username, since we already have a $userid which is the user we're modifying, while $authuser is the user to authenticate. src/PVE/API2/TFA.pm | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/PVE/API2/TFA.pm b/src/PVE/API2/TFA.pm index be696e1..31e5741 100644 --- a/src/PVE/API2/TFA.pm +++ b/src/PVE/API2/TFA.pm @@ -101,7 +101,7 @@ my $TFA_UPDATE_INFO_SCHEMA = { my sub root_permission_check : prototype($$$$) { my ($rpcenv, $authuser, $userid, $password) = @_; - ($userid, my $ruid, my $realm) = PVE::AccessControl::verify_username($userid); + ($userid, undef, my $realm) = PVE::AccessControl::verify_username($userid); $rpcenv->check_user_exist($userid); raise_perm_exc() if $userid eq 'root@pam' && $authuser ne 'root@pam'; @@ -111,11 +111,14 @@ my sub root_permission_check : prototype($$$$) { raise_param_exc({ 'password' => 'password is required to modify TFA data' }) if !defined($password); + ($authuser, my $auth_username, my $auth_realm) = + PVE::AccessControl::verify_username($authuser); + my $domain_cfg = cfs_read_file('domains.cfg'); - my $cfg = $domain_cfg->{ids}->{$realm}; - die "auth domain '$realm' does not exist\n" if !$cfg; + my $cfg = $domain_cfg->{ids}->{$auth_realm}; + die "auth domain '$auth_realm' does not exist\n" if !$cfg; my $plugin = PVE::Auth::Plugin->lookup($cfg->{type}); - $plugin->authenticate_user($cfg, $realm, $ruid, $password); + $plugin->authenticate_user($cfg, $auth_realm, $auth_username, $password); } return wantarray ? ($userid, $realm) : $userid; -- 2.30.2