* [pbs-devel] [PATCH proxmox-backup] access: limit editing pam credentials to superuser
@ 2021-01-12 14:40 Oguz Bektas
2021-01-13 8:49 ` Wolfgang Bumiller
0 siblings, 1 reply; 2+ messages in thread
From: Oguz Bektas @ 2021-01-12 14:40 UTC (permalink / raw)
To: pbs-devel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [pbs-devel] [PATCH proxmox-backup] access: limit editing pam credentials to superuser
2021-01-12 14:40 [pbs-devel] [PATCH proxmox-backup] access: limit editing pam credentials to superuser Oguz Bektas
@ 2021-01-13 8:49 ` Wolfgang Bumiller
0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Bumiller @ 2021-01-13 8:49 UTC (permalink / raw)
To: Oguz Bektas; +Cc: pbs-devel
On Tue, Jan 12, 2021 at 03:40:06PM +0100, Oguz Bektas wrote:
> 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!");
And if you see this error message, do you know what "this" is referring to?
> + }
> authenticator.store_password(userid.name(), &password)?;
> }
>
> --
> 2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-13 8:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-12 14:40 [pbs-devel] [PATCH proxmox-backup] access: limit editing pam credentials to superuser Oguz Bektas
2021-01-13 8:49 ` Wolfgang Bumiller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox