Skip to content

Commit

Permalink
tools / cpupower: Correctly detect if running as root
Browse files Browse the repository at this point in the history
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 <mprivozn@redhat.com>
Acked-by: Thomas Renninger <trenn@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Michal Privoznik authored and Rafael J. Wysocki committed Dec 19, 2014
1 parent 2a813f1 commit ad1d831
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/power/cpupower/utils/cpupower.c
Original file line number Diff line number Diff line change
@@ -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") &&

0 comments on commit ad1d831

Please sign in to comment.