From 426c43963a1d3801d5e5ca0766255a83a8bfc533 Mon Sep 17 00:00:00 2001 From: David Mulder Date: Wed, 31 Jul 2024 14:27:05 -0600 Subject: [PATCH] Add nss getgrgid to the himmelblau daemon Signed-off-by: David Mulder Reviewed-by: Alexander Bokovoy --- himmelblaud/src/himmelblaud.rs | 2 + .../src/himmelblaud/himmelblaud_getgrgid.rs | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 himmelblaud/src/himmelblaud/himmelblaud_getgrgid.rs diff --git a/himmelblaud/src/himmelblaud.rs b/himmelblaud/src/himmelblaud.rs index 9f6167bb7d0..6af19e2b901 100644 --- a/himmelblaud/src/himmelblaud.rs +++ b/himmelblaud/src/himmelblaud.rs @@ -219,6 +219,7 @@ pub(crate) async fn handle_client( Request::NssGroupByName(grp_id) => { resolver.getgrnam(&grp_id).await? } + Request::NssGroupByGid(gid) => resolver.getgrgid(gid).await?, _ => todo!(), }; reqs.send(resp).await?; @@ -231,6 +232,7 @@ pub(crate) async fn handle_client( } mod himmelblaud_getgrent; +mod himmelblaud_getgrgid; mod himmelblaud_getgrnam; mod himmelblaud_getpwent; mod himmelblaud_getpwnam; diff --git a/himmelblaud/src/himmelblaud/himmelblaud_getgrgid.rs b/himmelblaud/src/himmelblaud/himmelblaud_getgrgid.rs new file mode 100644 index 00000000000..9ddf4082931 --- /dev/null +++ b/himmelblaud/src/himmelblaud/himmelblaud_getgrgid.rs @@ -0,0 +1,43 @@ +/* + Unix SMB/CIFS implementation. + + Himmelblau daemon implementation for nss getgrgid + + 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 libc::gid_t; +use ntstatus_gen::NTSTATUS; +use sock::{Group, Response}; + +impl Resolver { + pub(crate) async fn getgrgid( + &mut self, + gid: gid_t, + ) -> Result> { + if let Some(uuid) = self.uid_cache.fetch(gid) { + if let Some(entry) = self.group_cache.fetch(&uuid) { + return Ok(Response::NssGroup(Some(Group { + name: entry.uuid.clone(), + passwd: "x".to_string(), + gid, + members: entry.members(), + }))); + } + } + Ok(Response::NssGroup(None)) + } +} -- 2.47.3