comparison src/libpam/module.rs @ 172:6727cbe56f4a

Test environment variable setting; minor cleanup.
author Paul Fisher <paul@pfish.zone>
date Fri, 25 Jul 2025 21:02:53 -0400
parents e27c5c667a5a
children 46e8ce5cd5d1
comparison
equal deleted inserted replaced
171:e27c5c667a5a 172:6727cbe56f4a
46 #[macro_export] 46 #[macro_export]
47 macro_rules! pam_hooks { 47 macro_rules! pam_hooks {
48 ($ident:ident) => { 48 ($ident:ident) => {
49 mod _pam_hooks_scope { 49 mod _pam_hooks_scope {
50 use std::ffi::{c_char, c_int, c_void}; 50 use std::ffi::{c_char, c_int, c_void};
51 use $crate::constants::{RawFlags, ReturnCode};
51 use $crate::ModuleExporter; 52 use $crate::ModuleExporter;
52 use $crate::constants::{RawFlags, ReturnCode};
53 53
54 macro_rules! export { 54 macro_rules! export {
55 ($func:ident) => { 55 ($func:ident) => {
56 #[no_mangle] 56 #[no_mangle]
57 unsafe extern "C" fn $func( 57 unsafe extern "C" fn $func(
58 pamh: *mut c_void, 58 pamh: *mut c_void,
59 flags: RawFlags, 59 flags: RawFlags,
60 argc: c_int, 60 argc: c_int,
61 argv: *const *const c_char, 61 argv: *const *const c_char,
62 ) -> c_int { 62 ) -> c_int {
63 let ret: ReturnCode = ModuleExporter::$func::<super::$ident>( 63 let ret: ReturnCode =
64 pamh, flags, argc, argv 64 ModuleExporter::$func::<super::$ident>(pamh, flags, argc, argv).into();
65 ).into();
66 ret.into() 65 ret.into()
67 } 66 }
68 }; 67 };
69 } 68 }
70 69
168 /// 167 ///
169 /// # Safety 168 /// # Safety
170 /// 169 ///
171 /// It's up to you to pass a valid handle. 170 /// It's up to you to pass a valid handle.
172 unsafe fn wrap<'a>(handle: *mut c_void) -> Result<&'a mut LibPamHandle> { 171 unsafe fn wrap<'a>(handle: *mut c_void) -> Result<&'a mut LibPamHandle> {
173 handle.cast::<LibPamHandle>().as_mut().ok_or(ErrorCode::SystemError) 172 handle
173 .cast::<LibPamHandle>()
174 .as_mut()
175 .ok_or(ErrorCode::SystemError)
174 } 176 }
175 177
176 #[cfg(test)] 178 #[cfg(test)]
177 mod tests { 179 mod tests {
178 // Compile-time test that the `pam_hooks` macro compiles. 180 // Compile-time test that the `pam_hooks` macro compiles.