SCCS-vsn: usr.bin/id/id.c 5.5
#endif /* not lint */
#ifndef lint
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)id.c 5.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)id.c 5.5 (Berkeley) %G%";
#endif /* not lint */
#include <sys/param.h>
#endif /* not lint */
#include <sys/param.h>
u_int eid, rid;
char *login;
u_int eid, rid;
char *login;
(void)printf("uid\t%s\n", pw->pw_name);
(void)printf("uid\t%s\n", pw->pw_name);
+ (void)printf("groups\t");
+ group(pw, 1);
+ } else {
if ((login = getlogin()) == NULL)
err("getlogin: %s", strerror(errno));
if ((login = getlogin()) == NULL)
err("getlogin: %s", strerror(errno));
(void)printf("rgid\t%s\n", gr->gr_name);
else
(void)printf("rgid\t%u\n", rid);
(void)printf("rgid\t%s\n", gr->gr_name);
else
(void)printf("rgid\t%u\n", rid);
+ (void)printf("groups\t");
+ group(NULL, 1);
- (void)printf("groups\t");
- group(pw, 1);
int nflag;
{
struct group *gr;
int nflag;
{
struct group *gr;
- int id, lastid, ngroups, groups[NGROUPS + 1];
+ int cnt, id, lastid, ngroups, groups[NGROUPS + 1];
char *fmt, *name, **p;
fmt = nflag ? "%s" : "%u";
char *fmt, *name, **p;
fmt = nflag ? "%s" : "%u";
} else {
groups[0] = getgid();
ngroups = getgroups(NGROUPS, groups + 1) + 1;
} else {
groups[0] = getgid();
ngroups = getgroups(NGROUPS, groups + 1) + 1;
- for (lastid = -1; --ngroups >= 0;) {
- if (lastid == (id = groups[ngroups]))
+ for (lastid = -1, cnt = 0; cnt < ngroups; ++cnt) {
+ if (lastid == (id = groups[cnt]))
continue;
if (nflag) {
if (gr = getgrgid(id))
continue;
if (nflag) {
if (gr = getgrgid(id))