Bugzilla – Bug 359
Should strip quotes when importing /etc/environment
Last modified: 2009-06-24 10:53:40 MDT
Created attachment 257 [details] Strip quotes like pam_env when parsing /etc/environment Hi bug #83 proposed importing env vars from /etc/environment. This was impleneted in some 1.7.x release and is now causing loads of warnings when using sudo -i on Ubuntu systems. Upon installation, /etc/environment is usually created with quoted-vars such as PATH, LANG or LANGUAGE. When sudo imports these literally, it results in LANG being set to e.g. "fr_FR.UTF-8" literally, that is with the double quotes. This is unfortunate as it actually breaks locale and causes warnings everytime you launch a Perl program. /etc/environment is usually read by PAN in Ubuntu systems (via pam_env), but I understand this could be confusing / impractical to use in sudo's PAM file as this means two different binaries set environment variables. So instead I rewrote pam_env's quote-striping code for sudo and will attach a patch. Launchpad bug: https://bugs.launchpad.net/ubuntu/+source/sudo/+bug/387262 Thanks,
NB: the attached patch is against CVS and differs slightly from the one in Launchpad. With LANG="fr_FR.UTF-8 in /etc/environment, before the change, with Ubuntu's sudo: sudo -i perl -e 1 perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LANGUAGE = "fr_FR:fr:en_GB:en", LC_ALL = (unset), LANG = ""fr_FR.UTF-8"" are supported and installed on your system. perl: warning: Falling back to the standard locale ("C"). after the change: ./sudo -i perl -e 1 (no output) I compiled a larger set of tests in the Launchpad bug.
I took a slightly different approach but the result is the same. The change will be in sudo 1.7.2, for which there should be a release candidate next week.
FYI: ftp://ftp.sudo.ws/pub/sudo/beta/sudo-1.7.2b3.tar.gz is now available which contains the fix.
Thanks for the quick review, rewrite, and release!