Subject: Re: bin/8706: inconsistent formatting in id output
To: Chris G. Demetriou <cgd@netbsd.org>
From: Joel N. Weber II <nemo@red-bean.com>
List: netbsd-bugs
Date: 10/30/1999 13:11:24
That does indeed appear to fix the problem.

   This issue has already been fixed in -current and on the 1.4 branch
   (and will be fixed in 1.4.2, when that is released).

   Based on the log of changes that's gone into 1.4.2, I believe that the
   patch to fix it is enclosed below.  Please try that patch, then reply
   to this message (being sure to cc: gnats-bugs@netbsd.org so the PR
   will get a copy of your reply) indicating whether or not it solves the
   problem for you.

   Index: usr.bin/id/id.c
   diff -c usr.bin/id/id.c:1.14 usr.bin/id/id.c:1.15
   *** usr.bin/id/id.c:1.14	Sat Dec 19 08:55:21 1998
   --- usr.bin/id/id.c	Tue Aug 17 10:37:32 1999
   ***************
   *** 239,246 ****
	   }
	   if ((ngroups = getgroups(maxgroups, groups)) != NULL) {
		   for (fmt = " groups=%u", lastid = -1, cnt = 0; cnt < ngroups;
   ! 		    fmt = ", %u", lastid = id) {
   ! 			id = groups[cnt++];
			   if (lastid == id)
				   continue;
			   (void)printf(fmt, id);
   --- 239,246 ----
	   }
	   if ((ngroups = getgroups(maxgroups, groups)) != NULL) {
		   for (fmt = " groups=%u", lastid = -1, cnt = 0; cnt < ngroups;
   ! 		    fmt = ",%u", lastid = id, cnt++) {
   ! 			id = groups[cnt];
			   if (lastid == id)
				   continue;
			   (void)printf(fmt, id);
   ***************
   *** 266,280 ****
		   (void)printf("(%s)", gr->gr_name);
	   ngroups = maxgroups + 1;
	   (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
   ! 	fmt = " groups=%u";
   ! 	for (lastid = -1, cnt = 0; cnt < ngroups; ++cnt) {
   ! 		if (lastid == (id = groups[cnt]))
			   continue;
		   (void)printf(fmt, id);
   - 		fmt = " %u";
		   if ((gr = getgrgid(id)) != NULL)
			   (void)printf("(%s)", gr->gr_name);
   - 		lastid = id;
	   }
	   (void)printf("\n");
     }
   --- 266,279 ----
		   (void)printf("(%s)", gr->gr_name);
	   ngroups = maxgroups + 1;
	   (void) getgrouplist(pw->pw_name, pw->pw_gid, groups, &ngroups);
   ! 	for (fmt = " groups=%u", lastid = -1, cnt = 0; cnt < ngroups;
   ! 	    fmt=",%u", lastid = id, cnt++) {
   ! 		id = groups[cnt];
   ! 		if (lastid == id)
			   continue;
		   (void)printf(fmt, id);
		   if ((gr = getgrgid(id)) != NULL)
			   (void)printf("(%s)", gr->gr_name);
	   }
	   (void)printf("\n");
     }

   -- 
   Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
   Disclaimer: Not speaking for NetBSD, just expressing my own opinion.