提交 ad1d8313 编写于 作者: M Michal Privoznik 提交者: Rafael J. Wysocki

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: NMichal Privoznik <mprivozn@redhat.com>
Acked-by: NThomas Renninger <trenn@suse.de>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 2a813f1a
...@@ -199,7 +199,7 @@ int main(int argc, const char *argv[]) ...@@ -199,7 +199,7 @@ int main(int argc, const char *argv[])
} }
get_cpu_info(0, &cpupower_cpu_info); get_cpu_info(0, &cpupower_cpu_info);
run_as_root = !getuid(); run_as_root = !geteuid();
if (run_as_root) { if (run_as_root) {
ret = uname(&uts); ret = uname(&uts);
if (!ret && !strcmp(uts.machine, "x86_64") && if (!ret && !strcmp(uts.machine, "x86_64") &&
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册