Fedora Linux Support Community & Resources Center
  #1  
Old 19th May 2012, 11:03 PM
idoitprone Offline
Registered User
 
Join Date: May 2012
Location: nowhere
Posts: 13
linuxfirefox
How to configure $PATH for sudo

I have a custom script that needs to be run as root

I have put it in /usr/local/sbin

Where do I configure root's $PATH or make my custom $PATH system wide.

The script itself is not anything special

I just have light sensative eyes that force to wish that I had a very dim screen.
Code:
cat /usr/local/sbin/backlight 
#!/bin/sh
MAX=976
MIN=0
SCREEN_BRIGHTNESS=/sys/class/backlight/intel_backlight/brightness
if test $# -gt 1;
   then
      echo "Usage: backlight [ARGS]" 1>&2
      echo "Arguments:"  1>&2
      echo "Number between $MIN and $MAX" 1>&2
      echo "Options:" 1>&2     
      echo "-h, --help    Print help message" 1>&2 
      exit 1
fi
if test $# -eq 0
   then
      cat "$SCREEN_BRIGHTNESS"
      exit 0
fi
if test $1 = '-h' -o '--help' = $1
   then
      echo "This number changes the screen bightness"
      echo "Usage: backlight NUMBER"
      echo "Number is between $MIN and $MAX"
fi
if test `whoami` != "root"
   then
      echo "You have to be root to perform this command" 1>&2
      exit 3
fi     
if test $1 -le $MIN -o $1 -gt $MAX;
   then
     echo "Numbers must be between $MIN and $MAX" 1>&2
     exit 2
fi
sh -c "echo $1 > "$SCREEN_BRIGHTNESS"
If I run it
I get
Code:
sudo: backlight: command not found
Reply With Quote
  #2  
Old 20th May 2012, 12:06 AM
scott32746 Offline
Registered User
 
Join Date: Jun 2007
Location: Lake Mary, Florida
Age: 50
Posts: 1,088
windows_xp_2003firefox
Re: How to configure $PATH for sudo

Hello,

You can place the path in sudo

# visudo

all types of options best to read what you would like to use
Reply With Quote
  #3  
Old 20th May 2012, 02:01 AM
idoitprone Offline
Registered User
 
Join Date: May 2012
Location: nowhere
Posts: 13
linuxfirefox
Re: How to configure $PATH for sudo

Quote:
Originally Posted by scott32746 View Post
Hello,

You can place the path in sudo

# visudo

all types of options best to read what you would like to use
thnks

I completely forgot about that command
Reply With Quote
  #4  
Old 20th May 2012, 02:30 AM
jpollard Offline
Registered User
 
Join Date: Aug 2009
Location: Waldorf, Maryland
Posts: 6,852
linuxfirefox
Re: How to configure $PATH for sudo

Note - I believe your script is insecure - $1 may have other special characters embedded that allow escapes from the script.
Reply With Quote
  #5  
Old 20th May 2012, 02:58 AM
idoitprone Offline
Registered User
 
Join Date: May 2012
Location: nowhere
Posts: 13
linuxfirefox
Re: How to configure $PATH for sudo

Quote:
Originally Posted by jpollard View Post
Note - I believe your script is insecure - $1 may have other special characters embedded that allow escapes from the script.
really oh

hmmmmm i was considering adding a test to see $1 was a number. Trying to understand all these special characters of bash is confusing.

Last edited by idoitprone; 20th May 2012 at 03:02 AM.
Reply With Quote
Reply

Tags
$path, configure, sudo

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] F16 - sudo vim /path/to/file reads root's .vimrc Marseille07 Using Fedora 6 5th March 2012 03:49 AM
PATH variable for sudo command gbuergisser Using Fedora 3 6th January 2012 12:52 PM
sudo & PATH halfshark Security and Privacy 6 29th April 2005 09:45 PM
X Configure fails, how to set path aakhws Using Fedora 0 19th February 2005 05:12 PM
X path at ./configure [M]eow Installation, Upgrades and Live Media 3 27th July 2004 01:22 AM


Current GMT-time: 10:10 (Monday, 22-09-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat