lslogins: ask for supplementary groups only once [asan]
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
f626170062
commit
d1a5e99e8a
|
@ -562,6 +562,9 @@ static int get_sgroups(gid_t **list, size_t *len, struct passwd *pwd)
|
||||||
|
|
||||||
*list = xcalloc(1, ngroups * sizeof(gid_t));
|
*list = xcalloc(1, ngroups * sizeof(gid_t));
|
||||||
|
|
||||||
|
fprintf(stderr, "KZAK>>> alloc '%p' for %s\n", *list, pwd->pw_name);
|
||||||
|
|
||||||
|
|
||||||
/* now for the actual list of GIDs */
|
/* now for the actual list of GIDs */
|
||||||
if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
|
if (-1 == getgrouplist(pwd->pw_name, pwd->pw_gid, *list, &ngroups))
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -754,7 +757,8 @@ static struct lslogins_user *get_user_info(struct lslogins_control *ctl, const c
|
||||||
break;
|
break;
|
||||||
case COL_SGROUPS:
|
case COL_SGROUPS:
|
||||||
case COL_SGIDS:
|
case COL_SGIDS:
|
||||||
if (get_sgroups(&user->sgroups, &user->nsgroups, pwd))
|
if (!user->nsgroups &&
|
||||||
|
get_sgroups(&user->sgroups, &user->nsgroups, pwd) < 0)
|
||||||
err(EXIT_FAILURE, _("failed to get supplementary groups"));
|
err(EXIT_FAILURE, _("failed to get supplementary groups"));
|
||||||
break;
|
break;
|
||||||
case COL_HOME:
|
case COL_HOME:
|
||||||
|
@ -1048,7 +1052,6 @@ static int create_usertree(struct lslogins_control *ctl)
|
||||||
}
|
}
|
||||||
if (rc || !user)
|
if (rc || !user)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tsearch(user, &ctl->usertree, cmp_uid);
|
tsearch(user, &ctl->usertree, cmp_uid);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue