sudoers: set Defaults secure_path to have sane default settings
authorMichael Prokop <mika@grml.org>
Thu, 2 Apr 2020 09:56:18 +0000 (11:56 +0200)
committerMichael Prokop <mika@grml.org>
Thu, 2 Apr 2020 09:56:18 +0000 (11:56 +0200)
If the user (non-root) doesn't have /sbin:/usr/sbin inside $PATH (as
present when invoking `mksh -l`, which causes /etc/profile to be
sourced and setting $PATH), then executing sudo might fail with:

| $ sudo apt-get install rdesktop
| [...]
| dpkg: warning: 'ldconfig' not found in PATH or not executable
| dpkg: warning: 'start-stop-daemon' not found in PATH or not executable
| dpkg: error: 2 expected programs not found in PATH or not executable
| Note: root's PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin

Ensure to have a working $PATH setting when invoking sudo
by explicitly setting secure_path.

Closes: https://github.com/grml/grml/issues/144

etc/grml/fai/config/files/etc/sudoers/GRMLBASE

index f52c892..7a46342 100644 (file)
@@ -20,6 +20,9 @@ root    ALL=(ALL) ALL
 # WARNING: Never allow external access to the $USERNAME user!!!
 $USERNAME    ALL=NOPASSWD: ALL
 
+# Path used for every command run from sudo
+Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+
 # allow editing of files with editor:
 # $USERNAME ALL=NOPASSWD: sudoedit