From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH v2 proxmox-backup 1/2] access: limit editing pam credentials to superuser
Date: Wed, 13 Jan 2021 13:07:19 +0100 [thread overview]
Message-ID: <1610538822.3bb51j179s.astroid@nora.none> (raw)
In-Reply-To: <20210113112736.307324-1-o.bektas@proxmox.com>
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.
>
> Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
> ---
> v1->v2:
> * change error message to be more descriptive
> * remove empty line
> * create CachedUserInfo in the if-branch
>
>
> src/api2/access/user.rs | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> 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<String>,
> delete: Option<Vec<DeletableProperty>>,
> digest: Option<String>,
> + rpcenv: &mut dyn RpcEnvironment,
> ) -> Result<(), Error> {
>
> let _lock = open_file_locked(user::USER_CFG_LOCKFILE, std::time::Duration::new(10, 0), true)?;
> @@ -392,7 +393,12 @@ pub fn update_user(
> }
>
> if let Some(password) = password {
> + let user_info = CachedUserInfo::new()?;
> + let source_auth_id = rpcenv.get_auth_id().unwrap().parse()?;
> let authenticator = crate::auth::lookup_authenticator(userid.realm())?;
> + if userid.realm() == "pam" && !user_info.is_superuser(&source_auth_id) {
> + bail!("only superuser can edit pam credentials!");
> + }
1.) that code reads weird, authenticator should be declared and
initialized after the check
2.) regular PAM users can now no longer self-service change their own password
> authenticator.store_password(userid.name(), &password)?;
> }
>
> --
> 2.20.1
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
>
prev parent reply other threads:[~2021-01-13 12:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-13 11:27 Oguz Bektas
2021-01-13 11:27 ` [pbs-devel] [PATCH v2 proxmox-backup 2/2] access: restrictions for editing passwords Oguz Bektas
2021-01-13 12:07 ` Fabian Grünbichler [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1610538822.3bb51j179s.astroid@nora.none \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox