Struct pamsm::Pam

source ·
pub struct Pam(/* private fields */);
Expand description

Opaque PAM handle, with additional native methods available via PamLibExt.

Implementations§

source§

impl Pam

source

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>

source§

fn from(value: &'a mut Pam) -> Self

Converts to this type from the input type.
source§

impl<'a> From<PamSendRef<'a>> for &'a Pam

source§

fn from(value: PamSendRef<'a>) -> Self

Converts to this type from the input type.
source§

impl<'a> From<PamSendRef<'a>> for &'a mut Pam

source§

fn from(value: PamSendRef<'a>) -> Self

Converts to this type from the input type.
source§

impl PamLibExt for Pam

source§

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>>

Get the username, i.e. the PAM_USER item. If it’s not set return None.
source§

fn get_cached_authtok(&self) -> PamResult<Option<&CStr>>

Get the cached authentication token.
source§

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>>

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
source§

fn set_authtok(&self, authtok: &CString) -> PamResult<()>

source§

fn get_rhost(&self) -> PamResult<Option<&CStr>>

Get the remote hostname.
source§

fn get_ruser(&self) -> PamResult<Option<&CStr>>

Get the remote username.
source§

fn get_service(&self) -> PamResult<Option<&CStr>>

Get the service name.
source§

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>>

Get a variable from the pam environment list.
source§

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 more
source§

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 more
source§

unsafe fn retrieve_data<T: PamData + Clone + Send>( &self, module_name: &str ) -> PamResult<T>

Retrieve data previously stored with send_data<T>. Read more
source§

fn send_bytes( &self, module_name: &str, data: Vec<u8>, cb: Option<PamCleanupCb> ) -> PamResult<()>

Similar to send_data, but only works with Vec<u8>. The PamData trait doesn’t have to be implemented on the data, a callback can be passed as an argument instead.
source§

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 RefUnwindSafe for Pam

§

impl !Send for Pam

§

impl !Sync for Pam

§

impl Unpin for Pam

§

impl UnwindSafe for Pam

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.