From 93d5c5434d67ee6231526b9de9f0c6d79f012bb2 Mon Sep 17 00:00:00 2001 From: James Hodgkinson Date: Wed, 30 Jun 2021 16:56:31 +1000 Subject: [PATCH] fixes #503 - TOTP prompt no longer drops a newline (#515) * fixes #503 * Adding comment for future archeologists. Hello, future-people! --- kanidm_tools/src/cli/session.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kanidm_tools/src/cli/session.rs b/kanidm_tools/src/cli/session.rs index a635f9c40..fa44289ee 100644 --- a/kanidm_tools/src/cli/session.rs +++ b/kanidm_tools/src/cli/session.rs @@ -6,7 +6,7 @@ use libc::umask; use std::collections::BTreeMap; use std::fs::{create_dir, File}; use std::io::ErrorKind; -use std::io::{self, BufReader, BufWriter}; +use std::io::{self, BufReader, BufWriter, Write}; use std::path::PathBuf; use webauthn_authenticator_rs::{u2fhid::U2FHid, RequestChallengeResponse, WebauthnAuthenticator}; @@ -144,7 +144,9 @@ impl LoginOpt { fn do_totp(&self, client: &mut KanidmClient) -> Result { let totp = loop { - println!("Enter TOTP: "); + print!("Enter TOTP: "); + // We flush stdout so it'll write the buffer to screen, continuing operation. Without it, the application halts. + io::stdout().flush().unwrap(); let mut buffer = String::new(); if let Err(e) = io::stdin().read_line(&mut buffer) { eprintln!("Failed to read from stdin -> {:?}", e);