Bugzilla – Bug 279
Please support extending env_keep via command-line or environment
Last modified: 2020-05-07 11:14:41 MDT
From Debian user Josh Triplett: I configure my system such that I have full sudo permissions, so in particular I have permission to use "sudo -E" to preserve the entire environment. I like the idea of filtering the environment via a whitelist, to avoid potentially undesirable behavior when running programs as another user; however, I'd like the ability to extend this whitelist without resorting to the big hammer of -E. Thus, I'd really like a command-line option or (more importantly) an environment variable which would specify additional environment variables to keep, treating them as though specified in /etc/sudoers with env_keep. I could then set that in my .bashrc to preserve some useful environment variables, such as LESSHISTFILE (so I stop getting a root-owned ~/.lesshst in $HOME), LESS, EDITOR, EMAIL, PROMPT_COMMAND, GREP_COLOR, and GREP_OPTIONS.
In sudo 1.8.21 it will be possible to specify a list of environment variables with "--preserve-env=list" for users with "setenv" permissions.
Closing, this was added in sudo 1.8.21.