login: use STREROR_USER helper

This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2025-11-18 10:28:53 +01:00
parent 718578b96d
commit f3f933ee92
2 changed files with 2 additions and 4 deletions

View File

@@ -348,10 +348,8 @@ static int run(int argc, char *argv[]) {
if (streq(verb, "start")) {
_cleanup_(user_record_unrefp) UserRecord *ur = NULL;
r = userdb_by_name(user, /* match= */ NULL, USERDB_PARSE_NUMERIC|USERDB_SUPPRESS_SHADOW, &ur);
if (r == -ESRCH)
return log_error_errno(r, "User '%s' does not exist: %m", user);
if (r < 0)
return log_error_errno(r, "Failed to resolve user '%s': %m", user);
return log_error_errno(r, "Failed to resolve user '%s': %s", user, STRERROR_USER(r));
/* We do two things here: mount the per-user XDG_RUNTIME_DIR, and set up tmpfs quota on /tmp/
* and /dev/shm/. */

View File

@@ -932,7 +932,7 @@ int userdb_by_name(const char *name, const UserDBMatch *match, UserDBFlags flags
r = userdb_start_query(iterator, "io.systemd.UserDatabase.GetUserRecord", /* more= */ false, query, flags);
if (r >= 0) {
r = userdb_process(iterator, &ur, /* ret_group_record= */ NULL, /* ret_user_name= */ NULL, /* ret_group_name= */ NULL);
if (r == -ENOEXEC) /* found a user matching UID or name, but not filter. In this case the
if (r == -ENOEXEC) /* Found a user matching UID or name, but not filter. In this case the
* fallback paths below are pointless */
return r;
}