diff options
author | obrien <obrien@FreeBSD.org> | 1998-08-21 06:47:58 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 1998-08-21 06:47:58 +0000 |
commit | 64c7d46ad00c98ca517d38f516839ce2460b6c1a (patch) | |
tree | 3d560c0b002bc45cef3d9330b17f516b3c61789b /usr.bin/id/id.c | |
parent | c237eaa035087aef88dc060f5536924ad7ed27ce (diff) | |
download | FreeBSD-src-64c7d46ad00c98ca517d38f516839ce2460b6c1a.zip FreeBSD-src-64c7d46ad00c98ca517d38f516839ce2460b6c1a.tar.gz |
Add "-P" display the id as a password file entry.
Submitted by: terry
Diffstat (limited to 'usr.bin/id/id.c')
-rw-r--r-- | usr.bin/id/id.c | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c index 0cb0d1f..c1e5902 100644 --- a/usr.bin/id/id.c +++ b/usr.bin/id/id.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)id.c 8.2 (Berkeley) 2/16/94"; #endif static const char rcsid[] = - "$Id: id.c,v 1.5 1997/07/15 09:48:49 charnier Exp $"; + "$Id: id.c,v 1.6 1998/02/18 17:35:16 steve Exp $"; #endif /* not lint */ #include <sys/param.h> @@ -56,6 +56,7 @@ static const char rcsid[] = #include <unistd.h> void current __P((void)); +void pline __P((struct passwd *)); void pretty __P((struct passwd *)); void group __P((struct passwd *, int)); void usage __P((void)); @@ -70,14 +71,17 @@ main(argc, argv) { struct group *gr; struct passwd *pw; - int Gflag, ch, gflag, id, nflag, pflag, rflag, uflag; + int Gflag, Pflag, ch, gflag, id, nflag, pflag, rflag, uflag; - Gflag = gflag = nflag = pflag = rflag = uflag = 0; - while ((ch = getopt(argc, argv, "Ggnpru")) != -1) + Gflag = Pflag = gflag = nflag = pflag = rflag = uflag = 0; + while ((ch = getopt(argc, argv, "PGgnpru")) != -1) switch(ch) { case 'G': Gflag = 1; break; + case 'P': + Pflag = 1; + break; case 'g': gflag = 1; break; @@ -100,7 +104,7 @@ main(argc, argv) argc -= optind; argv += optind; - switch(Gflag + gflag + pflag + uflag) { + switch(Gflag + Pflag + gflag + pflag + uflag) { case 1: break; case 0: @@ -136,6 +140,11 @@ main(argc, argv) exit(0); } + if (Pflag) { + pline(pw); + exit(0); + } + if (pflag) { pretty(pw); exit(0); @@ -315,6 +324,26 @@ who(u) } void +pline(pw) + struct passwd *pw; +{ + struct group *gr; + u_int eid, rid; + char *login; + + if (!pw) { + if ((pw = getpwuid(rid = getuid())) == NULL) + err(1, "getpwuid"); + } + + (void)printf("%s:%s:%d:%d:%s:%d:%d:%s:%s:%s\n", pw->pw_name, + pw->pw_passwd, pw->pw_uid, pw->pw_gid, pw->pw_class, + pw->pw_change, pw->pw_expire, pw->pw_gecos, + pw->pw_dir, pw->pw_shell); +} + + +void usage() { (void)fprintf(stderr, "%s\n%s\n%s\n%s\n", |