nss_kanidm/
lib.rs

1#![deny(warnings)]
2#![warn(unused_extern_crates)]
3#![deny(clippy::todo)]
4#![deny(clippy::unimplemented)]
5#![deny(clippy::unwrap_used)]
6#![deny(clippy::expect_used)]
7#![deny(clippy::panic)]
8#![deny(clippy::unreachable)]
9#![deny(clippy::await_holding_lock)]
10#![deny(clippy::needless_pass_by_value)]
11#![deny(clippy::trivially_copy_pass_by_ref)]
12
13#[cfg(target_os = "freebsd")]
14/// BSD nss is quite different to that of linux (rather, glibc). As a result of this
15/// FreeBSD kindly offers us wrappers to allow compatability of the two. But to
16/// do this we need a .c file to include the macros and export tables, as well as
17/// handling the variadic args (which rust doesn't).
18///
19/// The issue is that even though we link our static archive, rust won't export any
20/// of the symbols from it *unless* a rust source file actually consumes at least
21/// one of them. This means we can't just link to our .a and have it do the work,
22/// we need to wrap and expose this shim function to convince rust to actually
23/// link to the archive
24///
25/// https://github.com/rust-lang/rust/issues/78827
26mod bsd_nss_compat {
27    use std::ffi::c_void;
28
29    extern "C" {
30        pub fn _nss_module_register(a: *mut c_void, b: *mut c_void, c: *mut c_void);
31    }
32
33    #[no_mangle]
34    pub extern "C" fn nss_module_register(a: *mut c_void, b: *mut c_void, c: *mut c_void) {
35        unsafe { _nss_module_register(a, b, c) }
36    }
37}
38
39#[cfg(target_family = "unix")]
40#[macro_use]
41extern crate libnss;
42
43#[cfg(target_family = "unix")]
44mod hooks;
45
46#[cfg(target_family = "unix")]
47pub(crate) mod core;
48
49#[cfg(test)]
50mod tests;