From 34dfc562a93607177008e18cd03ec31501c45c5d Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Fri, 12 Jul 2024 20:53:03 +0200 Subject: [PATCH] Remove group support on macOS, fixes #10 --- src/core/common.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/common.rs b/src/core/common.rs index a8c9709..6cf6974 100644 --- a/src/core/common.rs +++ b/src/core/common.rs @@ -2,6 +2,8 @@ use anyhow::Context; use indoc::indoc; use itertools::Itertools; use nix::unistd::{getuid, Group, User}; + +#[cfg(not(target_os = "macos"))] use std::ffi::CString; pub fn get_current_unix_user() -> anyhow::Result { @@ -10,6 +12,13 @@ pub fn get_current_unix_user() -> anyhow::Result { .and_then(|u| u.ok_or(anyhow::anyhow!("Failed to look up your UNIX username"))) } +#[cfg(target_os = "macos")] +pub fn get_unix_groups(_user: &User) -> anyhow::Result> { + // Return an empty list on macOS since there is no `getgrouplist` function + Ok(vec![]) +} + +#[cfg(not(target_os = "macos"))] pub fn get_unix_groups(user: &User) -> anyhow::Result> { let user_cstr = CString::new(user.name.as_bytes()).context("Failed to convert username to CStr")?;