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.dev/auto-reload
parent
5ab5c3e98d
commit
d8126a6dcb
|
@ -181,7 +181,10 @@ fn get_hostname() -> Option<String> {
|
|||
|
||||
fn get_machine_id() -> Option<Uuid> {
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue