linux-kernel.vger.kernel.org archive mirror
 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

* Re: [PATCH] cpupower: Correctly detect if running as root
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Rafael J. Wysocki @ 2014-12-14 21:29 UTC (permalink / raw)
  To: Michal Privoznik; +Cc: trenn, rafael.j.wysocki, linux-pm, linux-kernel

On Sunday, December 14, 2014 01:36:52 PM Michal Privoznik wrote:
> 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>

An ACK from Thomas is needed.

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

-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

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

* Re: [PATCH] cpupower: Correctly detect if running as root
  2014-12-14 21:29 ` Rafael J. Wysocki
@ 2014-12-17 16:22   ` Thomas Renninger
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Renninger @ 2014-12-17 16:22 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Michal Privoznik, rafael.j.wysocki, linux-pm, linux-kernel

On Sunday, December 14, 2014 10:29:24 PM Rafael J. Wysocki wrote:
> On Sunday, December 14, 2014 01:36:52 PM Michal Privoznik wrote:
> > 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>
> 
> An ACK from Thomas is needed.
Patch is correct, Thanks!

Acked-by: Thomas Renninger <trenn@suse.de>

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


^ permalink raw reply	[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
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;
as well as URLs for NNTP newsgroup(s).