summaryrefslogtreecommitdiffstats
path: root/usr.bin/id/id.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/id/id.c')
-rw-r--r--usr.bin/id/id.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c
index e3e8f4c..e352712 100644
--- a/usr.bin/id/id.c
+++ b/usr.bin/id/id.c
@@ -74,11 +74,13 @@ main(int argc, char *argv[])
struct group *gr;
struct passwd *pw;
int Gflag, Mflag, Pflag, ch, gflag, id, nflag, pflag, rflag, uflag;
- int Aflag;
+ int Aflag, cflag;
+ int error;
const char *myname;
+ char loginclass[MAXLOGNAME];
Gflag = Mflag = Pflag = gflag = nflag = pflag = rflag = uflag = 0;
- Aflag = 0;
+ Aflag = cflag = 0;
myname = strrchr(argv[0], '/');
myname = (myname != NULL) ? myname + 1 : argv[0];
@@ -92,7 +94,7 @@ main(int argc, char *argv[])
}
while ((ch = getopt(argc, argv,
- (isgroups || iswhoami) ? "" : "APGMagnpru")) != -1)
+ (isgroups || iswhoami) ? "" : "APGMacgnpru")) != -1)
switch(ch) {
#ifdef USE_BSM_AUDIT
case 'A':
@@ -110,6 +112,9 @@ main(int argc, char *argv[])
break;
case 'a':
break;
+ case 'c':
+ cflag = 1;
+ break;
case 'g':
gflag = 1;
break;
@@ -158,6 +163,14 @@ main(int argc, char *argv[])
}
#endif
+ if (cflag) {
+ error = getloginclass(loginclass, sizeof(loginclass));
+ if (error != 0)
+ err(1, "loginclass");
+ (void)printf("%s\n", loginclass);
+ exit(0);
+ }
+
if (gflag) {
id = pw ? pw->pw_gid : rflag ? getgid() : getegid();
if (nflag && (gr = getgrgid(id)))
@@ -467,7 +480,7 @@ usage(void)
else if (iswhoami)
(void)fprintf(stderr, "usage: whoami\n");
else
- (void)fprintf(stderr, "%s\n%s%s\n%s\n%s\n%s\n%s\n%s\n",
+ (void)fprintf(stderr, "%s\n%s%s\n%s\n%s\n%s\n%s\n%s\n%s\n",
"usage: id [user]",
#ifdef USE_BSM_AUDIT
" id -A\n",
@@ -477,6 +490,7 @@ usage(void)
" id -G [-n] [user]",
" id -M",
" id -P [user]",
+ " id -c",
" id -g [-nr] [user]",
" id -p [user]",
" id -u [-nr] [user]");
OpenPOWER on IntegriCloud