-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support xpc_connection_set_peer_sig on macOS 12
Also support validating client code requirements using the audit token using the same APIs.
- Loading branch information
1 parent
3ba4b76
commit 3e220ac
Showing
6 changed files
with
176 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#![allow( | ||
dead_code, | ||
safe_packed_borrows, | ||
unaligned_references, | ||
Check failure on line 3 in xpc-connection-sys/src/lib.rs GitHub Actions / Lints
|
||
non_upper_case_globals, | ||
non_camel_case_types, | ||
non_snake_case, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// This is copied from mio which is MIT licensed, it's to work around the | ||
// linkage feature not yet being stable. | ||
// | ||
// https://github.com/carllerche/mio/blob/master/src/sys/unix/dlsym.rs | ||
|
||
use std::marker; | ||
use std::mem; | ||
use std::sync::atomic::{AtomicUsize, Ordering}; | ||
|
||
macro_rules! dlsym { | ||
(fn $name:ident($($t:ty),*) -> $ret:ty) => ( | ||
#[allow(bad_style)] | ||
static $name: crate::dlsym::DlSym<unsafe extern fn($($t),*) -> $ret> = | ||
crate::dlsym::DlSym { | ||
name: concat!(stringify!($name), "\0"), | ||
addr: AtomicUsize::new(0), | ||
_marker: ::std::marker::PhantomData, | ||
}; | ||
) | ||
} | ||
|
||
pub struct DlSym<F> { | ||
pub name: &'static str, | ||
pub addr: AtomicUsize, | ||
pub _marker: marker::PhantomData<F>, | ||
} | ||
|
||
impl<F> DlSym<F> { | ||
pub fn get(&self) -> Option<&F> { | ||
assert_eq!(mem::size_of::<F>(), mem::size_of::<usize>()); | ||
unsafe { | ||
if self.addr.load(Ordering::SeqCst) == 0 { | ||
self.addr.store(fetch(self.name), Ordering::SeqCst); | ||
} | ||
if self.addr.load(Ordering::SeqCst) == 1 { | ||
None | ||
} else { | ||
mem::transmute::<&AtomicUsize, Option<&F>>(&self.addr) | ||
} | ||
} | ||
} | ||
} | ||
|
||
unsafe fn fetch(name: &str) -> usize { | ||
assert_eq!(name.as_bytes()[name.len() - 1], 0); | ||
match libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr() as *const _) as usize { | ||
0 => 1, | ||
n => n, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters