diff --git a/tools/cli/src/opt/ssh_authorizedkeys.rs b/tools/cli/src/opt/ssh_authorizedkeys.rs index f5bc51121..947973fb1 100644 --- a/tools/cli/src/opt/ssh_authorizedkeys.rs +++ b/tools/cli/src/opt/ssh_authorizedkeys.rs @@ -1,4 +1,5 @@ #[derive(Debug, Parser)] +#[command(version)] struct SshAuthorizedOpt { #[clap(short, long = "debug")] debug: bool, diff --git a/unix_integration/src/opt/ssh_authorizedkeys.rs b/unix_integration/src/opt/ssh_authorizedkeys.rs index 2fe0e56d1..1f9e472f8 100644 --- a/unix_integration/src/opt/ssh_authorizedkeys.rs +++ b/unix_integration/src/opt/ssh_authorizedkeys.rs @@ -1,10 +1,10 @@ #[derive(Debug, Parser)] -#[command(name="kanidm_ssh_authorizedkeys")] +#[command(name = "kanidm_ssh_authorizedkeys")] struct SshAuthorizedOpt { #[clap(short, long)] debug: bool, #[clap()] - account_id: String, + account_id: Option, #[clap(short, long, action = clap::ArgAction::SetTrue)] version: bool, } diff --git a/unix_integration/src/ssh_authorizedkeys.rs b/unix_integration/src/ssh_authorizedkeys.rs index a5ca661f1..cd11da89d 100644 --- a/unix_integration/src/ssh_authorizedkeys.rs +++ b/unix_integration/src/ssh_authorizedkeys.rs @@ -34,8 +34,14 @@ async fn main() -> ExitCode { println!("ssh_authorizedkeys {}", env!("KANIDM_PKG_VERSION")); return ExitCode::SUCCESS; } + sketching::tracing_subscriber::fmt::init(); + if opt.account_id.is_none() { + error!("No account specified, quitting!"); + return ExitCode::FAILURE; + } + debug!("Starting authorized keys tool ..."); let cfg = match KanidmUnixdConfig::new().read_options_from_optional_config(DEFAULT_CONFIG_PATH) @@ -60,7 +66,8 @@ async fn main() -> ExitCode { ); return ExitCode::FAILURE; } - let req = ClientRequest::SshKey(opt.account_id); + // safe because we've already thrown an error if it's not there + let req = ClientRequest::SshKey(opt.account_id.unwrap_or("".to_string())); match call_daemon(cfg.sock_path.as_str(), req, cfg.unix_sock_timeout).await { Ok(r) => match r { diff --git a/unix_integration/src/tasks_daemon.rs b/unix_integration/src/tasks_daemon.rs index 65bdc97c6..3a67a2178 100644 --- a/unix_integration/src/tasks_daemon.rs +++ b/unix_integration/src/tasks_daemon.rs @@ -267,6 +267,19 @@ async fn main() -> ExitCode { let ceuid = get_effective_uid(); let cegid = get_effective_gid(); + for arg in std::env::args() { + if arg.contains("--version") { + println!("kanidm_unixd_tasks {}", env!("CARGO_PKG_VERSION")); + return ExitCode::SUCCESS; + } else if arg.contains("--help") { + println!("kanidm_unixd_tasks {}", env!("CARGO_PKG_VERSION")); + println!("Usage: kanidm_unixd_tasks"); + println!(" --version"); + println!(" --help"); + return ExitCode::SUCCESS; + } + } + #[allow(clippy::expect_used)] tracing_forest::worker_task() .set_global(true)