Read /var/lib/dbus/machine-id or /etc/machine-id for the key */
| 1444 | #if defined CC_BUILD_LINUX |
| 1445 | /* Read /var/lib/dbus/machine-id or /etc/machine-id for the key */ |
| 1446 | static cc_result GetMachineID(cc_uint32* key) { |
| 1447 | const cc_filepath* id_path = FILEPATH_RAW("/var/lib/dbus/machine-id"); |
| 1448 | const cc_filepath* alt_path = FILEPATH_RAW("/etc/machine-id"); |
| 1449 | char tmp[MACHINEID_LEN]; |
| 1450 | struct Stream s; |
| 1451 | cc_result res; |
| 1452 | |
| 1453 | /* Some machines only have dbus id, others only have etc id */ |
| 1454 | res = Stream_OpenPath(&s, id_path); |
| 1455 | if (res) res = Stream_OpenPath(&s, alt_path); |
| 1456 | if (res) return res; |
| 1457 | |
| 1458 | res = Stream_Read(&s, (cc_uint8*)tmp, MACHINEID_LEN); |
| 1459 | if (!res) DecodeMachineID(tmp, MACHINEID_LEN, key); |
| 1460 | |
| 1461 | (void)s.Close(&s); |
| 1462 | return res; |
| 1463 | } |
| 1464 | #elif defined CC_BUILD_MACOS |
| 1465 | /* kIOMasterPortDefault is deprecated since macOS 12.0 (replaced with kIOMainPortDefault) */ |
| 1466 | /* And since kIOMasterPortDefault is just 0/NULL anyways, just manually declare it */ |
nothing calls this directly
no test coverage detected