uid_t uid,
uint8_t md[static SHA256_DIGEST_LENGTH]) {
+ _cleanup_free_ struct passwd *pw = NULL;
sd_id128_t mid;
int r;
* (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)