annotate toys/posix/id.c @ 674:7e846e281e38

New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
author Rob Landley <rob@landley.net>
date Mon, 08 Oct 2012 00:02:30 -0500
parents 6df4ccc0acbe
children 786841fdb1e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
1 /* vi: set sw=4 ts=4:
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
2 *
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
3 * id.c - print real and effective user and group IDs
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
4 *
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
5 * Copyright 2012 Sony Network Entertainment, Inc.
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
6 *
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
7 * by Tim Bird <tim.bird@am.sony.com>
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
8 *
656
6df4ccc0acbe Regularize command headers, update links to standards documents.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
9 * See http://opengroup.org/onlinepubs/9699919799/utilities/id.html
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
10
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
11 USE_ID(NEWTOY(id, "nGgru", TOYFLAG_BIN))
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
12
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
13 config ID
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
14 bool "id"
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
15 default y
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
16 help
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
17 usage: id [-nGgru]
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
18
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
19 Print user and group ID.
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
20
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
21 -n print names instead of numeric IDs (to be used with -Ggu)
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
22 -G Show only the group IDs
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
23 -g Show only the effective group ID
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
24 -r Show real ID instead of effective ID
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
25 -u Show only the effective user ID
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
26 */
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
27
674
7e846e281e38 New build infrastructure to generate FLAG_ macros and TT alias, #define FOR_commandname before #including toys.h to trigger it. Rename DEFINE_GLOBALS() to just GLOBALS() (because I could never remember if it was DECLARE_GLOBALS). Convert existing commands to use new infrastructure, and replace optflag constants with FLAG_ macros where appropriate.
Rob Landley <rob@landley.net>
parents: 656
diff changeset
28 #define FOR_id
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
29 #include "toys.h"
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
30
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
31 static void s_or_u(char *s, unsigned u, int done)
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
32 {
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
33 if (toys.optflags & FLAG_n) printf("%s", s);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
34 else printf("%u", u);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
35 if (done) {
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
36 xputc('\n');
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
37 exit(0);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
38 }
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
39 }
542
06763d1a2f9d Tighten up the code a bit, and use actual process group id instead of what /etc/passwd says.
Rob Landley <rob@landley.net>
parents: 533
diff changeset
40
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
41 static void showid(char *header, unsigned u, char *s)
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
42 {
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
43 printf("%s%u(%s)", header, u, s);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
44 }
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
45
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
46 struct passwd *xgetpwuid(uid_t uid)
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
47 {
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
48 struct passwd *pwd = getpwuid(uid);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
49 if (!pwd) error_exit(NULL);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
50 return pwd;
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
51 }
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
52
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
53 struct group *xgetgrgid(gid_t gid)
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
54 {
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
55 struct group *group = getgrgid(gid);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
56 if (!group) error_exit(NULL);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
57 return group;
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
58 }
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
59
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
60 void id_main(void)
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
61 {
542
06763d1a2f9d Tighten up the code a bit, and use actual process group id instead of what /etc/passwd says.
Rob Landley <rob@landley.net>
parents: 533
diff changeset
62 int flags = toys.optflags, i, ngroups;
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
63 struct passwd *pw;
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
64 struct group *grp;
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
65 uid_t uid = getuid(), euid = geteuid();
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
66 gid_t gid = getgid(), egid = getegid(), *groups;
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
67
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
68 /* check if a username is given */
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
69 if (*toys.optargs) {
542
06763d1a2f9d Tighten up the code a bit, and use actual process group id instead of what /etc/passwd says.
Rob Landley <rob@landley.net>
parents: 533
diff changeset
70 if (!(pw = getpwnam(*toys.optargs)))
06763d1a2f9d Tighten up the code a bit, and use actual process group id instead of what /etc/passwd says.
Rob Landley <rob@landley.net>
parents: 533
diff changeset
71 error_exit("no such user '%s'", *toys.optargs);
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
72 uid = euid = pw->pw_uid;
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
73 gid = egid = pw->pw_gid;
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
74 }
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
75
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
76 i = toys.optflags & FLAG_r;
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
77 pw = xgetpwuid(i ? uid : euid);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
78 if (flags & FLAG_u) s_or_u(pw->pw_name, pw->pw_uid, 1);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
79
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
80 grp = xgetgrgid(i ? gid : egid);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
81 if (flags & FLAG_g) s_or_u(grp->gr_name, grp->gr_gid, 1);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
82
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
83 if (!(flags & FLAG_G)) {
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
84 showid("uid=", pw->pw_uid, pw->pw_name);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
85 showid(" gid=", grp->gr_gid, grp->gr_name);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
86
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
87 if (!i) {
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
88 if (uid != euid) {
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
89 pw = xgetpwuid(euid);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
90 showid(" euid=", pw->pw_uid, pw->pw_name);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
91 }
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
92 if (gid != egid) {
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
93 grp = xgetgrgid(egid);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
94 showid(" egid=", grp->gr_gid, grp->gr_name);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
95 }
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
96 }
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
97
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
98 showid(" groups=", grp->gr_gid, grp->gr_name);
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
99 }
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
100
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
101
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
102 groups = (gid_t *)toybuf;
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
103 if (0 >= (ngroups = getgroups(sizeof(toybuf)/sizeof(gid_t), groups)))
542
06763d1a2f9d Tighten up the code a bit, and use actual process group id instead of what /etc/passwd says.
Rob Landley <rob@landley.net>
parents: 533
diff changeset
104 perror_exit(0);
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
105
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
106 for (i = 0; i < ngroups; i++) {
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
107 xputc(' ');
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
108 if (!(grp = getgrgid(groups[i]))) perror_msg(0);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
109 else if (flags & FLAG_G)
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
110 s_or_u(grp->gr_name, grp->gr_gid, 0);
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
111 else if (grp->gr_gid != egid) showid("", grp->gr_gid, grp->gr_name);
493
42a322adbd17 update id to be SUS compliant
Daniel Walter <d.walter@0x90.at>
parents: 430
diff changeset
112 }
543
60b97ba66a70 Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
Rob Landley <rob@landley.net>
parents: 542
diff changeset
113 xputc('\n');
413
12add511705e Add id command from Tim Bird.
Rob Landley <rob@landley.net>
parents:
diff changeset
114 }