MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / GetMachineID

Function GetMachineID

src/Platform_Posix.c:1446–1463  ·  view source on GitHub ↗

Read /var/lib/dbus/machine-id or /etc/machine-id for the key */

Source from the content-addressed store, hash-verified

1444#if defined CC_BUILD_LINUX
1445/* Read /var/lib/dbus/machine-id or /etc/machine-id for the key */
1446static 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 */

Callers

nothing calls this directly

Calls 6

Stream_OpenPathFunction · 0.85
Stream_ReadFunction · 0.85
DecodeMachineIDFunction · 0.85
String_LengthFunction · 0.85
Mem_CopyFunction · 0.85
GetDeviceUUIDFunction · 0.85

Tested by

no test coverage detected