summaryrefslogtreecommitdiff
path: root/usr.bin/id
diff options
context:
space:
mode:
authorDavid E. O'Brien <obrien@FreeBSD.org>1998-08-21 06:47:58 +0000
committerDavid E. O'Brien <obrien@FreeBSD.org>1998-08-21 06:47:58 +0000
commitbd7061056e6565e510562969049927bb8f186030 (patch)
treeecf99aa7a9238a73a0b0e1d5febb8b8b6a1d567e /usr.bin/id
parent1eab1be09e20c0766fdd4686a1000890214a07f3 (diff)
downloadsrc-test2-bd7061056e6565e510562969049927bb8f186030.tar.gz
src-test2-bd7061056e6565e510562969049927bb8f186030.zip
Notes
Diffstat (limited to 'usr.bin/id')
-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 f739a1e4fdbc..56fdcb7c9b56 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 0cb0d1f24f1a..c1e5902ab505 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",