From 0d2a0262794841adcb9633d8fb43457355a43eaf Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Sun, 12 Nov 2023 10:44:48 -0600 Subject: [PATCH] cli: Trim trailing null from RPi serial The `/sys/firmware/devicetree/base/serial-number` pseudo-file has a trailing null byte, which causes `Uuid::parse_srr` to fail. This makes it impossible to authenticate Raspberry Pi devices to the server. The trailing byte needs to be removed before attempting to parse the serial number into a UUID to avoid this problem. --- cli/src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index c95c7fd..ba98571 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -181,7 +181,10 @@ fn get_hostname() -> Option { fn get_machine_id() -> Option { match std::fs::read_to_string(RPI_SERIAL_PATH) { - Ok(s) => match Uuid::parse_str(&format!("{:0>32}", s)) { + Ok(s) => match Uuid::parse_str(&format!( + "{:0>32}", + s.trim_end_matches('\0') + )) { Ok(u) => return Some(u), Err(e) => { debug!("Invalid UUID: {}", e);