Mercurial > crates > nonstick
diff libpam-sys/src/ffi.rs @ 134:6c1e1bdb4164
Use standard #[cfg] directives rather than custom proc macros.
Instead of having to do a bunch of custom parsing and other logic
that tools often choke on, this change introduces an easy way
to depend upon custom #[cfg]s provided by the libpam-sys crate.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Thu, 03 Jul 2025 11:03:36 -0400 |
parents | 32b2a545ca3e |
children |
line wrap: on
line diff
--- a/libpam-sys/src/ffi.rs Wed Jul 02 03:33:09 2025 -0400 +++ b/libpam-sys/src/ffi.rs Thu Jul 03 11:03:36 2025 -0400 @@ -115,7 +115,7 @@ } /// Definition of the PAM_XAUTHDATA item. Compatible with `xcb_auth_info_t`. -#[cfg(_hack_impl = "LinuxPam")] +#[cfg(pam_impl = "LinuxPam")] #[repr(C)] pub struct pam_xauth_data { namelen: c_int, @@ -124,7 +124,7 @@ data: *mut c_char, } -#[cfg(_hack_impl = "LinuxPam")] +#[cfg(pam_impl = "LinuxPam")] #[derive(Copy, Clone, Debug, PartialEq, Eq, TryFromPrimitive, IntoPrimitive)] #[repr(i32)] pub enum pam_modutil_redirect_fd { @@ -133,10 +133,10 @@ PAM_MODUTIL_NULL_FD, } -#[cfg(_hack_impl = "LinuxPam")] +#[cfg(pam_impl = "LinuxPam")] pub use pam_modutil_redirect_fd::*; -#[cfg(_hack_impl = "LinuxPam")] +#[cfg(pam_impl = "LinuxPam")] #[derive(Debug)] #[repr(C)] pub struct pam_modutil_privs { @@ -148,7 +148,7 @@ is_dropped: c_int, } -#[cfg(_hack_impl = "OpenPam")] +#[cfg(pam_impl = "OpenPam")] pub type pam_func_t = unsafe extern "C" fn( handle: *mut pam_handle, flags: c_int, @@ -156,7 +156,7 @@ argv: *const *const c_char, ) -> c_int; -#[cfg(_hack_impl = "OpenPam")] +#[cfg(pam_impl = "OpenPam")] #[derive(Debug)] #[repr(C)] pub struct pam_module { @@ -165,7 +165,7 @@ dlh: *mut c_void, } -#[cfg(_hack_impl = "OpenPam")] +#[cfg(pam_impl = "OpenPam")] #[derive(Debug)] #[repr(C)] pub struct pam_repository { @@ -175,6 +175,7 @@ } // These are the functions specified in X/SSO. Everybody exports them. +#[link(name = "pam")] extern "C" { /// Account validation. pub fn pam_acct_mgmt(pamh: *mut pam_handle, flags: c_int) -> c_int; @@ -272,11 +273,11 @@ pub fn pam_strerror(pamh: *const pam_handle, error_number: c_int) -> *mut c_char; } -// We use `_hack_impl` because ctest loses its mind +// We use `pam_impl` because ctest loses its mind // when it comes across the `cfg_pam_impl` macro. // This is a custom cfg variable set in our build.rs. Don't do this; just use // cfg_pam_impl. -#[cfg(any(_hack_impl = "LinuxPam", _hack_impl = "OpenPam"))] +#[cfg(any(pam_impl = "LinuxPam", pam_impl = "OpenPam"))] extern "C" { /// Gets `PAM_AUTHTOK`, or asks the user if that is unset. pub fn pam_get_authtok( @@ -296,7 +297,7 @@ } -#[cfg(_hack_impl = "LinuxPam")] +#[cfg(pam_impl = "LinuxPam")] extern "C" { pub fn pam_fail_delay(pamh: *mut pam_handle, musec_delay: c_uint) -> c_int; @@ -401,7 +402,7 @@ ) -> *mut c_char; } -#[cfg(_hack_impl = "OpenPam")] +#[cfg(pam_impl = "OpenPam")] extern "C" { pub fn openpam_borrow_cred(pamh: *mut pam_handle, passwd: *const libc::passwd) -> c_int;