pub struct Pam { /* private fields */ }Expand description
Authentication through a PAM service, from cx.pam(service), as a lock
screen does. A clone is cheap and shares it.
libpam blocks, so each attempt runs on a thread of its own, and the
loop hears from it only while it runs: an idle Pam wakes nothing. When
the context that made it goes, an attempt still running is refused its
answer, so its thread ends.
Implementations§
Source§impl Pam
impl Pam
Sourcepub fn start(&self, user: Option<&str>)
pub fn start(&self, user: Option<&str>)
Starts authenticating user, or with None the user the shell runs
as, found by its uid. An attempt already running is aborted first.
PAM can’t be stopped while a module blocks without asking, as a
fingerprint reader waits for a finger, so an aborted attempt’s
thread stays inside PAM until the module returns. A start meanwhile
shows Busy and begins once it has, so two
transactions never run side by side.
Ending an attempt while PAM waits for an answer, by aborting it,
starting another or dropping its context, counts as a failed login
where pam_faillock counts failures, and enough of them lock the
account. So take the password first, start on Enter, and answer as
soon as PAM asks.
Sourcepub fn respond(&self, text: impl Into<String>)
pub fn respond(&self, text: impl Into<String>)
Answers the question asked, and the state turns
Busy. The answer is never logged, and its bytes
are zeroed once handed on, but the copy made for libpam is freed
unzeroed. With no question waiting, it is dropped, and that is
logged.
Sourcepub fn abort(&self)
pub fn abort(&self)
Stops the attempt running: the state turns Idle
at once, its question is refused and its result is never shown.
Its thread ends at PAM’s next question, or once a module that
blocks without asking returns. A start waiting for that is dropped.
With nothing running, nothing changes. A refused question counts as
a failed login, as start says.
Sourcepub fn state(&self) -> ReadSignal<PamState>
pub fn state(&self) -> ReadSignal<PamState>
Where the attempt is.
Sourcepub fn messages(&self) -> ReadSignal<Vec<PamMessage>>
pub fn messages(&self) -> ReadSignal<Vec<PamMessage>>
The info and error lines PAM sent during the attempt, oldest first. Each start empties it.