Skip to content

Commit

Permalink
fix persistent lockout
Browse files Browse the repository at this point in the history
  • Loading branch information
34N0 committed Jan 30, 2024
1 parent f6aba7f commit b8356f6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>"]
license = "GPL-3.0"
Expand Down
46 changes: 23 additions & 23 deletions crates/lib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b8356f6

Please sign in to comment.