[pbs-devel] [PATCH v2 proxmox-backup 1/2] access: limit editing pam credentials to superuser
Oguz Bektas
o.bektas at proxmox.com
Wed Jan 13 12:27:35 CET 2021
modifying @pam users credentials should be only possible for root at pam,
otherwise it can have unintended consequences.
Signed-off-by: Oguz Bektas <o.bektas at 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!");
+ }
authenticator.store_password(userid.name(), &password)?;
}
--
2.20.1
More information about the pbs-devel
mailing list