pub struct Pam(/* private fields */);Expand description
Opaque PAM handle, with additional native methods available via PamLibExt.
Implementations§
Source§impl Pam
impl Pam
Sourcepub fn as_send_ref(&mut self) -> PamSendRef<'_>
pub fn as_send_ref(&mut self) -> PamSendRef<'_>
This allows sending the Pam handle to another thread.
std::thread::scope(|s| {
let borrowed = pamh.as_send_ref();
s.spawn(move || {
let pamh: &Pam = borrowed.into();
});
});Synchronized across multiple threads:
std::thread::scope(|s| {
let shared_1 = std::sync::Arc::new(std::sync::Mutex::new(pamh.as_send_ref()));
let shared_2 = shared_1.clone();
s.spawn(move || {
let pamh: &Pam = &*shared_1.lock().unwrap();
});
s.spawn(move || {
let pamh: &Pam = &*shared_2.lock().unwrap();
});
});Trait Implementations§
Source§impl<'a> From<&'a mut Pam> for PamSendRef<'a>
impl<'a> From<&'a mut Pam> for PamSendRef<'a>
Source§impl<'a> From<PamSendRef<'a>> for &'a Pam
impl<'a> From<PamSendRef<'a>> for &'a Pam
Source§fn from(value: PamSendRef<'a>) -> Self
fn from(value: PamSendRef<'a>) -> Self
Converts to this type from the input type.
Source§impl<'a> From<PamSendRef<'a>> for &'a mut Pam
impl<'a> From<PamSendRef<'a>> for &'a mut Pam
Source§fn from(value: PamSendRef<'a>) -> Self
fn from(value: PamSendRef<'a>) -> Self
Converts to this type from the input type.
Source§impl PamLibExt for Pam
impl PamLibExt for Pam
Source§fn get_user(&self, prompt: Option<&str>) -> PamResult<Option<&CStr>>
fn get_user(&self, prompt: Option<&str>) -> PamResult<Option<&CStr>>
Get the username. If the PAM_USER item is not set, this function
prompts for a username (like get_authtok).
Returns PamError::SERVICE_ERR if the prompt contains any null byte
Source§fn get_cached_user(&self) -> PamResult<Option<&CStr>>
fn get_cached_user(&self) -> PamResult<Option<&CStr>>
Get the username, i.e. the PAM_USER item. If it’s not set return None.
Source§fn get_cached_oldauthtok(&self) -> PamResult<Option<&CStr>>
fn get_cached_oldauthtok(&self) -> PamResult<Option<&CStr>>
Get the cached old authentication token.
Source§fn get_authtok(&self, prompt: Option<&str>) -> PamResult<Option<&CStr>>
fn get_authtok(&self, prompt: Option<&str>) -> PamResult<Option<&CStr>>
Get the cached authentication token or prompt the user for one if there isn’t any.
Returns PamError::SERVICE_ERR if the prompt contains any null byte
fn set_authtok(&self, authtok: &CString) -> PamResult<()>
Source§fn conv(
&self,
prompt: Option<&str>,
style: PamMsgStyle,
) -> PamResult<Option<&CStr>>
fn conv( &self, prompt: Option<&str>, style: PamMsgStyle, ) -> PamResult<Option<&CStr>>
Prompt the user for custom input.
Returns PamError::SERVICE_ERR if the prompt contains any null byte
Source§fn getenv(&self, name: &str) -> PamResult<Option<&CStr>>
fn getenv(&self, name: &str) -> PamResult<Option<&CStr>>
Get a variable from the pam environment list.
Source§fn putenv(&self, name_value: &str) -> PamResult<()>
fn putenv(&self, name_value: &str) -> PamResult<()>
Put a variable in the pam environment list.
name_value takes for form documented in pam_putent(3) : Read moreSource§unsafe fn send_data<T: PamData + Clone + Send>(
&self,
module_name: &str,
data: T,
) -> PamResult<()>
unsafe fn send_data<T: PamData + Clone + Send>( &self, module_name: &str, data: T, ) -> PamResult<()>
Send data to be stored by the pam library under the name
module_name.
The data can then be retrieved from a different
callback in this module, or even by a different module
using retrieve_data<T>. Read moreSource§unsafe fn retrieve_data<T: PamData + Clone + Send>(
&self,
module_name: &str,
) -> PamResult<T>
unsafe fn retrieve_data<T: PamData + Clone + Send>( &self, module_name: &str, ) -> PamResult<T>
Retrieve data previously stored with
send_data<T>. Read moreSource§fn send_bytes(
&self,
module_name: &str,
data: Vec<u8>,
cb: Option<PamCleanupCb>,
) -> PamResult<()>
fn send_bytes( &self, module_name: &str, data: Vec<u8>, cb: Option<PamCleanupCb>, ) -> PamResult<()>
Source§fn retrieve_bytes(&self, module_name: &str) -> PamResult<Vec<u8>>
fn retrieve_bytes(&self, module_name: &str) -> PamResult<Vec<u8>>
Retrieve bytes previously stored with
send_bytes.
The result is a clone of the data.Auto Trait Implementations§
impl Freeze for Pam
impl RefUnwindSafe for Pam
impl !Send for Pam
impl !Sync for Pam
impl Unpin for Pam
impl UnwindSafe for Pam
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more