From 5d88d53711bb0fbac3ea7cc894af7521db3cb0db Mon Sep 17 00:00:00 2001 From: lum Date: Tue, 20 Jul 2010 19:43:19 +0000 Subject: [PATCH] Remove setresguid since it is no longer needed. ok matthew@ millert@ deraadt@ --- usr.bin/vmstat/dkstats.c | 12 +----------- usr.bin/vmstat/vmstat.c | 19 ++----------------- 2 files changed, 3 insertions(+), 28 deletions(-) diff --git a/usr.bin/vmstat/dkstats.c b/usr.bin/vmstat/dkstats.c index a16c9385772..f7877d52c4b 100644 --- a/usr.bin/vmstat/dkstats.c +++ b/usr.bin/vmstat/dkstats.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dkstats.c,v 1.33 2007/11/26 09:28:34 martynas Exp $ */ +/* $OpenBSD: dkstats.c,v 1.34 2010/07/20 19:43:19 lum Exp $ */ /* $NetBSD: dkstats.c,v 1.1 1996/05/10 23:19:27 thorpej Exp $ */ /* @@ -431,28 +431,18 @@ dkinit(int sel) size_t size; struct clockinfo clkinfo; char *disknames, *name, *bufpp; - gid_t gid; if (once) return(1); - gid = getgid(); if (nlistf != NULL || memf != NULL) { #if !defined(NOKVM) - if (memf != NULL) - if (setresgid(gid, gid, gid) == -1) - err(1, "setresgid"); - /* Open the kernel. */ if (kd == NULL && (kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf)) == NULL) errx(1, "kvm_openfiles: %s", errbuf); - if (memf == NULL) - if (setresgid(gid, gid, gid) == -1) - err(1, "setresgid"); - /* Obtain the namelist symbols from the kernel. */ if (kvm_nlist(kd, namelist)) KVM_ERROR("kvm_nlist failed to read symbols."); diff --git a/usr.bin/vmstat/vmstat.c b/usr.bin/vmstat/vmstat.c index 288e70795e8..c6d968e2362 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.114 2009/11/22 22:22:14 tedu Exp $ */ +/* $OpenBSD: vmstat.c,v 1.115 2010/07/20 19:43:19 lum Exp $ */ /* * Copyright (c) 1980, 1986, 1991, 1993 @@ -138,7 +138,6 @@ main(int argc, char *argv[]) const char *errstr; u_int interval = 0; size_t size; - gid_t gid; while ((c = getopt(argc, argv, "c:fiM:mN:stw:vz")) != -1) { switch (c) { @@ -188,25 +187,12 @@ main(int argc, char *argv[]) if (todo == 0) todo = VMSTAT; - gid = getgid(); if (nlistf != NULL || memf != NULL) { - if (setresgid(gid, gid, gid) == -1) - err(1, "setresgid"); - } - /* - * Discard setgid privileges if not the running kernel so that bad - * guys can't print interesting stuff from kernel memory. - */ - if (nlistf != NULL || memf != NULL) { kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf); if (kd == 0) errx(1, "kvm_openfiles: %s", errbuf); - if (nlistf == NULL && memf == NULL) - if (setresgid(gid, gid, gid) == -1) - err(1, "setresgid"); - if ((c = kvm_nlist(kd, namelist)) != 0) { if (c > 0) { @@ -223,8 +209,7 @@ main(int argc, char *argv[]) } else errx(1, "kvm_nlist: %s", kvm_geterr(kd)); } - } else if (setresgid(gid, gid, gid) == -1) - err(1, "setresgid"); + } mib[0] = CTL_HW; mib[1] = HW_NCPU; -- 2.20.1