From 5a65afff1dfbd33ccf3304d6ed0dedce0a2bd6aa Mon Sep 17 00:00:00 2001 From: Christian Goeschel Ndjomouo Date: Thu, 27 Nov 2025 20:05:38 -0500 Subject: [PATCH] login: use new xgetuserpw() instead of xgetpwnam() Signed-off-by: Christian Goeschel Ndjomouo --- login-utils/login.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/login-utils/login.c b/login-utils/login.c index 402e17820..4f4cc9055 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -478,11 +478,9 @@ static void chown_tty(struct login_context *cxt) grname = getlogindefs_str("TTYGROUP", TTYGRPNAME); if (grname && *grname) { - struct group *gr = getgrnam(grname); - if (gr) /* group by name */ + struct group *gr = ul_getgrp_str(grname); + if (gr) gid = gr->gr_gid; - else /* group by ID */ - gid = (gid_t) getlogindefs_num("TTYGROUP", gid); } if (fchown(0, uid, gid)) /* tty */ chown_err(cxt->tty_name, uid, gid); @@ -643,13 +641,13 @@ static void log_audit(struct login_context *cxt, int status) if (audit_fd == -1) return; if (!pwd && cxt->username) - pwd = getpwnam(cxt->username); + pwd = ul_getuserpw_str(cxt->username); ignore_result( audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN, NULL, "login", - cxt->username ? cxt->username : "(unknown)", + pwd ? pwd->pw_name : "(unknown)", pwd ? pwd->pw_uid : (unsigned int)-1, cxt->hostname, NULL, @@ -1521,7 +1519,7 @@ int main(int argc, char **argv) */ loginpam_acct(&cxt); - cxt.pwd = xgetpwnam(cxt.username, &cxt.pwdbuf); + cxt.pwd = xgetuserpw(cxt.username, &cxt.pwdbuf); if (!cxt.pwd) { warnx(_("\nSession setup problem, abort.")); syslog(LOG_ERR, _("Invalid user name \"%s\". Abort."), -- 2.47.3