summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat/main.c
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2006-05-27 19:16:37 +0000
committerclaudio <claudio@openbsd.org>2006-05-27 19:16:37 +0000
commit0466316983d33dec333d775cea9708504702c7f3 (patch)
tree60eb9918aed51dc6d47c2c1ae710891ea48e70e0 /usr.bin/netstat/main.c
parentadd mpi(4) glue. commented out for now (diff)
downloadwireguard-openbsd-0466316983d33dec333d775cea9708504702c7f3.tar.xz
wireguard-openbsd-0466316983d33dec333d775cea9708504702c7f3.zip
Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat. kvm snooping code is still in and useable. Put it in deraadt@ henning@
Diffstat (limited to 'usr.bin/netstat/main.c')
-rw-r--r--usr.bin/netstat/main.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index bc69a48afa4..d743d41c3b6 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.61 2005/07/04 01:54:10 djm Exp $ */
+/* $OpenBSD: main.c,v 1.62 2006/05/27 19:16:37 claudio Exp $ */
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
/*
@@ -40,7 +40,7 @@ char copyright[] =
#if 0
static char sccsid[] = "from: @(#)main.c 8.4 (Berkeley) 3/1/94";
#else
-static char *rcsid = "$OpenBSD: main.c,v 1.61 2005/07/04 01:54:10 djm Exp $";
+static char *rcsid = "$OpenBSD: main.c,v 1.62 2006/05/27 19:16:37 claudio Exp $";
#endif
#endif /* not lint */
@@ -396,7 +396,16 @@ main(int argc, char *argv[])
if (nlistf != NULL || memf != NULL || Pflag)
if (setresgid(gid, gid, gid) == -1)
err(1, "setresgid");
-
+ if (nlistf == NULL && memf == NULL && rflag && !Aflag) {
+ /* printing the routing table no longer needs kvm */
+ if (setresgid(gid, gid, gid) == -1)
+ err(1, "setresgid");
+ if (sflag)
+ rt_stats(1, 0);
+ else
+ p_rttables(af);
+ exit(0);
+ }
if ((kvmd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY,
buf)) == NULL) {
fprintf(stderr, "%s: kvm_open: %s\n", __progname, buf);
@@ -466,7 +475,7 @@ main(int argc, char *argv[])
}
if (rflag) {
if (sflag)
- rt_stats(nl[N_RTSTAT].n_value);
+ rt_stats(0, nl[N_RTSTAT].n_value);
else
routepr(nl[N_RTREE].n_value);
exit(0);