]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lslogins: fix broken GROUP column output
authorKarel Zak <kzak@redhat.com>
Mon, 9 Mar 2026 11:04:44 +0000 (12:04 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 9 Mar 2026 11:04:44 +0000 (12:04 +0100)
The condition on COL_GROUP incorrectly checked `!grp->gr_name`
instead of `!user->group`. This caused the GROUP column to always
be empty because when gr_name is non-NULL (normal case) the
assignment was skipped, and when gr_name is NULL, xstrdup() would
crash.

Fixes: https://github.com/util-linux/util-linux/issues/4097
Fixes: 52a6e45bfe5ddee1fed20f2f4f7542cac6bf13c9
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/lslogins.c

index 26c08783fc8abbb1ad545fb5ab9268b9755689e6..28dd7d79aed5b234364bc8f8bec2481bcbcfbb16 100644 (file)
@@ -853,7 +853,7 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
                        user->uid = pwd->pw_uid;
                        break;
                case COL_GROUP:
-                       if (!grp->gr_name)
+                       if (!user->group)
                                user->group = xstrdup(grp->gr_name);
                        break;
                case COL_GID: