Remove setresguid since it is no longer needed.
authorlum <lum@openbsd.org>
Tue, 20 Jul 2010 19:43:19 +0000 (19:43 +0000)
committerlum <lum@openbsd.org>
Tue, 20 Jul 2010 19:43:19 +0000 (19:43 +0000)
ok matthew@ millert@ deraadt@

usr.bin/vmstat/dkstats.c
usr.bin/vmstat/vmstat.c

index a16c938..f7877d5 100644 (file)
@@ -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.");
index 288e707..c6d968e 100644 (file)
@@ -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;