From a8491e83b4969a66a73d42907069894b30a17579 Mon Sep 17 00:00:00 2001 From: David Mulder Date: Mon, 26 Aug 2024 07:33:25 -0600 Subject: [PATCH] Add the user's primary group to the cache We create a fake primary group which simply matches the user's upn. This is because Entra ID does not have primary groups, but we can fake it with a primary group which is a member of all the users groups. Signed-off-by: David Mulder Reviewed-by: Alexander Bokovoy --- rust/himmelblaud/src/cache.rs | 1 - rust/himmelblaud/src/himmelblaud/himmelblaud_getpwnam.rs | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/rust/himmelblaud/src/cache.rs b/rust/himmelblaud/src/cache.rs index 5a344e5f0dd..764753d0037 100644 --- a/rust/himmelblaud/src/cache.rs +++ b/rust/himmelblaud/src/cache.rs @@ -294,7 +294,6 @@ impl GroupEntry { } } -#[cfg(test)] impl GroupEntry { pub fn new(uuid: &str) -> Self { GroupEntry { diff --git a/rust/himmelblaud/src/himmelblaud/himmelblaud_getpwnam.rs b/rust/himmelblaud/src/himmelblaud/himmelblaud_getpwnam.rs index 576a62e78e6..40a7bffcbdc 100644 --- a/rust/himmelblaud/src/himmelblaud/himmelblaud_getpwnam.rs +++ b/rust/himmelblaud/src/himmelblaud/himmelblaud_getpwnam.rs @@ -18,6 +18,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ +use crate::cache::GroupEntry; use crate::himmelblaud::Resolver; use crate::utils::split_username; use dbg::{DBG_ERR, DBG_WARNING}; @@ -59,6 +60,10 @@ impl Resolver { })?; // Store the calculated uid -> upn map in the cache self.uid_cache.store(uid, &upn)?; + // Store the primary group (which is a fake group matching the user upn) + let mut group = GroupEntry::new(upn); + group.add_member(upn); + self.group_cache.merge_groups(upn, vec![group])?; let (cn, domain) = match split_username(&upn) { Ok(res) => res, Err(e) => {