Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751402AbaLNVHx (ORCPT ); Sun, 14 Dec 2014 16:07:53 -0500 Received: from v094114.home.net.pl ([79.96.170.134]:58860 "HELO v094114.home.net.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1750986AbaLNVHn (ORCPT ); Sun, 14 Dec 2014 16:07:43 -0500 From: "Rafael J. Wysocki" To: Michal Privoznik Cc: trenn@suse.de, rafael.j.wysocki@intel.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] cpupower: Correctly detect if running as root Date: Sun, 14 Dec 2014 22:29:24 +0100 Message-ID: <1660884.y6rjWabQcf@vostro.rjw.lan> User-Agent: KMail/4.11.5 (Linux/3.16.0-rc5+; KDE/4.11.5; x86_64; ; ) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="utf-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/