=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/id/id.c,v retrieving revision 1.22 retrieving revision 1.23 diff -c -r1.22 -r1.23 *** src/usr.bin/id/id.c 2015/01/16 06:40:08 1.22 --- src/usr.bin/id/id.c 2015/05/19 16:03:19 1.23 *************** *** 1,4 **** ! /* $OpenBSD: id.c,v 1.22 2015/01/16 06:40:08 deraadt Exp $ */ /*- * Copyright (c) 1991, 1993 --- 1,4 ---- ! /* $OpenBSD: id.c,v 1.23 2015/05/19 16:03:19 millert Exp $ */ /*- * Copyright (c) 1991, 1993 *************** *** 38,43 **** --- 38,44 ---- #include #include #include + #include void current(void); void pretty(struct passwd *); *************** *** 52,63 **** { struct group *gr; struct passwd *pw; ! int Gflag, ch, gflag, nflag, pflag, rflag, uflag; uid_t uid; gid_t gid; const char *opts; ! Gflag = gflag = nflag = pflag = rflag = uflag = 0; if (strcmp(getprogname(), "groups") == 0) { Gflag = 1; --- 53,64 ---- { struct group *gr; struct passwd *pw; ! int ch, cflag, Gflag, gflag, nflag, pflag, rflag, uflag; uid_t uid; gid_t gid; const char *opts; ! cflag = Gflag = gflag = nflag = pflag = rflag = uflag = 0; if (strcmp(getprogname(), "groups") == 0) { Gflag = 1; *************** *** 72,81 **** if (argc > 1) usage(); } else ! opts = "Ggnpru"; while ((ch = getopt(argc, argv, opts)) != -1) switch(ch) { case 'G': Gflag = 1; break; --- 73,85 ---- if (argc > 1) usage(); } else ! opts = "cGgnpru"; while ((ch = getopt(argc, argv, opts)) != -1) switch(ch) { + case 'c': + cflag = 1; + break; case 'G': Gflag = 1; break; *************** *** 101,107 **** argc -= optind; argv += optind; ! switch (Gflag + gflag + pflag + uflag) { case 1: break; case 0: --- 105,111 ---- argc -= optind; argv += optind; ! switch (cflag + Gflag + gflag + pflag + uflag) { case 1: break; case 0: *************** *** 117,122 **** --- 121,136 ---- pw = *argv ? who(*argv) : NULL; + if (cflag) { + if (pw == NULL) + pw = getpwuid(getuid()); + if (pw != NULL && pw->pw_class != NULL && *pw->pw_class != '\0') + (void)printf("%s\n", pw->pw_class); + else + (void)printf("%s\n", LOGIN_DEFCLASS); + exit(0); + } + if (gflag) { gid = pw ? pw->pw_gid : rflag ? getgid() : getegid(); if (nflag && (gr = getgrgid(gid))) *************** *** 190,195 **** --- 204,211 ---- (void)printf("groups\t"); group(NULL, 1); } + if (pw != NULL && pw->pw_class != NULL && *pw->pw_class != '\0') + (void)printf("class\t%s\n", pw->pw_class); } void *************** *** 325,330 **** --- 341,347 ---- (void)fprintf(stderr, "usage: whoami\n"); } else { (void)fprintf(stderr, "usage: id [user]\n"); + (void)fprintf(stderr, " id -c [user]\n"); (void)fprintf(stderr, " id -G [-n] [user]\n"); (void)fprintf(stderr, " id -g [-nr] [user]\n"); (void)fprintf(stderr, " id -p [user]\n");