SWDEV-387026: using gethostid instead of depending on libsystemd

Change-Id: If576eec4abee1a52dfe7cc5bce507420bc8a4d07
Tento commit je obsažen v:
Ammar ELWazir
2023-03-06 22:15:09 +00:00
rodič da570693e3
revize 05f2ef97f9
10 změnil soubory, kde provedl 34 přidání a 61 odebrání
+1 -9
Zobrazit soubor
@@ -27,7 +27,6 @@
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <systemd/sd-id128.h>
#include <cassert>
#include <cstdint>
@@ -50,14 +49,7 @@ namespace {
}
[[maybe_unused]] uint64_t GetMachineID() {
char hostname[1023] = "\0";
gethostname(hostname, 1023);
sd_id128_t ret;
char machine_id[SD_ID128_STRING_MAX];
[[maybe_unused]] int status = sd_id128_get_machine(&ret);
assert(status == 0 && "Error: Couldn't get machine id!");
if (sd_id128_to_string(ret, machine_id)) return std::hash<std::string>{}(machine_id);
return std::rand();
return gethostid();
}
} // namespace