From 6ff7f5e25b0d9c231df1d3921f16fb0cc34e698e Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 3 Jul 2009 19:37:22 +0000 Subject: [PATCH] Exit immediately if not root. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@5749 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 3 +++ prog/pwm/pwmconfig | 15 +++++++-------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGES b/CHANGES index 1377bf03..62cafd60 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ lm-sensors CHANGES file ----------------------- +SVN-HEAD + pwmconfig: Exit immediately if not root + 3.1.1 (2009-06-21) isadump: Use geteuid instead of getuid so that setuid bit works isaset: Use geteuid instead of getuid so that setuid bit works diff --git a/prog/pwm/pwmconfig b/prog/pwm/pwmconfig index fe448ad2..a88b87b2 100755 --- a/prog/pwm/pwmconfig +++ b/prog/pwm/pwmconfig @@ -42,6 +42,12 @@ then exit 1 fi +if [ "`id -u`" != "0" ] +then + echo "You need to be root to run this script." + exit 1 +fi + echo "# pwmconfig revision $REVISION ($REVDATE)" echo 'This program will search your sensors for pulse width modulation (pwm)' echo 'controls, and test each one to see if it controls a fan on' @@ -258,7 +264,7 @@ do GOODPWM="$GOODPWM $i" fi else - NOTROOT=1 + echo "Can't write to $i, skipping." fi done @@ -302,13 +308,6 @@ then exit 1 fi -if [ "$NOTROOT" = "1" ] -then - echo 'As you are not root, we cannot write the PWM settings.' - echo 'Please run as root to continue.' - exit 1 -fi - echo 'Warning!!! This program will stop your fans, one at a time,' echo "for approximately $DELAY seconds each!!!" echo 'This may cause your processor temperature to rise!!!'