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
impl PamHandle
Sourcepub unsafe fn get_data<'a, T>(&'a self, key: &str) -> PamResult<&'a T>
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
PamResultCodeif the lookup itself fails.PamResultCode::PAM_BUF_ERRif the key string bytes contain an internal 0 byte.PamResultCode::PAM_SYSTEM_ERRif PAM reports success but yields a null pointer.
§Safety
The data stored under the provided key must be of type T otherwise the
behaviour of this function is undefined.
Sourcepub fn set_data<T: 'static>(&mut self, key: &str, data: Box<T>) -> PamResult<()>
pub fn set_data<T: 'static>(&mut 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
PamResultCodeif the store itself fails.PamResultCode::PAM_BUF_ERRif the key string contains a 0 byte.
Sourcepub fn get_item<'a, T: Item<'a>>(&'a self) -> PamResult<Option<T>>
pub fn get_item<'a, T: Item<'a>>(&'a 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.
Sourcepub fn set_item_str<'a, T: Item<'a>>(&mut self, item: T) -> PamResult<()>
pub fn set_item_str<'a, T: Item<'a>>(&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.
Sourcepub fn get_user(&mut self, prompt: Option<&str>) -> PamResult<String>
pub fn get_user(&mut 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.
This may prompt via the conversation and set the PAM_USER item.
It therefore takes &mut self, unlike the read-only item accessors.
See pam_get_user in
http://www.linux-pam.org/Linux-PAM-html/mwg-expected-by-module-item.html
§Errors
PamResultCodeif the lookup itself fails.PamResultCode::PAM_BUF_ERRif the prompt string contains a 0 byte.PamResultCode::PAM_SYSTEM_ERRif PAM reports success but yields a null pointer.PamResultCode::PAM_SYSTEM_ERRif the returned username is not valid UTF-8.