From b5203ad09868b7c521f010b0f66c75d101a17ba5 Mon Sep 17 00:00:00 2001 From: David Greenman Date: Mon, 28 Aug 1995 10:23:58 +0000 Subject: [PATCH] Fixed bug where 'id ' output the wrong group name (the user name was output instead). Pointed out by Chael Hall . --- usr.bin/id/id.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c index 9b306ce4d114..61cae11a58f8 100644 --- a/usr.bin/id/id.c +++ b/usr.bin/id/id.c @@ -231,24 +231,24 @@ user(pw) { register struct group *gr; register char *fmt, **p; - int cnt, id, lastid, ngroups, groups[NGROUPS + 1]; + int cnt, gid, lastgid, ngroups, groups[NGROUPS + 1]; - id = pw->pw_uid; - (void)printf("uid=%u(%s)", id, pw->pw_name); - (void)printf(" gid=%u", pw->pw_gid); - if (gr = getgrgid(id)) + (void)printf("uid=%u(%s)", pw->pw_uid, pw->pw_name); + gid = pw->pw_gid; + (void)printf(" gid=%u", gid); + if (gr = getgrgid(gid)) (void)printf("(%s)", gr->gr_name); ngroups = NGROUPS + 1; - (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups); + (void) getgrouplist(pw->pw_name, gid, groups, &ngroups); fmt = " groups=%u"; - for (lastid = -1, cnt = 0; cnt < ngroups; ++cnt) { - if (lastid == (id = groups[cnt])) + for (lastgid = -1, cnt = 0; cnt < ngroups; ++cnt) { + if (lastgid == (gid = groups[cnt])) continue; - (void)printf(fmt, id); + (void)printf(fmt, gid); fmt = " %u"; - if (gr = getgrgid(id)) + if (gr = getgrgid(gid)) (void)printf("(%s)", gr->gr_name); - lastid = id; + lastgid = gid; } (void)printf("\n"); }