Add WIP locker
This commit is contained in:
parent
3bc299859f
commit
7b8777457b
6 changed files with 1059 additions and 523 deletions
23
examples/pam.rs
Normal file
23
examples/pam.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
fn main() {
|
||||
use pam_client::conv_cli::Conversation;
|
||||
use pam_client::{Context, Flag}; // CLI implementation
|
||||
|
||||
let passwd = pwd::Passwd::current_user().expect("Failed to get current user");
|
||||
|
||||
let mut context = Context::new(
|
||||
"cosmic-lock", // Service name, decides which policy is used (see `/etc/pam.d`)
|
||||
Some(&passwd.name), // Optional preset user name
|
||||
Conversation::new(), // Handler for user interaction
|
||||
)
|
||||
.expect("Failed to initialize PAM context");
|
||||
|
||||
// Authenticate the user (ask for password, 2nd-factor token, fingerprint, etc.)
|
||||
context
|
||||
.authenticate(Flag::NONE)
|
||||
.expect("Authentication failed");
|
||||
|
||||
// Validate the account (is not locked, expired, etc.)
|
||||
context
|
||||
.acct_mgmt(Flag::NONE)
|
||||
.expect("Account validation failed");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue