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 5BB1C838D7 for ; Mon, 6 Dec 2021 15:07:26 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3D73820901 for ; Mon, 6 Dec 2021 15:06:56 +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 2A7F3208F5 for ; Mon, 6 Dec 2021 15:06:55 +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 ECE4844A11 for ; Mon, 6 Dec 2021 15:06:54 +0100 (CET) Date: Mon, 06 Dec 2021 15:06:47 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion Cc: w.bumiller@proxmox.com References: <20211206133627.101909-1-w.bumiller@proxmox.com> In-Reply-To: <20211206133627.101909-1-w.bumiller@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1638799288.xt0u3c1b8k.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.251 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 Subject: Re: [pve-devel] [PATCH 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: Mon, 06 Dec 2021 14:07:26 -0000 doesn't work for me On December 6, 2021 2:36 pm, Wolfgang Bumiller wrote: > this was wrong as it asked for the password of the > to-be-edited user instead, which makes no sense >=20 > Signed-off-by: Wolfgang Bumiller > --- > src/PVE/API2/TFA.pm | 10 ++++++---- > 1 file changed, 6 insertions(+), 4 deletions(-) >=20 > diff --git a/src/PVE/API2/TFA.pm b/src/PVE/API2/TFA.pm > index be696e1..343374e 100644 > --- a/src/PVE/API2/TFA.pm > +++ b/src/PVE/API2/TFA.pm > @@ -101,7 +101,7 @@ my $TFA_UPDATE_INFO_SCHEMA =3D { > my sub root_permission_check : prototype($$$$) { > my ($rpcenv, $authuser, $userid, $password) =3D @_; > =20 > - ($userid, my $ruid, my $realm) =3D PVE::AccessControl::verify_userna= me($userid); > + ($userid, undef, my $realm) =3D PVE::AccessControl::verify_username(= $userid); > $rpcenv->check_user_exist($userid); > =20 > raise_perm_exc() if $userid eq 'root@pam' && $authuser ne 'root@pam'= ; > @@ -111,11 +111,13 @@ my sub root_permission_check : prototype($$$$) { > raise_param_exc({ 'password' =3D> 'password is required to modify TFA d= ata' }) > if !defined($password); > =20 > + ($authuser, my $ruid, my $auth_realm) =3D PVE::AccessControl::verify_us= ername($authuser); > + > my $domain_cfg =3D cfs_read_file('domains.cfg'); > - my $cfg =3D $domain_cfg->{ids}->{$realm}; > - die "auth domain '$realm' does not exist\n" if !$cfg; > + my $cfg =3D $domain_cfg->{ids}->{$auth_realm}; > + die "auth domain '$auth_realm' does not exist\n" if !$cfg; > my $plugin =3D PVE::Auth::Plugin->lookup($cfg->{type}); > - $plugin->authenticate_user($cfg, $realm, $ruid, $password); > + $plugin->authenticate_user($cfg, $auth_realm, $authuser, $password); this should likely still be $ruid? (which is actually just the username=20 without realm, which is what authenticate_user expects. so maybe=20 $username might also be a more readable variable name - ruid reads to me=20 like euid and friends) > } > =20 > return wantarray ? ($userid, $realm) : $userid; > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20