Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix persistent lockout #58

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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