Sudo notes

From Brandonhutchinson.com

Revision as of 15:12, 13 June 2008 by Hutch (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

sudo ignores current directory in PATH by default

  • By default, the current directory in a user's PATH is ignored.
       ignore_dot  If set, sudo will ignore ’.’ or ’’ (current dir) in the
                   PATH environment variable; the PATH itself is not modified.
                   This flag is on by default.  Currently, while it is possi-
                   ble to set ignore_dot in sudoers, its value is not used.
                   This option should be considered read-only (it will be
                   fixed in a future version of sudo).

Example:

$ sudo -l
User hutchib may run the following commands on this host:
    (ALL) NOPASSWD: /files1/AdventNet/ME/*/bin/*
    (ALL) NOPASSWD: /etc/rc.d/init.d/netflowanalyzer
    (ALL) NOPASSWD: /sbin/service netflowanalyzer *
$ cd /files1/AdventNet/ME/NetFlow/bin
$ sudo ./linkAsService.sh
(Prompts for password)
$ sudo linkAsService.sh

As a workaround, make sure the appropriate directories are in your PATH and execute the command without the ./

$ PATH=$PATH:$(pwd) sudo linkAsService.sh
(Works without prompting for password)
Personal tools