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")?;