Skip to content

Commit 809e13e

Browse files
committed
pam: Undo refactor from aa5394f
Creating the tuple `(HiddenInput::new(true)?, self)` moves `self`, which we still need to use later (to write a newline if the read fails). Signed-off-by: Wesley Hershberger <[email protected]>
1 parent 2b4d403 commit 809e13e

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/pam/rpassword.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -279,16 +279,19 @@ impl Terminal<'_> {
279279
&mut self,
280280
timeout: Option<Duration>,
281281
) -> io::Result<PamBuffer> {
282-
match (HiddenInput::new(true)?, self) {
283-
(Some(hide_input), Terminal::StdIE(stdin, stdout)) => {
284-
let mut reader = TimeoutRead::new(stdin.as_fd(), timeout);
285-
read_unbuffered_with_feedback(&mut reader, stdout, &hide_input)
286-
}
287-
(Some(hide_input), Terminal::Tty(file)) => {
288-
let mut reader = TimeoutRead::new(file.as_fd(), timeout);
289-
read_unbuffered_with_feedback(&mut reader, &mut &*file, &hide_input)
282+
if let Some(hide_input) = HiddenInput::new(true)? {
283+
match self {
284+
Terminal::StdIE(stdin, stdout) => {
285+
let mut reader = TimeoutRead::new(stdin.as_fd(), timeout);
286+
read_unbuffered_with_feedback(&mut reader, stdout, &hide_input)
287+
}
288+
Terminal::Tty(file) => {
289+
let mut reader = TimeoutRead::new(file.as_fd(), timeout);
290+
read_unbuffered_with_feedback(&mut reader, &mut &*file, &hide_input)
291+
}
290292
}
291-
(None, term) => read_unbuffered(&mut term.source_timeout(timeout)),
293+
} else {
294+
read_unbuffered(&mut self.source_timeout(timeout))
292295
}
293296
}
294297

0 commit comments

Comments
 (0)