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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C772A67AB2 for ; Wed, 13 Jan 2021 13:07:34 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BBA481164B for ; Wed, 13 Jan 2021 13:07:34 +0100 (CET) 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) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 1F94D11640 for ; Wed, 13 Jan 2021 13:07:31 +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 E20FE41A94 for ; Wed, 13 Jan 2021 13:07:30 +0100 (CET) Date: Wed, 13 Jan 2021 13:07:19 +0100 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox Backup Server development discussion References: <20210113112736.307324-1-o.bektas@proxmox.com> In-Reply-To: <20210113112736.307324-1-o.bektas@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1610538822.3bb51j179s.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.028 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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. [user.rs, proxmox.com] Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 1/2] access: limit editing pam credentials to superuser X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Jan 2021 12:07:34 -0000 On January 13, 2021 12:27 pm, Oguz Bektas wrote: > modifying @pam users credentials should be only possible for root@pam, > otherwise it can have unintended consequences. >=20 > Signed-off-by: Oguz Bektas > --- > v1->v2: > * change error message to be more descriptive > * remove empty line > * create CachedUserInfo in the if-branch >=20 >=20 > src/api2/access/user.rs | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs > index 484919bf..4c861c5f 100644 > --- a/src/api2/access/user.rs > +++ b/src/api2/access/user.rs > @@ -350,6 +350,7 @@ pub fn update_user( > email: Option, > delete: Option>, > digest: Option, > + rpcenv: &mut dyn RpcEnvironment, > ) -> Result<(), Error> { > =20 > let _lock =3D open_file_locked(user::USER_CFG_LOCKFILE, std::time::D= uration::new(10, 0), true)?; > @@ -392,7 +393,12 @@ pub fn update_user( > } > =20 > if let Some(password) =3D password { > + let user_info =3D CachedUserInfo::new()?; > + let source_auth_id =3D rpcenv.get_auth_id().unwrap().parse()?; > let authenticator =3D crate::auth::lookup_authenticator(userid.r= ealm())?; > + if userid.realm() =3D=3D "pam" && !user_info.is_superuser(&sourc= e_auth_id) { > + bail!("only superuser can edit pam credentials!"); > + } 1.) that code reads weird, authenticator should be declared and=20 initialized after the check 2.) regular PAM users can now no longer self-service change their own passw= ord > authenticator.store_password(userid.name(), &password)?; > } > =20 > --=20 > 2.20.1 >=20 >=20 > _______________________________________________ > pbs-devel mailing list > pbs-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel >=20 >=20 >=20 =