diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2017-05-30 15:07:02 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2017-05-30 15:07:02 +0000 |
commit | d9a2d2303505a59addd4a869993dee1414160e43 (patch) | |
tree | d5f38abb658ece7b699c17bc7f85e696e4cd0e67 /usr.bin/id | |
parent | 0a97d6a9a23aac88beba46db5eb3858bf15198bc (diff) |
id -R: make current rdomain more easily accessible to the shell
ok benno deraadt
Diffstat (limited to 'usr.bin/id')
-rw-r--r-- | usr.bin/id/id.1 | 10 | ||||
-rw-r--r-- | usr.bin/id/id.c | 21 |
2 files changed, 23 insertions, 8 deletions
diff --git a/usr.bin/id/id.1 b/usr.bin/id/id.1 index 35728ee53ee..33a67154487 100644 --- a/usr.bin/id/id.1 +++ b/usr.bin/id/id.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: id.1,v 1.18 2015/05/19 16:03:19 millert Exp $ +.\" $OpenBSD: id.1,v 1.19 2017/05/30 15:07:01 tedu Exp $ .\" $NetBSD: id.1,v 1.5 1995/09/28 08:05:40 perry Exp $ .\" .\" Copyright (c) 1991, 1993, 1994 @@ -33,7 +33,7 @@ .\" .\" @(#)id.1 8.2 (Berkeley) 5/5/94 .\" -.Dd $Mdocdate: May 19 2015 $ +.Dd $Mdocdate: May 30 2017 $ .Dt ID 1 .Os .Sh NAME @@ -57,6 +57,8 @@ .Nm id .Fl u Op Fl nr .Op Ar user +.Nm id +.Fl R .Sh DESCRIPTION The .Nm @@ -115,6 +117,8 @@ If there is a login class specified for the user in the database, it is displayed, preceded by the keyword .Dq class . Each display is on a separate line. +.It Fl R +Display the routing table of the current process. .It Fl r Display the real ID for the .Fl g @@ -137,7 +141,7 @@ utility is compliant with the specification. .Pp The flags -.Op Fl cp +.Op Fl cpR are extensions to that specification. .Sh HISTORY The diff --git a/usr.bin/id/id.c b/usr.bin/id/id.c index ba107339794..e701cb7ae80 100644 --- a/usr.bin/id/id.c +++ b/usr.bin/id/id.c @@ -1,4 +1,4 @@ -/* $OpenBSD: id.c,v 1.26 2015/10/09 01:37:07 deraadt Exp $ */ +/* $OpenBSD: id.c,v 1.27 2017/05/30 15:07:01 tedu Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -29,6 +29,9 @@ * SUCH DAMAGE. */ +#include <sys/types.h> +#include <sys/socket.h> /* getrtable() lives here */ + #include <err.h> #include <errno.h> #include <grp.h> @@ -53,7 +56,7 @@ main(int argc, char *argv[]) { struct group *gr; struct passwd *pw; - int ch, cflag, Gflag, gflag, nflag, pflag, rflag, uflag; + int ch, cflag, Gflag, gflag, nflag, pflag, Rflag, rflag, uflag; uid_t uid; gid_t gid; const char *opts; @@ -61,7 +64,7 @@ main(int argc, char *argv[]) if (pledge("stdio getpw", NULL) == -1) err(1, "pledge"); - cflag = Gflag = gflag = nflag = pflag = rflag = uflag = 0; + cflag = Gflag = gflag = nflag = pflag = Rflag = rflag = uflag = 0; if (strcmp(getprogname(), "groups") == 0) { Gflag = 1; @@ -76,7 +79,7 @@ main(int argc, char *argv[]) if (argc > 1) usage(); } else - opts = "cGgnpru"; + opts = "cGgnpRru"; while ((ch = getopt(argc, argv, opts)) != -1) switch(ch) { @@ -95,6 +98,9 @@ main(int argc, char *argv[]) case 'p': pflag = 1; break; + case 'R': + Rflag = 1; + break; case 'r': rflag = 1; break; @@ -108,7 +114,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - switch (cflag + Gflag + gflag + pflag + uflag) { + switch (cflag + Gflag + gflag + pflag + Rflag + uflag) { case 1: break; case 0: @@ -122,6 +128,11 @@ main(int argc, char *argv[]) if (strcmp(opts, "") != 0 && argc > 1) usage(); + if (Rflag) { + printf("%d\n", getrtable()); + exit(0); + } + pw = *argv ? who(*argv) : NULL; if (cflag) { |