cli: Trim trailing null from RPi serial
dustin/sshca/pipeline/head This commit looks good
Details
dustin/sshca/pipeline/head This commit looks good
Details
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.
parent
435221da39
commit
0d2a026279
|
@ -181,7 +181,10 @@ fn get_hostname() -> Option<String> {
|
||||||
|
|
||||||
fn get_machine_id() -> Option<Uuid> {
|
fn get_machine_id() -> Option<Uuid> {
|
||||||
match std::fs::read_to_string(RPI_SERIAL_PATH) {
|
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),
|
Ok(u) => return Some(u),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!("Invalid UUID: {}", e);
|
debug!("Invalid UUID: {}", e);
|
||||||
|
|
Loading…
Reference in New Issue