sudo in a shell script

Dick Davies rasputnik at
Fri Jul 15 10:17:15 UTC 2005

* Lee Braiden <lee_b at> [0709 11:09]:
> On Friday 15 July 2005 10:50, Behrang Saeedzadeh wrote:
> >  sudo rmmod ipw2200
> >  sudo modprobe ipw2200
> You probably want to use a script which has been setuid'd to root, ratehr than 
> using sudo like this.  Putting passwords into a script file would be terribly 
> insecure, and is unnecessary.

Can you even run suid shellscripts?
I thought that was so inherently full of race conditions that most kernels disallow

This sounds like a job for cron. Just put a script in roots crontab that runs (say)
every five minutes, and restarts the interface if it can't ping a well-known server.
Something like:

*/5 * * * * (/sbin/ping -c 5 yourdnsserver || /sbin/ifconfig eth0 down; /sbin/ifconfig eth0 up ) >/dev/null 2>&1

'Minor skin grafts can be performed on pigs by covering any cuts and
grazes with thin strips of bacon.' -- Phil Wasey, Liverpool
Rasputin :: Jack of All Trades - Master of Nuns
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
URL: <>

More information about the ubuntu-users mailing list