shared/creds-util: use getpwuid_malloc()
Static linking, i.e. without dlopen, sometimes fails when getpwuid is used. I doesn't fail in all cases (glibc version?), so I didn't do this initially.
This commit is contained in:
@@ -768,6 +768,7 @@ static int mangle_uid_into_key(
|
||||
uid_t uid,
|
||||
uint8_t md[static SHA256_DIGEST_LENGTH]) {
|
||||
|
||||
_cleanup_free_ struct passwd *pw = NULL;
|
||||
sd_id128_t mid;
|
||||
int r;
|
||||
|
||||
@@ -778,12 +779,9 @@ static int mangle_uid_into_key(
|
||||
* (specifically, UID, user name, machine ID) with the key we'd otherwise use for system credentials,
|
||||
* and use the resulting hash as actual encryption key. */
|
||||
|
||||
errno = 0;
|
||||
struct passwd *pw = getpwuid(uid);
|
||||
if (!pw)
|
||||
return log_error_errno(
|
||||
IN_SET(errno, 0, ENOENT) ? SYNTHETIC_ERRNO(ESRCH) : errno,
|
||||
"Failed to resolve UID " UID_FMT ": %m", uid);
|
||||
r = getpwuid_malloc(uid, &pw);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to resolve UID "UID_FMT": %m", uid);
|
||||
|
||||
r = sd_id128_get_machine(&mid);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user