Răsfoiți Sursa

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>
Michal Privoznik 11 ani în urmă
părinte
comite
ad1d8313cd
1 a modificat fișierele cu 1 adăugiri și 1 ștergeri
  1. 1 1
      tools/power/cpupower/utils/cpupower.c

+ 1 - 1
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") &&