Struct pam_client::Session
source · [−]pub struct Session<'a, ConvT> where
ConvT: ConversationHandler, { /* private fields */ }
Expand description
An active PAM session or pseudo session
Implementations
sourceimpl<'a, ConvT> Session<'a, ConvT> where
ConvT: ConversationHandler,
impl<'a, ConvT> Session<'a, ConvT> where
ConvT: ConversationHandler,
sourcepub fn refresh_credentials(&mut self, flags: Flag) -> Result<()>
pub fn refresh_credentials(&mut self, flags: Flag) -> Result<()>
Extends the lifetime of existing credentials.
Might be called periodically for long running sessions to keep e.g. Kerberos tokens alive.
Relevant flags
are Flag::NONE
and Flag::SILENT
.
Errors
Expected error codes include:
ReturnCode::BUF_ERR
: Memory allocation errorReturnCode::CRED_ERR
: Setting credentials failedReturnCode::CRED_EXPIRED
: Credentials are expiredReturnCode::CRED_UNAVAIL
: Failed to retrieve credentialsReturnCode::SYSTEM_ERR
: Other system errorReturnCode::USER_UNKNOWN
: User not known
sourcepub fn reinitialize_credentials(&mut self, flags: Flag) -> Result<()>
pub fn reinitialize_credentials(&mut self, flags: Flag) -> Result<()>
Fully reinitializes the user’s credentials.
Relevant flags
are Flag::NONE
and Flag::SILENT
.
See Context::reinitialize_credentials()
for more information.
sourcepub fn leak(self) -> SessionToken
pub fn leak(self) -> SessionToken
Converts the session into a SessionToken
without closing it.
The returned token can be used to resume handling the
session with Context::unleak_session()
.
Please note, that if the session isn’t closed eventually and the established credentials aren’t deleted, security problems might occur.
Depending on the platform it may be possible to close the session from another context than the one that started the session. But as this behaviour cannot be safely relied upon, it is recommended to close the session within the same PAM context.
sourcepub fn getenv(&self, name: impl AsRef<OsStr>) -> Option<&str>
pub fn getenv(&self, name: impl AsRef<OsStr>) -> Option<&str>
Returns the value of a PAM environment variable.
See Context::getenv()
.
sourcepub fn putenv(&mut self, name_value: impl AsRef<OsStr>) -> Result<()>
pub fn putenv(&mut self, name_value: impl AsRef<OsStr>) -> Result<()>
Sets or unsets a PAM environment variable.
See Context::putenv()
.
sourcepub fn envlist(&self) -> EnvList
pub fn envlist(&self) -> EnvList
Returns a copy of the PAM environment in this context.
See Context::envlist()
.
sourcepub fn close(self, flags: Flag) -> ExtResult<(), Self>
pub fn close(self, flags: Flag) -> ExtResult<(), Self>
Manually closes the session
Closes the PAM session and deletes credentials established when opening the session. Session closing happens automatically when dropping the session, so this is not strictly required.
Please note that the application must usually have the same privileges to close as it had to open the session (e.g. have EUID 0).
Relevant flags
are Flag::NONE
and Flag::SILENT
Errors
Expected error codes include:
ReturnCode::ABORT
: Generic failureReturnCode::BUF_ERR
: Memory allocation errorReturnCode::SESSION_ERR
: Generic session failureReturnCode::CRED_ERR
: Deleting credentials failedReturnCode::SYSTEM_ERR
: Other system error
The ownership of self
is passed back in the error payload.
On drop the session will once again try to close itself.
Trait Implementations
Auto Trait Implementations
impl<'a, ConvT> !RefUnwindSafe for Session<'a, ConvT>
impl<'a, ConvT> Send for Session<'a, ConvT> where
ConvT: Send,
impl<'a, ConvT> !Sync for Session<'a, ConvT>
impl<'a, ConvT> Unpin for Session<'a, ConvT>
impl<'a, ConvT> !UnwindSafe for Session<'a, ConvT>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more