Merge tag 'v0.23.12'

release v0.23.12
This commit is contained in:
Max Kellermann
2023-01-17 18:58:04 +01:00
7 changed files with 25 additions and 23 deletions

View File

@@ -34,7 +34,6 @@
#include <shlobj.h>
#else
#include <stdlib.h>
#include <unistd.h>
#include <pwd.h>
#endif
@@ -83,16 +82,7 @@ public:
return result != nullptr;
}
bool ReadByUid(uid_t uid) noexcept {
#ifdef HAVE_GETPWUID_R
getpwuid_r(uid, &pw, buf.data(), buf.size(), &result);
#else
result = getpwuid(uid);
#endif
return result != nullptr;
}
const passwd *operator->() noexcept {
const passwd *operator->() {
assert(result != nullptr);
return result;
}
@@ -415,10 +405,8 @@ GetHomeDir() noexcept
#ifndef ANDROID
if (const auto home = GetExistingEnvDirectory("HOME"); home != nullptr)
return AllocatedPath{home};
if (PasswdEntry pw; pw.ReadByUid(getuid()))
return SafePathFromFS(pw->pw_dir);
#endif
return nullptr;
}