summaryrefslogtreecommitdiffstats
path: root/usr.bin
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>1998-08-21 06:47:58 +0000
committerobrien <obrien@FreeBSD.org>1998-08-21 06:47:58 +0000
commit64c7d46ad00c98ca517d38f516839ce2460b6c1a (patch)
tree3d560c0b002bc45cef3d9330b17f516b3c61789b /usr.bin
parentc237eaa035087aef88dc060f5536924ad7ed27ce (diff)
downloadFreeBSD-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')
-rw-r--r--usr.bin/id/id.17
-rw-r--r--usr.bin/id/id.c39
2 files changed, 40 insertions, 6 deletions
diff --git a/usr.bin/id/id.1 b/usr.bin/id/id.1
index f739a1e..56fdcb7 100644
--- a/usr.bin/id/id.1
+++ b/usr.bin/id/id.1
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)id.1 8.1 (Berkeley) 6/6/93
-.\" $Id: id.1,v 1.3 1997/06/23 04:02:57 steve Exp $
+.\" $Id: id.1,v 1.4 1998/02/28 21:37:54 alex Exp $
.\"
.Dd June 6, 1993
.Dt ID 1
@@ -48,6 +48,9 @@
.Fl G Op Fl n
.Op Ar user
.Nm id
+.Fl P
+.Op Ar user
+.Nm id
.Fl g Op Fl nr
.Op Ar user
.Nm id
@@ -74,6 +77,8 @@ The options are as follows:
.It Fl G
Display the different group IDs (effective, real and supplementary)
as white-space separated numbers, in no particular order.
+.It Fl P
+Display the id as a password file entry.
.It Fl g
Display the effective group ID as a number.
.It Fl n
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",
OpenPOWER on IntegriCloud