From 1d0e55816300a081606a1aafa1cf1380c4011cfe Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Thu, 16 Nov 2023 20:10:26 -0600 Subject: [PATCH] Add SSHCA_CLI_DEBUG_TEST_MACHINE_ID env var When running a debug build, the `sshca host sign` command will now check the `SSHCA_CLI_DEBUG_TEST_MACHINE_ID` environment variable for the value to use as the machine ID. This is useful during development and testing, where the real machine ID is inaccessible or otherwise unavailable. The `SSHCA_CLI_DEBUG_TEST_MACHINE_ID` environment variable is *NOT* used at all in release builds. --- src/main.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/main.rs b/src/main.rs index ba98571..3d09fa5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -180,6 +180,13 @@ fn get_hostname() -> Option { } fn get_machine_id() -> Option { + #[cfg(debug_assertions)] + if let Ok(v) = std::env::var("SSHCA_CLI_DEBUG_TEST_MACHINE_ID") { + if let Ok(u) = Uuid::parse_str(&v) { + return Some(u); + } + }; + match std::fs::read_to_string(RPI_SERIAL_PATH) { Ok(s) => match Uuid::parse_str(&format!( "{:0>32}",