diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-11-16 17:29:44 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2015-11-16 17:29:44 +0000 |
commit | 788d0d4ed3e6d42eadb785bebe25bbbf56488478 (patch) | |
tree | 6a5abcfbd7abd634d12753a7598b0ebc005eba78 | |
parent | f3b52ab4fdac1de692d6541eced0ba69f0449777 (diff) |
delete setuid code (which we disabled in 2002)
ok guenther millert
-rw-r--r-- | usr.sbin/kgmon/Makefile | 10 | ||||
-rw-r--r-- | usr.sbin/kgmon/kgmon.c | 13 |
2 files changed, 3 insertions, 20 deletions
diff --git a/usr.sbin/kgmon/Makefile b/usr.sbin/kgmon/Makefile index 1e6da8f6c18..502568483d9 100644 --- a/usr.sbin/kgmon/Makefile +++ b/usr.sbin/kgmon/Makefile @@ -1,16 +1,8 @@ -# $OpenBSD: Makefile,v 1.4 2002/06/17 07:07:45 deraadt Exp $ +# $OpenBSD: Makefile,v 1.5 2015/11/16 17:29:43 deraadt Exp $ PROG= kgmon MAN= kgmon.8 DPADD= ${LIBKVM} LDADD= -lkvm -# -# This program may safely be run setuid-root to allow non-root -# users to start, stop, and reset profiling buffers. -# However, we choose not to do so. -# -#BINOWN=root -#BINMODE=4555 - .include <bsd.prog.mk> diff --git a/usr.sbin/kgmon/kgmon.c b/usr.sbin/kgmon/kgmon.c index 4e7f570dede..7d53f4b7829 100644 --- a/usr.sbin/kgmon/kgmon.c +++ b/usr.sbin/kgmon/kgmon.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kgmon.c,v 1.22 2015/08/20 22:39:29 deraadt Exp $ */ +/* $OpenBSD: kgmon.c,v 1.23 2015/11/16 17:29:43 deraadt Exp $ */ /* * Copyright (c) 1983, 1992, 1993 @@ -79,7 +79,6 @@ main(int argc, char **argv) char *sys, *kmemf; const char *p; - seteuid(getuid()); kmemf = NULL; sys = NULL; while ((ch = getopt(argc, argv, "M:N:bc:hpr")) != -1) { @@ -192,10 +191,8 @@ openfiles(char *sys, char *kmemf, struct kvmvars *kvp, int cpuid) if (!(bflag || hflag || rflag || (pflag && state == GMON_PROF_ON))) return (O_RDONLY); - (void)seteuid(0); if (sysctl(mib, 4, NULL, NULL, &state, size) >= 0) return (O_RDWR); - (void)seteuid(getuid()); kern_readonly(state); return (O_RDONLY); } @@ -285,12 +282,8 @@ setprof(struct kvmvars *kvp, int cpuid, int state) goto bad; if (oldstate == state) return; - (void)seteuid(0); - if (sysctl(mib, 4, NULL, NULL, &state, sz) >= 0) { - (void)seteuid(getuid()); + if (sysctl(mib, 4, NULL, NULL, &state, sz) >= 0) return; - } - (void)seteuid(getuid()); } else if (kvm_write(kvp->kd, (u_long)&p->state, (void *)&state, sz) == sz) return; @@ -477,7 +470,6 @@ reset(struct kvmvars *kvp, int cpuid) errx(15, "tos zero: %s", kvm_geterr(kvp->kd)); return; } - (void)seteuid(0); mib[0] = CTL_KERN; mib[1] = KERN_PROF; mib[2] = GPROF_COUNT; @@ -490,7 +482,6 @@ reset(struct kvmvars *kvp, int cpuid) mib[2] = GPROF_TOS; if (sysctl(mib, 4, NULL, NULL, zbuf, kvp->gpm.tossize) < 0) err(15, "tos zero"); - (void)seteuid(getuid()); free(zbuf); } |