diff options
| author | Emīls Piņķis <emils@mullvad.net> | 2021-05-18 18:28:47 +0100 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2021-12-10 09:58:51 +0000 |
| commit | 2b48ee7a513651f65e2db5ff48eeb2fdb14d881a (patch) | |
| tree | 540c00042091c75de08685020d1f110182c7c920 /talpid-core/src | |
| parent | 05ae3cad58eea7319a566323e7fdc326f8035470 (diff) | |
| download | mullvadvpn-2b48ee7a513651f65e2db5ff48eeb2fdb14d881a.tar.xz mullvadvpn-2b48ee7a513651f65e2db5ff48eeb2fdb14d881a.zip | |
Add exclusion GID fetcher
Diffstat (limited to 'talpid-core/src')
| -rw-r--r-- | talpid-core/src/lib.rs | 4 | ||||
| -rw-r--r-- | talpid-core/src/macos.rs | 12 |
2 files changed, 16 insertions, 0 deletions
diff --git a/talpid-core/src/lib.rs b/talpid-core/src/lib.rs index 8d540fcdbd..648a45bda4 100644 --- a/talpid-core/src/lib.rs +++ b/talpid-core/src/lib.rs @@ -63,5 +63,9 @@ mod mktemp; #[cfg(target_os = "linux")] mod linux; +/// Misc utilities for the macOS platform. +#[cfg(target_os = "macos")] +pub mod macos; + /// A pair of functions to monitor and establish connectivity with ICMP pub mod ping_monitor; diff --git a/talpid-core/src/macos.rs b/talpid-core/src/macos.rs new file mode 100644 index 0000000000..7e6922b796 --- /dev/null +++ b/talpid-core/src/macos.rs @@ -0,0 +1,12 @@ +/// name of the group that should be excluded +const EXCLUSION_GROUP: &[u8] = b"mullvad-exclusion\0"; + +/// Returns the GID of `mullvad-exclusion` group if it exists. +pub fn get_exclusion_gid() -> Option<u32> { + let group = unsafe { libc::getgrnam(EXCLUSION_GROUP.as_ptr() as *const _) }; + if group.is_null() { + return None; + } + let gid = unsafe { (*group).gr_gid }; + Some(gid) +} |
