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.
dev/auto-reload
Dustin 2023-11-16 20:10:26 -06:00
parent 041788e818
commit 1d0e558163
1 changed files with 7 additions and 0 deletions

View File

@ -180,6 +180,13 @@ fn get_hostname() -> Option<String> {
}
fn get_machine_id() -> Option<Uuid> {
#[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}",