From: David Mulder Date: Wed, 31 Jul 2024 20:14:32 +0000 (-0600) Subject: Add nss getgrnam to the himmelblau daemon X-Git-Tag: tdb-1.4.13~912 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c55599e9921f0fc7076d34800a255e0191354ea;p=thirdparty%2Fsamba.git Add nss getgrnam to the himmelblau daemon Signed-off-by: David Mulder Reviewed-by: Alexander Bokovoy --- diff --git a/himmelblaud/src/himmelblaud.rs b/himmelblaud/src/himmelblaud.rs index a4a0af3ca26..9f6167bb7d0 100644 --- a/himmelblaud/src/himmelblaud.rs +++ b/himmelblaud/src/himmelblaud.rs @@ -216,6 +216,9 @@ pub(crate) async fn handle_client( } Request::NssAccountByUid(uid) => resolver.getpwuid(uid).await?, Request::NssGroups => resolver.getgrent().await?, + Request::NssGroupByName(grp_id) => { + resolver.getgrnam(&grp_id).await? + } _ => todo!(), }; reqs.send(resp).await?; @@ -228,6 +231,7 @@ pub(crate) async fn handle_client( } mod himmelblaud_getgrent; +mod himmelblaud_getgrnam; mod himmelblaud_getpwent; mod himmelblaud_getpwnam; mod himmelblaud_getpwuid; diff --git a/himmelblaud/src/himmelblaud/himmelblaud_getgrnam.rs b/himmelblaud/src/himmelblaud/himmelblaud_getgrnam.rs new file mode 100644 index 00000000000..cafc6a4f685 --- /dev/null +++ b/himmelblaud/src/himmelblaud/himmelblaud_getgrnam.rs @@ -0,0 +1,52 @@ +/* + Unix SMB/CIFS implementation. + + Himmelblau daemon implementation for nss getgrnam + + Copyright (C) David Mulder 2024 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ +use crate::himmelblaud::Resolver; +use dbg::DBG_ERR; +use ntstatus_gen::*; +use sock::{Group, Response}; + +impl Resolver { + pub(crate) async fn getgrnam( + &mut self, + grp_id: &str, + ) -> Result> { + let entry = match self.group_cache.fetch(grp_id) { + Some(entry) => entry, + None => return Ok(Response::NssGroup(None)), + }; + let gid = self + .idmap + .gen_to_unix(&self.tenant_id, &entry.uuid.to_uppercase()) + .map_err(|e| { + DBG_ERR!("{:?}", e); + Box::new(NT_STATUS_INVALID_TOKEN) + })?; + // Store the calculated gid -> uuid map in the cache + self.uid_cache.store(gid, &entry.uuid.to_uppercase())?; + let group = Group { + name: entry.uuid.clone(), + passwd: "x".to_string(), + gid, + members: entry.members(), + }; + return Ok(Response::NssGroup(Some(group))); + } +}