Mercurial > crates > nonstick
diff src/libpam/module.rs @ 141:a508a69c068a
Remove a lot of Results from functions.
Many functions are documented to only return failing Results when given
improper inputs or when there is a memory allocation failure (which
can be verified by looking at the source). In cases where we know our
input is correct, we don't need to check for memory allocation errors
for the same reason that Rust doesn't do so when you, e.g., create a
new Vec.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Sat, 05 Jul 2025 17:16:56 -0400 |
parents | a2676475e86b |
children | ebb71a412b58 |
line wrap: on
line diff
--- a/src/libpam/module.rs Sat Jul 05 17:11:33 2025 -0400 +++ b/src/libpam/module.rs Sat Jul 05 17:16:56 2025 -0400 @@ -42,7 +42,7 @@ ($ident:ident) => { mod _pam_hooks_scope { use std::ffi::{c_char, c_int, c_void, CStr}; - use $crate::{ErrorCode, Flags, LibPamHandle, PamModule}; + use $crate::{ErrorCode, Flags, PamModule, RawPamHandle}; #[no_mangle] extern "C" fn pam_sm_acct_mgmt( @@ -51,7 +51,7 @@ argc: c_int, argv: *const *const c_char, ) -> c_int { - if let Some(handle) = unsafe { pamh.cast::<LibPamHandle>().as_mut() } { + if let Some(handle) = unsafe { pamh.cast::<RawPamHandle>().as_mut() } { let args = extract_argv(argc, argv); ErrorCode::result_to_c(super::$ident::account_management(handle, args, flags)) } else { @@ -66,7 +66,7 @@ argc: c_int, argv: *const *const c_char, ) -> c_int { - if let Some(handle) = unsafe { pamh.cast::<LibPamHandle>().as_mut() } { + if let Some(handle) = unsafe { pamh.cast::<RawPamHandle>().as_mut() } { let args = extract_argv(argc, argv); ErrorCode::result_to_c(super::$ident::authenticate(handle, args, flags)) } else { @@ -81,7 +81,7 @@ argc: c_int, argv: *const *const c_char, ) -> c_int { - if let Some(handle) = unsafe { pamh.cast::<LibPamHandle>().as_mut() } { + if let Some(handle) = unsafe { pamh.cast::<RawPamHandle>().as_mut() } { let args = extract_argv(argc, argv); ErrorCode::result_to_c(super::$ident::change_authtok(handle, args, flags)) } else { @@ -96,7 +96,7 @@ argc: c_int, argv: *const *const c_char, ) -> c_int { - if let Some(handle) = unsafe { pamh.cast::<LibPamHandle>().as_mut() } { + if let Some(handle) = unsafe { pamh.cast::<RawPamHandle>().as_mut() } { let args = extract_argv(argc, argv); ErrorCode::result_to_c(super::$ident::close_session(handle, args, flags)) } else { @@ -112,7 +112,7 @@ argv: *const *const c_char, ) -> c_int { let args = extract_argv(argc, argv); - if let Some(handle) = unsafe { pamh.cast::<LibPamHandle>().as_mut() } { + if let Some(handle) = unsafe { pamh.cast::<RawPamHandle>().as_mut() } { ErrorCode::result_to_c(super::$ident::open_session(handle, args, flags)) } else { ErrorCode::Ignore as c_int @@ -127,7 +127,7 @@ argv: *const *const c_char, ) -> c_int { let args = extract_argv(argc, argv); - if let Some(handle) = unsafe { pamh.cast::<LibPamHandle>().as_mut() } { + if let Some(handle) = unsafe { pamh.cast::<RawPamHandle>().as_mut() } { ErrorCode::result_to_c(super::$ident::set_credentials(handle, args, flags)) } else { ErrorCode::Ignore as c_int