public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cpupower: Correctly detect if running as root
@ 2014-12-14 12:36 Michal Privoznik
  2014-12-14 21:29 ` Rafael J. Wysocki
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Privoznik @ 2014-12-14 12:36 UTC (permalink / raw)
  To: trenn; +Cc: rafael.j.wysocki, linux-pm, linux-kernel

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>
---
 tools/power/cpupower/utils/cpupower.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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") &&
-- 
2.0.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* [PATCH] cpupower: Correctly detect if running as root
@ 2014-12-24 11:08 Michal Privoznik
  0 siblings, 0 replies; 4+ messages in thread
From: Michal Privoznik @ 2014-12-24 11:08 UTC (permalink / raw)
  To: rjw; +Cc: rafael.j.wysocki, linux-pm, linux-kernel

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>
---
 tools/power/cpupower/utils/cpupower.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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") &&
-- 
2.0.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-24 11:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-14 12:36 [PATCH] cpupower: Correctly detect if running as root Michal Privoznik
2014-12-14 21:29 ` Rafael J. Wysocki
2014-12-17 16:22   ` Thomas Renninger
  -- strict thread matches above, loose matches on Subject: below --
2014-12-24 11:08 Michal Privoznik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox