From: Michal Privoznik Date: Sun, 14 Dec 2014 12:36:52 +0000 (+0100) Subject: tools / cpupower: Correctly detect if running as root X-Git-Tag: v4.14-rc1~6200^2~1^4~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ad1d8313cdeec8bc10cecb2143d047eb565b9f65;p=platform%2Fkernel%2Flinux-rpi.git tools / cpupower: Correctly detect if running as root Some operations, like frequency-set, need root privileges. However, the way that this is detected is not correct. The getuid() is called, while in fact geteuid() should be. This way we can allow distributions or users to set SETUID flags on the cpupower binary if they want to and let regular users change the cpu frequency governor. Signed-off-by: Michal Privoznik Acked-by: Thomas Renninger Signed-off-by: Rafael J. Wysocki --- diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c index 7cdcf88..9ea9143 100644 --- a/tools/power/cpupower/utils/cpupower.c +++ b/tools/power/cpupower/utils/cpupower.c @@ -199,7 +199,7 @@ int main(int argc, const char *argv[]) } get_cpu_info(0, &cpupower_cpu_info); - run_as_root = !getuid(); + run_as_root = !geteuid(); if (run_as_root) { ret = uname(&uts); if (!ret && !strcmp(uts.machine, "x86_64") &&