Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
lslogins segfault when execute with buggy user name.
Version-Release number of selected component (if applicable):
util-linux-2.23.2-26.el7.x86_64
How reproducible:
Always
Steps to Reproduce:
1.Execute lslogins with buggy user name
Actual results:
lslogins abort due to scols_line_get_cell: Assertion `ln' failed and it is failed because user does not exist.
Expected results:
It should not segfault
Additional info:
Hi,
After checked the lslogins code it seems get_user_info is returned NULL if user does not exist and initially errno is 0
static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const char *username)
{
struct lslogins_user *user;
struct passwd *pwd;
struct group *grp;
struct spwd *shadow;
struct utmp *user_wtmp = NULL, *user_btmp = NULL;
int n = 0;
time_t time;
uid_t uid;
errno = 0;
pwd = username ? getpwnam(username) : getpwent();
if (!pwd)
return NULL;
.......
.......
}
In function get_user to validate about error it is doing logical and with errno but if errno is 0 in that case the code path will not execute even user is NULL so it will return 0,It should check if user is NULL then should return -1.
static int get_user(struct lslogins_control *ctl, struct lslogins_user **user,const char *username)
{
*user = get_user_info(ctl, username);
if (!*user && errno)
if (IS_REAL_ERRNO(errno))
return -1;
return 0;
}
I think after update above condition it will execute successfully.
Fixed by upstream commit 123f0f5bf00635e5dd7e5cbc73f906bf2a0bed9c.
It would be probably nice to rebase all lslogins.c with the current upstream. There is many another bugfixes.
(In reply to Terry Bowling from comment #15)
> Does this also affect RHEL 6? Should this be cloned?
The most fatal issues should be already fixed in RHEL6.8 (see bug #1215840), the last missing things for RHEL6 are nonsenses in --help output.
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://rhn.redhat.com/errata/RHSA-2016-2605.html