From b450b573a759ee91bfb510c4a115b97f2c1dd3a2 Mon Sep 17 00:00:00 2001 From: James Morris Date: Tue, 22 Oct 2024 18:53:35 -0400 Subject: [PATCH] Correctly handle lookups of missing netgroups If the netgroup does not exist, setnetgrent returns 0. Do not bail, simply return 0 results --- src/handlers.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handlers.rs b/src/handlers.rs index 4e3b1bd..17187fd 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -342,9 +342,9 @@ impl NetgroupWithName { }; if unsafe { setnetgrent(netgroup_name.as_ptr() as *const c_char) } != 1 { - anyhow::bail!("Error: Could not open netgroup {}", self.name); + //setnetgrent returns 0 if the netgroup cannot be found + return Ok(results); } - let mut buffer = vec![0 as c_char; 4096]; let mut host: *mut c_char = std::ptr::null_mut(); let mut user: *mut c_char = std::ptr::null_mut();