]> git.proxmox.com Git - proxmox-backup.git/commitdiff
client: improve connection/new fingerprint query
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 26 May 2020 09:52:36 +0000 (11:52 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Tue, 2 Jun 2020 08:40:31 +0000 (10:40 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/client/http_client.rs

index 23c4aa54a2803294fbf19a9a5d9adbb59ba3482c..52d699e19da027adb9cfd2ba8ab611a3e7a43159 100644 (file)
@@ -400,21 +400,22 @@ impl HttpClient {
         if interactive && tty::stdin_isatty() {
             println!("fingerprint: {}", fp_string);
             loop {
-                print!("Want to trust? (y/n): ");
+                print!("Are you sure you want to continue connecting? (y/n): ");
                 let _ = std::io::stdout().flush();
-                let mut buf = [0u8; 1];
-                use std::io::Read;
-                match std::io::stdin().read_exact(&mut buf) {
-                    Ok(()) => {
-                        if buf[0] == b'y' || buf[0] == b'Y' {
+                use std::io::{BufRead, BufReader};
+                let mut line = String::new();
+                match BufReader::new(std::io::stdin()).read_line(&mut line) {
+                    Ok(_) => {
+                        let trimmed = line.trim();
+                        if trimmed == "y" || trimmed == "Y" {
                             return (true, Some(fp_string));
-                        } else if buf[0] == b'n' || buf[0] == b'N' {
+                        } else if trimmed == "n" || trimmed == "N" {
                             return (false, None);
+                        } else {
+                            continue;
                         }
                     }
-                    Err(_) => {
-                        return (false, None);
-                    }
+                    Err(_) => return (false, None),
                 }
             }
         }