$PATH is taken from login.defs not /etc/environment

Bug #984390 reported by James Troup on 2012-04-17
32
This bug affects 6 people
Affects Status Importance Assigned to Milestone
shadow (Ubuntu)
Medium
Canonical Foundations Team
Precise
Medium
Canonical Foundations Team

Bug Description

$PATH isn't sourced from /etc/environment, instead the version in
/etc/login.defs is used. (The example below comes from a precise install.)

| james@panlong:~$ echo $PATH
| /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
| james@panlong:~$ sudo su - buildd
| buildd@panlong:~$ echo $PATH
| /usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
| buildd@panlong:~$ cat /etc/environment
| PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
| buildd@panlong:~$ grep PATH /etc/login.defs
| # Three items must be defined: MAIL_DIR, ENV_SUPATH, and ENV_PATH.
| # *REQUIRED* The default PATH settings, for superuser and normal users.
| ENV_SUPATH PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
| ENV_PATH PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
| #CRACKLIB_DICTPATH
| buildd@panlong:~$ sudo sed -i -e "s#^ENV_PATH.*#ENV_PATH PATH=/wtf:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games#" /etc/login.defs
| buildd@panlong:~$ logout
| james@panlong:~$ sudo su - buildd
| buildd@panlong:~$ echo $PATH
| /wtf:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
| buildd@panlong:~$

Steve Langasek (vorlon) on 2012-04-17
Changed in shadow (Ubuntu):
status: New → Triaged
importance: Undecided → Medium
assignee: nobody → Canonical Foundations Team (canonical-foundations)
Adam Conrad (adconrad) on 2012-06-15
Changed in shadow (Ubuntu Precise):
status: New → Triaged
assignee: nobody → Canonical Foundations Team (canonical-foundations)
importance: Undecided → Medium
Michael Vogt (mvo) wrote :
tags: added: patch
Michael Vogt (mvo) wrote :

I pushed a slightly modified version of this to https://github.com/shadow-maint/shadow/pull/119

Michael Vogt (mvo) wrote :

Fwiw, I looked at the code of "su.c" from util-linux (because debian/ubuntu may switch to it, see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=833256) and it looks like the bug is not present there. The su-common.c:modify_environment() code will first setenv_path() from login.defs and then do the supam_export_environment() which will override the existing PATH if /etc/environment also defines it.

Michael Vogt (mvo) wrote :

This is now fixed upstream: https://github.com/shadow-maint/shadow/pull/119 - so the next shadow release should have it. This makes me also wonder if we should simply cherry pick it for disco.

Balint Reczey (rbalint) wrote :

@mvo I'm ok with the cherry-pick since I'd like to move over the complete login binary package to util-linux in Debian before merging shadox + util-linux to disco. If you have already tested the cherry-picked version please go ahead otherwise i put it on my TODO list for the next weeks.

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

Other bug subscribers

Remote bug watches

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