mirror of
https://github.com/stenzek/duckstation.git
synced 2025-06-28 06:10:12 +00:00
Achievements: Use gethostuuid() as machine key on macOS (#3452)
This commit is contained in:
parent
99268f22ec
commit
6ef3df5a5c
@ -71,17 +71,17 @@ public:
|
||||
// append hex string
|
||||
void append_hex(const void* data, size_t len, bool comma_separate = false);
|
||||
|
||||
// append a single character to this string
|
||||
// prepend a single character to this string
|
||||
void prepend(char c);
|
||||
|
||||
// append a string to this string
|
||||
// prepend a string to this string
|
||||
void prepend(const char* str);
|
||||
void prepend(const char* str, u32 length);
|
||||
void prepend(const std::string& str);
|
||||
void prepend(const std::string_view str);
|
||||
void prepend(const SmallStringBase& str);
|
||||
|
||||
// append formatted string to this string
|
||||
// prepend formatted string to this string
|
||||
void prepend_sprintf(const char* format, ...) PRINTFLIKE(2, 3);
|
||||
void prepend_vsprintf(const char* format, va_list ap);
|
||||
|
||||
|
@ -3709,7 +3709,6 @@ static TinyString GetLoginEncryptionMachineKey()
|
||||
TinyString ret;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
HKEY hKey;
|
||||
DWORD error;
|
||||
if ((error = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Cryptography", 0, KEY_READ, &hKey)) !=
|
||||
@ -3741,12 +3740,18 @@ static TinyString GetLoginEncryptionMachineKey()
|
||||
|
||||
ret.resize(machine_guid_length);
|
||||
RegCloseKey(hKey);
|
||||
#elif !defined(__ANDROID__)
|
||||
#ifdef __linux__
|
||||
#else
|
||||
#if defined(__linux__)
|
||||
// use /etc/machine-id on Linux
|
||||
std::optional<std::string> machine_id = FileSystem::ReadFileToString("/etc/machine-id");
|
||||
if (machine_id.has_value())
|
||||
ret = std::string_view(machine_id.value());
|
||||
#elif defined(__APPLE__)
|
||||
// use gethostuuid(2) on macOS
|
||||
const struct timespec ts{};
|
||||
uuid_t uuid{};
|
||||
if (gethostuuid(uuid, &ts) == 0)
|
||||
ret.append_hex(uuid, sizeof(uuid), false);
|
||||
#endif
|
||||
|
||||
if (ret.empty())
|
||||
|
Loading…
x
Reference in New Issue
Block a user