]> git.saurik.com Git - apple/system_cmds.git/blame - msa/VoucherContentSysctl.cpp
system_cmds-670.1.2.tar.gz
[apple/system_cmds.git] / msa / VoucherContentSysctl.cpp
CommitLineData
bd6521f0
A
1//
2// VoucherContentSysctl.cpp
3// system_cmds
4//
5// Created by James McIlree on 4/29/14.
6//
7//
8
9#include "global.h"
10
11VoucherContentSysctl::VoucherContentSysctl(bool is_enabled) :
12 _original_value(0),
13 _new_value(is_enabled ? 1 : 0)
14{
15 size_t original_value_size = sizeof(_original_value);
16 if (sysctlbyname("kern.ipc_voucher_trace_contents", &_original_value, &original_value_size, &_new_value, sizeof(_new_value))) {
17 log_msg(ASL_LEVEL_ERR, "Unable to %s kern.ipc_voucher_trace_contents sysctl", is_enabled ? "set" : "clear");
18 }
19}
20
21VoucherContentSysctl::~VoucherContentSysctl() {
22 if (_original_value != _new_value) {
23 if (sysctlbyname("kern.ipc_voucher_trace_contents", NULL, 0, &_original_value, sizeof(_original_value))) {
24 log_msg(ASL_LEVEL_ERR, "Unable to restore original value of kern.ipc_voucher_trace_contents sysctl");
25 }
26 }
27}