Bug 359

Summary: Should strip quotes when importing /etc/environment
Product: Sudo Reporter: Loïc Minier <lool>
Component: SudoAssignee: Todd C. Miller <Todd.Miller>
Status: RESOLVED FIXED    
Severity: normal    
Priority: low    
Version: 1.7.1   
Hardware: PC   
OS: Linux   
Attachments: Strip quotes like pam_env when parsing /etc/environment

Description Loïc Minier 2009-06-22 11:37:32 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,
Comment 1 Loïc Minier 2009-06-22 11:46:08 MDT
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.
Comment 2 Todd C. Miller 2009-06-23 14:26:05 MDT
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.
Comment 3 Todd C. Miller 2009-06-24 10:02:49 MDT
FYI: ftp://ftp.sudo.ws/pub/sudo/beta/sudo-1.7.2b3.tar.gz is now available which contains the fix.
Comment 4 Loïc Minier 2009-06-24 10:53:40 MDT
Thanks for the quick review, rewrite, and release!