From f4f1303f07c7d29c508850b987748c90dd40eabc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 13 Mar 2016 19:03:07 -0400 Subject: [PATCH] Make sure HandleWrite() is run as root. --- apple-ir-control.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apple-ir-control.cc b/apple-ir-control.cc index c92eb80..1a7186e 100644 --- a/apple-ir-control.cc +++ b/apple-ir-control.cc @@ -168,6 +168,11 @@ int HandleRead() { } int HandleWrite(bool enable) { + if (geteuid() != 0) { + ERROR("This operation must be performed as root"); + return EXIT_FAILURE; + } + const CFBooleanRef enabled_value = enable ? kCFBooleanTrue : kCFBooleanFalse; CFPreferencesSetValue(kPrefEnabled, enabled_value, kPrefDomain, -- 2.43.5