sudo does not read /etc/environment on interactive logins (directly, not through pam_env)

Bug #25700 reported by Daniel Hahler
16
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sudo
Unknown
Unknown
sudo (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

sudo (and su) do not work with pam_env.

Adding a line like:
auth required pam_env.so
to /etc/pam.d/sudo should put the environment variables from /etc/environment into the environment of an
interactive session created by "sudo -i" or "su -".

This is especially bad because /etc/environment is the place where Ubuntu defines the charset (with LANG) and
not setting LANG to xx_XX.UTF8 causes the shell (bash) to misbehave on umlauts for example: I cannot type
them on the command line and they're displayed wrong with "ls" and other tools.

Revision history for this message
Martin Pitt (pitti) wrote :

Is that still an issue for you? Normally the sudo shell inherits locale settings from the user's shell, i. e. it preserves the locale.

Changed in sudo:
status: Unconfirmed → Needs Info
Revision history for this message
Sam Morris (yrro) wrote :

According to a thread on sudo-users, sudo < 1.7 doesn't ever call pam_open_session, so PAM session modules such as pam_env, pam_tmpdir and so on are all ignored.

http://www.sudo.ws/pipermail/sudo-users/2005-May/002522.html

Revision history for this message
Daniel Hahler (blueyed) wrote :

I'm not sure if it really preserves the environment using "sudo -i", but I've worked around it by defining LANG in /etc/profile..

Revision history for this message
Martin Pitt (pitti) wrote :

Known upstream and fixed for future 1.7

Changed in sudo:
status: Needs Info → Confirmed
status: Unconfirmed → In Progress
Revision history for this message
Joolz (joolz) wrote :

The problem still exists on Intrepid amd64. I can't believe this isn't fixed yet :(

Revision history for this message
Daniel Hahler (blueyed) wrote :

sudo 1.7.0 has been released on 2008-12-19 and is in Debian unstable already.
Therefore, this is expected to be fixed for Karmic.

Changed in sudo:
status: Confirmed → Triaged
importance: Undecided → Unknown
status: In Progress → Unknown
Revision history for this message
Aidan Furlan (aidan-epochlabs) wrote :

Another workaround is to become root with `sudo su` rather than `sudo -i` or `sudo -u`.

Revision history for this message
Loïc Minier (lool) wrote :

From sudo 1.7.0 WHATSNEW file:
 * Support for /etc/environment on AIX and Linux. If sudo is run
   with the -i flag, the contents of /etc/environment are used to
   populate the new environment that is passed to the command being
   run.

there's a bug in that the contents are taken literally instead of stripping quotes though, bug #387262.

I see some comments requested usage of pam_env in sudo; while that's not entirely unreasonnable, I think it would make it harder to understand why some sudo environment-handlign options don't work as expected.

Changed in sudo (Ubuntu):
status: Triaged → Fix Released
ceg (ceg)
summary: - sudo does not use /etc/environment on interactive logins (through
- pam_env)
+ sudo does not read /etc/environment on interactive logins (directly, not
+ through pam_env)
Revision history for this message
Dimitri John Ledkov (xnox) wrote :

I wonder if this regressed and/or if my configuration is different from default, because sudo -i does not appear to be reading /etc/environment any more.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.