diff options
author | Katharina Fey <kookie@spacekookie.de> | 2018-07-02 21:53:59 +0200 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2018-07-02 21:53:59 +0200 |
commit | f903e653d59fa923210f5a583f7f8adc663a5dd5 (patch) | |
tree | 1af992782b624170e5b7c47f107675721bda5b17 /lockchain-core/src/users/auth.rs | |
parent | f2156e21b830ebc3cfd0f9eab4e7e01112e023b4 (diff) |
This doesn't work
Diffstat (limited to 'lockchain-core/src/users/auth.rs')
-rw-r--r-- | lockchain-core/src/users/auth.rs | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/lockchain-core/src/users/auth.rs b/lockchain-core/src/users/auth.rs index 538bd04..ad25757 100644 --- a/lockchain-core/src/users/auth.rs +++ b/lockchain-core/src/users/auth.rs @@ -6,7 +6,7 @@ // use nix::sys::wait::*; // use nix::unistd::{fork, ForkResult}; -// use pam_auth::{self, Authenticator, PamError, Result as PamResult}; +use pam_auth::{self, Authenticator, PamError, Result as PamResult}; #[derive(Debug)] pub enum AuthError { @@ -30,7 +30,7 @@ pub enum AuthError { /// yet due to issues in the `pam-auth` dependency. #[allow(unused_variables)] pub fn pam_authenticate(username: &str, password: &str) -> Result<(), AuthError> { - Err(AuthError::FailedPAM) + // Err(AuthError::FailedPAM) // match fork().map_err(|_| AuthError::FailedFork)? { @@ -41,33 +41,35 @@ pub fn pam_authenticate(username: &str, password: &str) -> Result<(), AuthError> // ForkResult::Child => { // let mut auth = Authenticator::new("lockchain").ok_or(AuthError::FailedPAM)?; - // use std::error::Error; - // let service = "login"; + use std::error::Error; + let service = "lockchain-core"; - // println!("Username: {}", username); - // println!("Password: {}", password); - // println!("Service: {}", service); + println!("Username: {}", username); + println!("Password: {}", password); + println!("Service: {}", service); - // let mut auth = Authenticator::new(service).unwrap(); - // auth.set_credentials(username, password); + let mut auth = Authenticator::new(service).unwrap(); + auth.set_credentials(username, password); - // match auth.authenticate() { - // Ok(()) => println!("authenticate() OK!"), - // Err(e) => { - // println!("authenticate() FAILED!"); - // println!("{}", e.description()); - // println!("{:#?}", e.cause()); - // } - // } + match auth.authenticate() { + Ok(()) => println!("authenticate() OK!"), + Err(e) => { + println!("authenticate() FAILED!"); + println!("{}", e.description()); + println!("{:#?}", e.cause()); + } + } - // match auth.open_session() { - // Ok(()) => println!("open_session() OK!"), - // Err(e) => { - // println!("open_session() FAILED!"); - // println!("{}", e.description()); - // println!("{:#?}", e.cause()); - // } - // } + match auth.open_session() { + Ok(()) => println!("open_session() OK!"), + Err(e) => { + println!("open_session() FAILED!"); + println!("{}", e.description()); + println!("{:#?}", e.cause()); + } + } + + Ok(()) // auth.set_credentials(username, password); // auth.authenticate().map_err(|_| AuthError::InvalidUser)?; |