summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1998-07-08 22:14:38 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1998-07-08 22:14:38 +0000
commitc42d3dfc6a3f99fbbe1a0c87af2f3705ea3ce262 (patch)
treeb2801e83b20e253f4a46ba0d4341d06e3695199c /usr.bin
parent5d7745af6274ad1c61f601a05048c86ed26cf8a9 (diff)
whack kmem gid after kvm_openfiles()
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/fstat/fstat.c8
-rw-r--r--usr.bin/ipcs/ipcs.c5
-rw-r--r--usr.bin/netstat/main.c7
-rw-r--r--usr.bin/top/machine.c5
-rw-r--r--usr.bin/vmstat/vmstat.c13
-rw-r--r--usr.bin/w/w.c7
6 files changed, 34 insertions, 11 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index 508b9b109c3..bdb97c276eb 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fstat.c,v 1.15 1998/07/05 18:42:41 deraadt Exp $ */
+/* $OpenBSD: fstat.c,v 1.16 1998/07/08 22:14:12 deraadt Exp $ */
/*-
* Copyright (c) 1988, 1993
@@ -41,7 +41,7 @@ static char copyright[] =
#ifndef lint
/*static char sccsid[] = "from: @(#)fstat.c 8.1 (Berkeley) 6/6/93";*/
-static char *rcsid = "$OpenBSD: fstat.c,v 1.15 1998/07/05 18:42:41 deraadt Exp $";
+static char *rcsid = "$OpenBSD: fstat.c,v 1.16 1998/07/08 22:14:12 deraadt Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -238,6 +238,10 @@ main(argc, argv)
fprintf(stderr, "fstat: %s\n", buf);
exit(1);
}
+
+ setegid(getgid());
+ setgid(getgid());
+
if ((p = kvm_getprocs(kd, what, arg, &cnt)) == NULL) {
fprintf(stderr, "fstat: %s\n", kvm_geterr(kd));
exit(1);
diff --git a/usr.bin/ipcs/ipcs.c b/usr.bin/ipcs/ipcs.c
index 8882cece4bd..2f2379e4782 100644
--- a/usr.bin/ipcs/ipcs.c
+++ b/usr.bin/ipcs/ipcs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ipcs.c,v 1.7 1997/01/15 23:42:37 millert Exp $ */
+/* $OpenBSD: ipcs.c,v 1.8 1998/07/08 22:14:13 deraadt Exp $ */
/* $NetBSD: ipcs.c,v 1.10.6.1 1996/06/07 01:53:47 thorpej Exp $ */
/*
@@ -199,6 +199,9 @@ main(argc, argv)
if ((kd = kvm_open(namelist, core, NULL, O_RDONLY, "ipcs")) == NULL)
exit(1);
+ setegid(getgid());
+ setgid(getgid());
+
switch (kvm_nlist(kd, symbols)) {
case 0:
break;
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index f035fca2c46..b73a41ebde6 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.13 1998/02/26 10:06:07 peter Exp $ */
+/* $OpenBSD: main.c,v 1.14 1998/07/08 22:14:15 deraadt Exp $ */
/* $NetBSD: main.c,v 1.9 1996/05/07 02:55:02 thorpej Exp $ */
/*
@@ -44,7 +44,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.13 1998/02/26 10:06:07 peter Exp $";
+static char *rcsid = "$OpenBSD: main.c,v 1.14 1998/07/08 22:14:15 deraadt Exp $";
#endif
#endif /* not lint */
@@ -372,6 +372,9 @@ main(argc, argv)
fprintf(stderr, "%s: kvm_open: %s\n", __progname, buf);
exit(1);
}
+ setegid(getgid());
+ setgid(getgid());
+
if (kvm_nlist(kvmd, nl) < 0 || nl[0].n_type == 0) {
if (nlistf)
fprintf(stderr, "%s: %s: no namelist\n", __progname,
diff --git a/usr.bin/top/machine.c b/usr.bin/top/machine.c
index 52eb7112bcf..f112fe7bb02 100644
--- a/usr.bin/top/machine.c
+++ b/usr.bin/top/machine.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machine.c,v 1.9 1998/06/25 16:54:35 deraadt Exp $ */
+/* $OpenBSD: machine.c,v 1.10 1998/07/08 22:14:16 deraadt Exp $ */
/*
* top - a top users display for Unix
@@ -203,6 +203,9 @@ struct statics *statics;
return(-1);
}
+ setegid(getgid());
+ setgid(getgid());
+
/* get the list of symbols we want to access in the kernel */
if (kvm_nlist(kd, nlst) <= 0) {
warnx("nlist failed");
diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c
index 1517c94996f..3a67b89047d 100644
--- a/usr.bin/vmstat/vmstat.c
+++ b/usr.bin/vmstat/vmstat.c
@@ -1,5 +1,5 @@
/* $NetBSD: vmstat.c,v 1.29.4.1 1996/06/05 00:21:05 cgd Exp $ */
-/* $OpenBSD: vmstat.c,v 1.24 1998/05/19 17:38:20 mickey Exp $ */
+/* $OpenBSD: vmstat.c,v 1.25 1998/07/08 22:14:18 deraadt Exp $ */
/*
* Copyright (c) 1980, 1986, 1991, 1993
@@ -185,7 +185,7 @@ main(argc, argv)
register int c, todo;
u_int interval;
int reps;
- char errbuf[_POSIX2_LINE_MAX];
+ char errbuf[_POSIX2_LINE_MAX];
memf = nlistf = NULL;
interval = reps = todo = 0;
@@ -238,7 +238,7 @@ main(argc, argv)
setgid(getgid());
}
- kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
+ kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
if (kd == 0) {
(void)fprintf(stderr,
"vmstat: kvm_openfiles: %s\n", errbuf);
@@ -246,6 +246,10 @@ main(argc, argv)
}
if ((c = kvm_nlist(kd, namelist)) != 0) {
+
+ setegid(getgid());
+ setgid(getgid());
+
if (c > 0) {
(void)fprintf(stderr,
"vmstat: undefined symbols:");
@@ -273,6 +277,9 @@ main(argc, argv)
}
+ setegid(getgid());
+ setgid(getgid());
+
#define BACKWARD_COMPATIBILITY
#ifdef BACKWARD_COMPATIBILITY
if (*argv) {
diff --git a/usr.bin/w/w.c b/usr.bin/w/w.c
index 72c8a01ddf5..72297091204 100644
--- a/usr.bin/w/w.c
+++ b/usr.bin/w/w.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: w.c,v 1.24 1998/02/03 19:18:22 deraadt Exp $ */
+/* $OpenBSD: w.c,v 1.25 1998/07/08 22:14:20 deraadt Exp $ */
/*-
* Copyright (c) 1980, 1991, 1993, 1994
@@ -43,7 +43,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)w.c 8.4 (Berkeley) 4/16/94";
#else
-static char *rcsid = "$OpenBSD: w.c,v 1.24 1998/02/03 19:18:22 deraadt Exp $";
+static char *rcsid = "$OpenBSD: w.c,v 1.25 1998/07/08 22:14:20 deraadt Exp $";
#endif
#endif /* not lint */
@@ -187,6 +187,9 @@ main(argc, argv)
if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == NULL)
errx(1, "%s", errbuf);
+ setegid(getgid());
+ setgid(getgid());
+
(void)time(&now);
if ((ut = fopen(_PATH_UTMP, "r")) == NULL)
err(1, "%s", _PATH_UTMP);