diff options
author | deraadt <deraadt@openbsd.org> | 2015-10-28 12:25:13 +0000 |
---|---|---|
committer | deraadt <deraadt@openbsd.org> | 2015-10-28 12:25:13 +0000 |
commit | 372b8ca349db272687cb8b6262eac1645763116d (patch) | |
tree | 2ace4d0451c29ad57b3f32ba4be914c9ea9bf598 | |
parent | Prevent F_SETOWN, unless a "proc" pledge was made. (diff) | |
download | wireguard-openbsd-372b8ca349db272687cb8b6262eac1645763116d.tar.xz wireguard-openbsd-372b8ca349db272687cb8b6262eac1645763116d.zip |
By hoisting sysctl hw.cpuspeed towards the top, it is possible to
pledge "stdio rpath wpath cpath unix". I wonder what we can do in
apmd...
-rw-r--r-- | usr.sbin/apm/apm.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.sbin/apm/apm.c b/usr.sbin/apm/apm.c index 7f2aa7a860a..f8d602d79be 100644 --- a/usr.sbin/apm/apm.c +++ b/usr.sbin/apm/apm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: apm.c,v 1.30 2015/10/11 20:23:49 guenther Exp $ */ +/* $OpenBSD: apm.c,v 1.31 2015/10/28 12:25:13 deraadt Exp $ */ /* * Copyright (c) 1996 John T. Kohl @@ -157,6 +157,12 @@ main(int argc, char *argv[]) int cpuspeed_mib[] = { CTL_HW, HW_CPUSPEED }, cpuspeed; size_t cpuspeed_sz = sizeof(cpuspeed); + if (sysctl(cpuspeed_mib, 2, &cpuspeed, &cpuspeed_sz, NULL, 0) < 0) + err(1, "sysctl hw.cpuspeed"); + + if (pledge("stdio rpath wpath cpath unix", NULL) == -1) + err(1, "pledge"); + while ((ch = getopt(argc, argv, "ACHLlmbvaPSzZf:")) != -1) { switch (ch) { case 'v': @@ -257,10 +263,7 @@ main(int argc, char *argv[]) reply.batterystate.battery_state = APM_BATT_UNKNOWN; reply.batterystate.ac_state = APM_AC_UNKNOWN; reply.perfmode = PERF_MANUAL; - if (sysctl(cpuspeed_mib, 2, &cpuspeed, &cpuspeed_sz, NULL, 0) < 0) - reply.cpuspeed = 0; - else - reply.cpuspeed = cpuspeed; + reply.cpuspeed = cpuspeed; switch (action) { case SETPERF_LOW: |