aboutsummaryrefslogtreecommitdiffstats
path: root/tools/power
diff options
context:
space:
mode:
authorMichal Privoznik <mprivozn@redhat.com>2014-12-14 07:36:52 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-12-19 17:01:03 -0500
commitad1d8313cdeec8bc10cecb2143d047eb565b9f65 (patch)
tree456df70b2c1e6d0df4c94c2e199575b6d687bff5 /tools/power
parent2a813f1aaaf00a7eb65bef8da2fe9fcec0aabaaa (diff)
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 <mprivozn@redhat.com> Acked-by: Thomas Renninger <trenn@suse.de> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'tools/power')
-rw-r--r--tools/power/cpupower/utils/cpupower.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/power/cpupower/utils/cpupower.c b/tools/power/cpupower/utils/cpupower.c
index 7cdcf88659c7..9ea914378985 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[])
199 } 199 }
200 200
201 get_cpu_info(0, &cpupower_cpu_info); 201 get_cpu_info(0, &cpupower_cpu_info);
202 run_as_root = !getuid(); 202 run_as_root = !geteuid();
203 if (run_as_root) { 203 if (run_as_root) {
204 ret = uname(&uts); 204 ret = uname(&uts);
205 if (!ret && !strcmp(uts.machine, "x86_64") && 205 if (!ret && !strcmp(uts.machine, "x86_64") &&