From 9f3352cf71e716eb04bee4a70876e99a4fba5666 Mon Sep 17 00:00:00 2001 From: James Hodgkinson Date: Sun, 8 Aug 2021 13:36:41 +1000 Subject: [PATCH] fixes #556, humanises connection errors a little (#561) --- kanidm_tools/src/ssh_authorizedkeys.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kanidm_tools/src/ssh_authorizedkeys.rs b/kanidm_tools/src/ssh_authorizedkeys.rs index bc6cf22ca..e43132c5c 100644 --- a/kanidm_tools/src/ssh_authorizedkeys.rs +++ b/kanidm_tools/src/ssh_authorizedkeys.rs @@ -8,9 +8,10 @@ #![deny(clippy::needless_pass_by_value)] #![deny(clippy::trivially_copy_pass_by_ref)] -use kanidm_client::KanidmClientBuilder; use std::path::PathBuf; +use kanidm_client::{ClientError, KanidmClientBuilder}; + use log::{debug, error}; use structopt::StructOpt; @@ -72,9 +73,13 @@ fn main() { }); client.auth_simple_password(opt.username.as_str(), password.as_str()) }; - if r.is_err() { - eprintln!("Error during authentication phase: {:?}", r); + match r { + Err(ClientError::Transport(value)) => { + error!("Failed to connect to kanidm server: {}", value.to_string()); + } + _ => error!("Error during authentication phase: {:?}", r), + } std::process::exit(1); }