If I look at the archlinux PKGBUILD for sudo, I do not see –disable-env-reset, which I think controls whether environmental variables are passed or not.
The recommended way of preserving environment variables is to append them to env_keep
If I explicitly set Defaults env_reset and I do not have an env_keep, what is passing DISPLAY and XAUTHORITY when I use sudo?
This is more of an educational question after much research.
Update
After reading archwiki, the man pages for sudoers and pam_env, etc, and the sudo mailing list, I think I got it. When using sudo, the preserved environmental variables are hard-coded.
These can be viewed by
sudo -i
# followed by
sudo -V
Distro’s can vary, so a script may work on one distribution but not another.