summaryrefslogtreecommitdiff
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
parent5d7745af6274ad1c61f601a05048c86ed26cf8a9 (diff)
whack kmem gid after kvm_openfiles()
-rw-r--r--bin/ps/ps.c7
-rw-r--r--sbin/dmesg/dmesg.c8
-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
-rw-r--r--usr.sbin/eeprom/main.c9
-rw-r--r--usr.sbin/iostat/iostat.c6
-rw-r--r--usr.sbin/pstat/pstat.c8
-rw-r--r--usr.sbin/slstats/slstats.c7
-rw-r--r--usr.sbin/trpt/trpt.c5
-rw-r--r--usr.sbin/trsp/trsp.c5
14 files changed, 76 insertions, 24 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index d506c2b20a3..7e84c0038fd 100644
--- a/bin/ps/ps.c
+++ b/bin/ps/ps.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ps.c,v 1.9 1997/08/04 05:37:05 deraadt Exp $ */
+/* $OpenBSD: ps.c,v 1.10 1998/07/08 22:14:25 deraadt Exp $ */
/* $NetBSD: ps.c,v 1.15 1995/05/18 20:33:25 mycroft Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94";
#else
-static char rcsid[] = "$OpenBSD: ps.c,v 1.9 1997/08/04 05:37:05 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: ps.c,v 1.10 1998/07/08 22:14:25 deraadt Exp $";
#endif
#endif /* not lint */
@@ -272,6 +272,9 @@ main(argc, argv)
if (kd == 0)
errx(1, "%s", errbuf);
+ setegid(getgid());
+ setgid(getgid());
+
if (!fmt)
parsefmt(dfmt);
diff --git a/sbin/dmesg/dmesg.c b/sbin/dmesg/dmesg.c
index dd5edb3ba45..7643ce9ce8c 100644
--- a/sbin/dmesg/dmesg.c
+++ b/sbin/dmesg/dmesg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dmesg.c,v 1.6 1998/07/05 18:45:17 deraadt Exp $ */
+/* $OpenBSD: dmesg.c,v 1.7 1998/07/08 22:14:37 deraadt Exp $ */
/* $NetBSD: dmesg.c,v 1.8 1995/03/18 14:54:49 cgd Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
static char sccsid[] = "@(#)dmesg.c 8.1 (Berkeley) 6/5/93";
#else
-static char rcsid[] = "$OpenBSD: dmesg.c,v 1.6 1998/07/05 18:45:17 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: dmesg.c,v 1.7 1998/07/08 22:14:37 deraadt Exp $";
#endif
#endif /* not lint */
@@ -113,6 +113,10 @@ main(argc, argv)
/* Read in kernel message buffer, do sanity checks. */
if ((kd = kvm_open(nlistf, memf, NULL, O_RDONLY, "dmesg")) == NULL)
exit (1);
+
+ setegid(getgid());
+ setgid(getgid());
+
if (kvm_nlist(kd, nl) == -1)
errx(1, "kvm_nlist: %s", kvm_geterr(kd));
if (nl[X_MSGBUF].n_type == 0)
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);
diff --git a/usr.sbin/eeprom/main.c b/usr.sbin/eeprom/main.c
index b5d06d5baff..48fccb98b8c 100644
--- a/usr.sbin/eeprom/main.c
+++ b/usr.sbin/eeprom/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.4 1996/07/22 02:01:50 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.5 1998/07/08 22:13:26 deraadt Exp $ */
/* $NetBSD: main.c,v 1.3 1996/05/16 16:00:55 thorpej Exp $ */
/*-
@@ -161,8 +161,10 @@ main(argc, argv)
argv += optind;
#ifdef __sparc__
- if (system != NULL)
+ if (system != NULL) {
+ setegid(getgid());
setgid(getgid());
+ }
if (getcputype() != CPU_SUN4)
use_openprom = 1;
#endif /* __sparc__ */
@@ -223,6 +225,9 @@ getcputype()
if ((kd = kvm_openfiles(system, NULL, NULL, O_RDONLY, errbuf)) == NULL)
errx(1, "can't open kvm: %s", errbuf);
+ setegid(getgid());
+ setgid(getgid());
+
if (kvm_nlist(kd, nl))
KVM_ABORT(kd, "can't read symbol table");
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 8b3ff50cb46..eb277cdd09e 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iostat.c,v 1.7 1997/01/15 23:44:01 millert Exp $ */
+/* $OpenBSD: iostat.c,v 1.8 1998/07/08 22:13:27 deraadt Exp $ */
/* $NetBSD: iostat.c,v 1.10 1996/10/25 18:21:58 scottr Exp $ */
/*
@@ -182,6 +182,10 @@ main(argc, argv)
}
dkinit(0);
+
+ setegid(getgid());
+ setgid(getgid());
+
dkreadstats();
selectdrives(argc, argv);
diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c
index 5388c6de08e..f53299c9601 100644
--- a/usr.sbin/pstat/pstat.c
+++ b/usr.sbin/pstat/pstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pstat.c,v 1.17 1998/06/25 17:04:29 deraadt Exp $ */
+/* $OpenBSD: pstat.c,v 1.18 1998/07/08 22:13:29 deraadt Exp $ */
/* $NetBSD: pstat.c,v 1.27 1996/10/23 22:50:06 cgd Exp $ */
/*-
@@ -44,7 +44,7 @@ static char copyright[] =
#if 0
from: static char sccsid[] = "@(#)pstat.c 8.9 (Berkeley) 2/16/94";
#else
-static char *rcsid = "$OpenBSD: pstat.c,v 1.17 1998/06/25 17:04:29 deraadt Exp $";
+static char *rcsid = "$OpenBSD: pstat.c,v 1.18 1998/07/08 22:13:29 deraadt Exp $";
#endif
#endif /* not lint */
@@ -218,6 +218,10 @@ main(argc, argv)
if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, buf)) == 0)
errx(1, "kvm_openfiles: %s", buf);
+
+ (void)setegid(getgid());
+ (void)setgid(getgid());
+
if ((ret = kvm_nlist(kd, nl)) != 0) {
if (ret == -1)
errx(1, "kvm_nlist: %s", kvm_geterr(kd));
diff --git a/usr.sbin/slstats/slstats.c b/usr.sbin/slstats/slstats.c
index 0f084193db1..e71609b31fb 100644
--- a/usr.sbin/slstats/slstats.c
+++ b/usr.sbin/slstats/slstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: slstats.c,v 1.8 1998/03/19 07:32:08 deraadt Exp $ */
+/* $OpenBSD: slstats.c,v 1.9 1998/07/08 22:13:30 deraadt Exp $ */
/* $NetBSD: slstats.c,v 1.6.6.1 1996/06/07 01:42:30 thorpej Exp $ */
/*
@@ -25,7 +25,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: slstats.c,v 1.8 1998/03/19 07:32:08 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: slstats.c,v 1.9 1998/07/08 22:13:30 deraadt Exp $";
#endif
#define INET
@@ -143,6 +143,9 @@ main(argc, argv)
if ((kd = kvm_openfiles(kernel, kmemf, NULL, O_RDONLY, errbuf)) == NULL)
errx(1, "can't open kvm: %s", errbuf);
+ setegid(getgid());
+ setgid(getgid());
+
if (kvm_nlist(kd, nl) < 0 || nl[0].n_type == 0)
errx(1, "%s: SLIP symbols not in namelist",
kernel == NULL ? _PATH_UNIX : kernel);
diff --git a/usr.sbin/trpt/trpt.c b/usr.sbin/trpt/trpt.c
index f3f1fd78922..0ab9bff705f 100644
--- a/usr.sbin/trpt/trpt.c
+++ b/usr.sbin/trpt/trpt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trpt.c,v 1.6 1997/09/08 09:23:15 deraadt Exp $ */
+/* $OpenBSD: trpt.c,v 1.7 1998/07/08 22:13:32 deraadt Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -210,6 +210,9 @@ main(argc, argv)
if (kd == NULL)
errx(1, "can't open kmem: %s", errbuf);
+ setegid(getgid());
+ setgid(getgid());
+
if (kvm_nlist(kd, nl))
errx(2, "%s: no namelist", system ? system : _PATH_UNIX);
diff --git a/usr.sbin/trsp/trsp.c b/usr.sbin/trsp/trsp.c
index 74d7a12357e..cc6a7fd9ad8 100644
--- a/usr.sbin/trsp/trsp.c
+++ b/usr.sbin/trsp/trsp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trsp.c,v 1.6 1997/09/12 04:07:23 millert Exp $ */
+/* $OpenBSD: trsp.c,v 1.7 1998/07/08 22:13:33 deraadt Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -212,6 +212,9 @@ main(argc, argv)
if (kd == NULL)
errx(1, "can't open kmem: %s", errbuf);
+ setegid(getgid());
+ setgid(getgid());
+
if (kvm_nlist(kd, nl))
errx(2, "%s: no namelist", system ? system : _PATH_UNIX);