Skip to content

An open-source remote desktop application designed for self-hosting, as an alternative to TeamViewer.

Fix: replace unwrap() with proper error handling in CLI password prompt (#14910)

Azhar5ea6714db8c4
diff --git a/src/cli.rs b/src/cli.rs
index f61bfe92f..2f3b3550f 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -25,7 +25,13 @@ impl Session {
pub fn new(id: &str, sender: mpsc::UnboundedSender<Data>) -> Self {
let mut password = "".to_owned();
if PeerConfig::load(id).password.is_empty() {
- password = rpassword::prompt_password("Enter password: ").unwrap();
+ match rpassword::prompt_password("Enter password: ") {
+ Ok(p) => password = p,
+ Err(e) => {
+ log::error!("Failed to read password: {:?}", e);
+ password = "".to_owned();
+ }
+ }
}
let session = Self {
id: id.to_owned(),