-.\" $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
.\"
.\" @(#)id.1 8.2 (Berkeley) 5/5/94
.\"
-.Dd $Mdocdate: May 19 2015 $
+.Dd $Mdocdate: May 30 2017 $
.Dt ID 1
.Os
.Sh NAME
.Nm id
.Fl u Op Fl nr
.Op Ar user
+.Nm id
+.Fl R
.Sh DESCRIPTION
The
.Nm
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
specification.
.Pp
The flags
-.Op Fl cp
+.Op Fl cpR
are extensions to that specification.
.Sh HISTORY
The
-/* $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
* SUCH DAMAGE.
*/
+#include <sys/types.h>
+#include <sys/socket.h> /* getrtable() lives here */
+
#include <err.h>
#include <errno.h>
#include <grp.h>
{
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;
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;
if (argc > 1)
usage();
} else
- opts = "cGgnpru";
+ opts = "cGgnpRru";
while ((ch = getopt(argc, argv, opts)) != -1)
switch(ch) {
case 'p':
pflag = 1;
break;
+ case 'R':
+ Rflag = 1;
+ break;
case 'r':
rflag = 1;
break;
argc -= optind;
argv += optind;
- switch (cflag + Gflag + gflag + pflag + uflag) {
+ switch (cflag + Gflag + gflag + pflag + Rflag + uflag) {
case 1:
break;
case 0:
if (strcmp(opts, "") != 0 && argc > 1)
usage();
+ if (Rflag) {
+ printf("%d\n", getrtable());
+ exit(0);
+ }
+
pw = *argv ? who(*argv) : NULL;
if (cflag) {