diff --git a/Cargo.lock b/Cargo.lock index 8f4a3a3..1ed6829 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -57,9 +57,9 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.4" +version = "1.0.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7079075b41f533b8c61d2a4d073c4676e1f8b249ff94a393b0595db304e0dd87" +checksum = "2faccea4cc4ab4a667ce676a30e8ec13922a692c99bb8f5b11f1502c72e04220" [[package]] name = "anstyle-parse" @@ -276,7 +276,7 @@ checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" [[package]] name = "cli" -version = "0.9.7" +version = "0.9.8" dependencies = [ "clap", "colored", @@ -553,7 +553,7 @@ checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" [[package]] name = "lib" -version = "0.9.7" +version = "0.9.8" dependencies = [ "chrono", "libc", @@ -695,7 +695,7 @@ checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" [[package]] name = "pam-authramp" -version = "0.9.7" +version = "0.9.8" dependencies = [ "pam-client", "tempdir", @@ -1277,7 +1277,7 @@ checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" [[package]] name = "util" -version = "0.9.7" +version = "0.9.8" dependencies = [ "chrono", "log", @@ -1583,7 +1583,7 @@ checksum = "7e2c411759b501fb9501aac2b1b2d287a6e93e5bdcf13c25306b23e1b716dd0e" [[package]] name = "xtask-test-integration" -version = "0.9.7" +version = "0.9.8" dependencies = [ "anyhow", "cli-xtask", diff --git a/Cargo.toml b/Cargo.toml index ad249ce..97a9749 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ members = [ "crates/lib", "crates/cli", "crates/util", "crates/xtask-test-integr [workspace.package] edition = "2021" -version = "0.9.7" +version = "0.9.8" description = "The AuthRamp PAM module provides an account lockout mechanism based on the number of authentication failures." authors = ["34n0 <34n0@immerda.ch>"] license = "GPL-3.0" diff --git a/crates/lib/src/lib.rs b/crates/lib/src/lib.rs index 9df3425..7b07b67 100644 --- a/crates/lib/src/lib.rs +++ b/crates/lib/src/lib.rs @@ -238,34 +238,34 @@ fn bounce_auth(pamh: &mut PamHandle, settings: &Settings, tally: &Tally) -> PamR ); // disable loop for now (#48, #50) - // while Utc::now() < unlock_instant { - // Calculate remaining time until unlock - let remaining_time = unlock_instant - Utc::now(); + if Utc::now() < unlock_instant { + // Calculate remaining time until unlock + let remaining_time = unlock_instant - Utc::now(); - // Cap remaining time at 24 hours - let capped_remaining_time = min(remaining_time, Duration::hours(24)); + // Cap remaining time at 24 hours + let capped_remaining_time = min(remaining_time, Duration::hours(24)); - // Send a message to the conversation function - let conv_res = conv.send( - PAM_TEXT_INFO, - &format!( - "Account locked! Unlocking in {}.", - format_remaining_time(capped_remaining_time) - ), - ); + // Send a message to the conversation function + let conv_res = conv.send( + PAM_TEXT_INFO, + &format!( + "Account locked! Unlocking in {}.", + format_remaining_time(capped_remaining_time) + ), + ); - // Log Conversation Error but continue loop - match conv_res { - Ok(_) => (), - Err(pam_code) => { - log_error!("{:?}: Error starting PAM conversation.", pam_code); + // Log Conversation Error but continue loop + match conv_res { + Ok(_) => (), + Err(pam_code) => { + log_error!("{:?}: Error starting PAM conversation.", pam_code); + } } - } - // Wait for one second - sleep(std::time::Duration::from_secs(1)); - // } - return PamResultCode::PAM_AUTH_ERR + // Wait for one second + sleep(std::time::Duration::from_secs(1)); + } + return PamResultCode::PAM_AUTH_ERR; } } PamResultCode::PAM_SUCCESS