Small Mosaic


Categories:

books
career
codinghorrors
comics
events
geekstuff
justdont
languages
languages/bash
linkshot
magazines
meta
misctech
movies
nottech
operatingsystems
operatingsystems/linux
operatingsystems/linux/debian
operatingsystems/solaris
paranoidadmin
perl
python
ruby
security
security/apache
security/tools
serversmells
sites
specifications
sysadmin
tools
tools/commandline
tools/firefox
tools/gui
tools/network
tools/online
tools/online/greasemonkey
unixdaemon

Archives:

October 20085
September 20084
August 200812
July 20089
April 20084
March 20081
February 20081
January 200815
August 20072
June 20079
May 20076
April 20078
March 200731
February 20073
January 200721
December 20061
November 20064
October 20066
September 200632
August 200617
July 200614
June 20069
May 200613
March 200611
February 200616
January 200611
December 20051
November 20056
October 200519
September 200525
August 200516
July 200516
June 200513
May 20052
April 200519
March 200531
February 200520
January 200531
December 200421
November 200430
October 200432
September 200418
August 20047
July 200414
June 20045

Fri, 29 Jul 2005

Using sudo Without A Password
If you add a NOPASSWD directive in your sudoers file then you can, as you'd expect from its name, use those commands without a password. This is a pretty useful trick that allows you to set up sudo entries that allow commands to be run with different privileges from cron without requiring the setuid flag. However twice this week I've seen a similar question asked on mailing lists and I thought I'd stick this entry up, hope google indexes it and saves me from ever seeing it again. Yeah right.

When you use sudo and authenticate it sets a short timeout period in which if you use sudo again it won't ask for your password. This is typically a useful feature (for interactive use anyway) but a couple of people seem to follow a series of events that go something like this: sudo visudo (add the NOPASSWD line). sudo "command I want in cron." "Oh look, it worked. Now let me add a cronjob." The next day they (hopefully) notice it didn't work and then ask on a mailing list. Which I'm on.

Now it seems obvious but people don't seem to realise that the trial run is pointless, the timestamp is still valid from when they ran sudo visudo and so sudo WILL NOT PROMPT FOR THE PASSWORD. In order to run a real test you need to use sudo -k to invalidate the timestamp and then rerun the command.

As a closing note adding a sudo -k to your .logout/.bash_logout file can also be a smart thing to do on some systems.

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2005/07/29 14:33 | /tools/commandline | Permanent link to this entry | This entry + same date


books career codinghorrors events geekstuff justdont languages/bash linkshot magazines meta misctech movies nottech operatingsystems/linux operatingsystems/linux/debian operatingsystems/solaris perl python ruby security security/apache security/tools serversmells sites specifications sysadmin tools/commandline tools/firefox tools/gui tools/network tools/online tools/online/greasemonkey unixdaemon

Copyright © 2000-2005 Dean Wilson XML feed logo