Mercurial > crates > nonstick
diff testharness/src/bin/testharness.rs @ 171:e27c5c667a5a
Create full new types for return code and flags, separate end to end.
This plumbs the ReturnCode and RawFlags types through the places where
we call into or are called from PAM.
Also adds Sun documentation to the project.
author | Paul Fisher <paul@pfish.zone> |
---|---|
date | Fri, 25 Jul 2025 20:52:14 -0400 |
parents | 0cabe7b94a4f |
children | 6727cbe56f4a |
line wrap: on
line diff
--- a/testharness/src/bin/testharness.rs Wed Jul 16 18:45:20 2025 -0400 +++ b/testharness/src/bin/testharness.rs Fri Jul 25 20:52:14 2025 -0400 @@ -22,7 +22,7 @@ wrong_username: bool, wrong_password: bool, changing_password: Cell<bool>, - change_prompt_count: Cell<u8>, + change_prompt_count: Cell<usize>, } impl Conversation for &TestHarness { @@ -42,19 +42,27 @@ } Exchange::MaskedPrompt(p) => { let answer = if self.changing_password.get() { - let prompts = self.change_prompt_count.get(); - eprintln!("CHANGING PASSWORD PROMPT {prompts}"); + let prompt_count = self.change_prompt_count.get(); + eprintln!("CHANGING PASSWORD PROMPT {prompt_count}"); eprintln!("-> {p:?}"); - self.change_prompt_count.set(prompts + 1); - match prompts { - 0 => "old token!", - 1 => "mistake", - 2 => "mismatch", - 3 => "old token!", - 4 => "acceptable", - 5 => "acceptable", - _ => panic!("unexpected number of prompts!"), - } + self.change_prompt_count.set(prompt_count + 1); + // When changing passwords after logging in, Sun PAM + // uses the existing authtok that was just entered as + // the old_authtok. Other PAMs prompt the user to enter + // their existing password again. + let responses: &[&str] = if cfg!(pam_impl = "Sun") { + &["mistake", "mismatch", "acceptable", "acceptable"] + } else { + &[ + "old token!", + "mistake", + "mismatch", + "old token!", + "acceptable", + "acceptable", + ] + }; + responses[prompt_count] } else if self.wrong_password { "bogus" } else {