[pbs-devel] [PATCH proxmox-backup] access: limit editing pam credentials to superuser

Wolfgang Bumiller w.bumiller at proxmox.com
Wed Jan 13 09:49:52 CET 2021


On Tue, Jan 12, 2021 at 03:40:06PM +0100, Oguz Bektas wrote:
> modifying @pam users' credentials should be only allowed for root at pam,
> otherwise it can have unintended consequences.
> 
> Signed-off-by: Oguz Bektas <o.bektas at 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





More information about the pbs-devel mailing list