[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Problems with sudo PATH



On Thu, Dec 29, 2011 at 05:15:19PM +0100, Steve Kreyer wrote:
> after an update of my Debian system some time ago I've encountered
> some problems with sudo. In particular sudo doesn't seem to
> recognize any commands located in /sbin or /usr/sbin.
[…]
> What could be wrong here? Can I somehow see the content of $PATH
> within the sudo environment? AFAIK "sudo echo $PATH" fails because
> $PATH is evaluated by the shell before sudo is called.

This has bitten me on a few systems as well.  I think it essentially
amounts to having

Defaults	env_reset
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

at the start of your /etc/sudoers.  This wasn't required in earlier
versions, but if you choose not to upgrade /etc/sudoers (quite
sensible, since you would loose root access), then it no longer
sets a full path.

Note that a minimal sudoers is this:
------
Defaults	env_reset
Defaults	secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
root	ALL=(ALL:ALL) ALL
%sudo	ALL=(ALL:ALL) ALL
#includedir /etc/sudoers.d
------

i.e. add yourself to group sudo rather than having to add each user
separately.


Regards,
Roger

-- 
  .''`.  Roger Leigh
 : :' :  Debian GNU/Linux             http://people.debian.org/~rleigh/
 `. `'   Printing on GNU/Linux?       http://gutenprint.sourceforge.net/
   `-    GPG Public Key: 0x25BFB848   Please GPG sign your mail.


Reply to: