]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
Add nss getgrent to the himmelblau daemon
authorDavid Mulder <dmulder@samba.org>
Wed, 31 Jul 2024 17:39:38 +0000 (11:39 -0600)
committerDavid Mulder <dmulder@samba.org>
Wed, 23 Oct 2024 14:21:33 +0000 (14:21 +0000)
Signed-off-by: David Mulder <dmulder@samba.org>
Reviewed-by: Alexander Bokovoy <ab@samba.org>
himmelblaud/src/himmelblaud.rs
himmelblaud/src/himmelblaud/himmelblaud_getgrent.rs [new file with mode: 0644]

index 8904f27db7b7040f1480ba843753bd941c5999f6..a4a0af3ca26805c5006b7c14840c7085186150e6 100644 (file)
@@ -215,6 +215,7 @@ pub(crate) async fn handle_client(
                 resolver.getpwnam(&account_id).await?
             }
             Request::NssAccountByUid(uid) => resolver.getpwuid(uid).await?,
+            Request::NssGroups => resolver.getgrent().await?,
             _ => todo!(),
         };
         reqs.send(resp).await?;
@@ -226,6 +227,7 @@ pub(crate) async fn handle_client(
     Ok(())
 }
 
+mod himmelblaud_getgrent;
 mod himmelblaud_getpwent;
 mod himmelblaud_getpwnam;
 mod himmelblaud_getpwuid;
diff --git a/himmelblaud/src/himmelblaud/himmelblaud_getgrent.rs b/himmelblaud/src/himmelblaud/himmelblaud_getgrent.rs
new file mode 100644 (file)
index 0000000..9f0c615
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+   Unix SMB/CIFS implementation.
+
+   Himmelblau daemon implementation for nss getgrent
+
+   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 <http://www.gnu.org/licenses/>.
+*/
+use crate::himmelblaud::Resolver;
+use dbg::DBG_ERR;
+use ntstatus_gen::*;
+use sock::{Group, Response};
+
+impl Resolver {
+    pub(crate) async fn getgrent(&mut self) -> Result<Response, Box<NTSTATUS>> {
+        let group_entries = self.group_cache.fetch_all()?;
+        let mut res = Vec::new();
+        for entry in group_entries {
+            let name = entry.uuid.clone();
+            let gid = self
+                .idmap
+                .gen_to_unix(&self.tenant_id, &entry.uuid.to_uppercase())
+                .map_err(|e| {
+                    DBG_ERR!("{:?}", e);
+                    Box::new(NT_STATUS_NO_SUCH_GROUP)
+                })?;
+            let group = Group {
+                name,
+                passwd: "x".to_string(),
+                gid,
+                members: entry.members(),
+            };
+            res.push(group);
+        }
+        Ok(Response::NssGroups(res))
+    }
+}