PamHandle

Struct PamHandle 

Source
#[repr(C)]
pub struct PamHandle { /* private fields */ }
Expand description

Opaque type, used as a pointer when making pam API calls.

A module is invoked via an external function such as pam_sm_authenticate. Such a call provides a pam handle pointer. The same pointer should be given as an argument when making API calls.

Implementations§

Source§

impl PamHandle

Source

pub unsafe fn get_data<'a, T>(&'a self, key: &str) -> PamResult<&'a T>

Gets some value, identified by key, that has been set by the module previously.

See pam_get_data in http://www.linux-pam.org/Linux-PAM-html/mwg-expected-by-module-item.html

§Errors

Returns an error if the underlying PAM function call fails.

§Safety

The data stored under the provided key must be of type T otherwise the behaviour of this funtion is undefined.

Source

pub fn set_data<T>(&self, key: &str, data: Box<T>) -> PamResult<()>

Stores a value that can be retrieved later with get_data. The value lives as long as the current pam cycle.

See pam_set_data in http://www.linux-pam.org/Linux-PAM-html/mwg-expected-by-module-item.html

§Errors

Returns an error if the underlying PAM function call fails.

Source

pub fn get_item<T: Item>(&self) -> PamResult<Option<T>>

Retrieves a value that has been set, possibly by the pam client. This is particularly useful for getting a PamConv reference.

See pam_get_item in http://www.linux-pam.org/Linux-PAM-html/mwg-expected-by-module-item.html

§Errors

Returns an error if the underlying PAM function call fails.

Source

pub fn set_item_str<T: Item>(&mut self, item: T) -> PamResult<()>

Sets a value in the pam context. The value can be retrieved using get_item.

Note that all items are strings, except PAM_CONV and PAM_FAIL_DELAY.

See pam_set_item in http://www.linux-pam.org/Linux-PAM-html/mwg-expected-by-module-item.html

§Errors

Returns an error if the underlying PAM function call fails.

§Panics

Panics if the provided item key contains a nul byte

Source

pub fn get_user(&self, prompt: Option<&str>) -> PamResult<String>

Retrieves the name of the user who is authenticating or logging in.

This is really a specialization of get_item.

See pam_get_user in http://www.linux-pam.org/Linux-PAM-html/mwg-expected-by-module-item.html

§Errors

Returns an error if the underlying PAM function call fails.

§Panics

Panics if the provided prompt string contains a nul byte

Auto Trait Implementations§

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

Source§

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

Source§

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.