From: Oguz Bektas <o.bektas@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup] access: limit editing pam credentials to superuser
Date: Tue, 12 Jan 2021 15:40:06 +0100 [thread overview]
Message-ID: <20210112144006.931307-1-o.bektas@proxmox.com> (raw)
modifying @pam users' credentials should be only allowed for root@pam,
otherwise it can have unintended consequences.
Signed-off-by: Oguz Bektas <o.bektas@proxmox.com>
---
src/api2/access/user.rs | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/api2/access/user.rs b/src/api2/access/user.rs
index 484919bf..7c19db2f 100644
--- a/src/api2/access/user.rs
+++ b/src/api2/access/user.rs
@@ -350,8 +350,11 @@ pub fn update_user(
email: Option<String>,
delete: Option<Vec<DeletableProperty>>,
digest: Option<String>,
+ rpcenv: &mut dyn RpcEnvironment,
) -> Result<(), Error> {
+ let user_info = CachedUserInfo::new()?;
+
let _lock = open_file_locked(user::USER_CFG_LOCKFILE, std::time::Duration::new(10, 0), true)?;
let (mut config, expected_digest) = user::config()?;
@@ -391,8 +394,13 @@ pub fn update_user(
data.expire = if expire > 0 { Some(expire) } else { None };
}
+
if let Some(password) = password {
+ 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 this!");
+ }
authenticator.store_password(userid.name(), &password)?;
}
--
2.20.1
next reply other threads:[~2021-01-12 14:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-12 14:40 Oguz Bektas [this message]
2021-01-13 8:49 ` Wolfgang Bumiller
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=20210112144006.931307-1-o.bektas@proxmox.com \
--to=o.bektas@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.