summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/vmstat/dkstats.c15
-rw-r--r--usr.sbin/iostat/iostat.c4
2 files changed, 15 insertions, 4 deletions
diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c
index 631138b1960..22af0ffb2a7 100644
--- a/usr.bin/vmstat/dkstats.c
+++ b/usr.bin/vmstat/dkstats.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkstats.c,v 1.19 2002/06/28 22:40:53 deraadt Exp $ */
+/* $OpenBSD: dkstats.c,v 1.20 2002/08/04 00:51:01 deraadt Exp $ */
/* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */
/*
@@ -87,7 +87,7 @@ struct _disk cur, last;
/* Kernel pointers: nlistf and memf defined in calling program. */
#if !defined(NOKVM)
-static kvm_t *kd = NULL;
+extern kvm_t *kd;
#endif
extern char *nlistf;
extern char *memf;
@@ -250,11 +250,20 @@ int select;
if (nlistf != NULL || memf != NULL) {
#if !defined(NOKVM)
+ if (memf != NULL) {
+ setegid(getgid());
+ setgid(getgid());
+ }
+
/* Open the kernel. */
- if ((kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY,
+ if (kd == NULL &&
+ (kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY,
errbuf)) == NULL)
errx(1, "kvm_openfiles: %s", errbuf);
+ setegid(getgid());
+ setgid(getgid());
+
/* Obtain the namelist symbols from the kernel. */
if (kvm_nlist(kd, namelist))
KVM_ERROR("kvm_nlist failed to read symbols.");
diff --git a/usr.sbin/iostat/iostat.c b/usr.sbin/iostat/iostat.c
index 3f44941e35c..bddb43c7227 100644
--- a/usr.sbin/iostat/iostat.c
+++ b/usr.sbin/iostat/iostat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iostat.c,v 1.14 2002/05/30 19:09:05 deraadt Exp $ */
+/* $OpenBSD: iostat.c,v 1.15 2002/08/04 00:51:01 deraadt Exp $ */
/* $NetBSD: iostat.c,v 1.10 1996/10/25 18:21:58 scottr Exp $ */
/*
@@ -91,6 +91,7 @@ static char *rcsid = "$NetBSD: iostat.c,v 1.10 1996/10/25 18:21:58 scottr Exp $"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <kvm.h>
#include "dkstats.h"
@@ -99,6 +100,7 @@ extern struct _disk cur;
extern int dk_ndrive;
/* Namelist and memory files. */
+kvm_t *kd;
char *nlistf, *memf;
int hz, reps, interval;