--- util-linux-ng-2.13/login-utils/login.c +++ util-linux-ng-2.13/login-utils/login.c @@ -324,21 +324,17 @@ static void logaudit(const char *tty, const char *username, const char *hostname, struct passwd *pwd, int status) { - char buf[64]; int audit_fd; audit_fd = audit_open(); if (audit_fd == -1) return; - if (!pwd) + if (!pwd && username) pwd = getpwnam(username); - if (pwd) - snprintf(buf, sizeof(buf), "uid=%d", pwd->pw_uid); - else - snprintf(buf, sizeof(buf), "acct=%s", username); - audit_log_user_message(audit_fd, AUDIT_USER_LOGIN, - buf, hostname, NULL, tty, status); + audit_log_acct_message(audit_fd, AUDIT_USER_LOGIN, + NULL, "login", username ? username : "(unknown)", + pwd ? pwd->pw_uid : -1, hostname, NULL, tty, status); close(audit_fd); }