Arch Linux

Please read this before reporting a bug:
https://wiki.archlinux.org/title/Bug_reporting_guidelines

Do NOT report bugs when a package is just outdated, or it is in the AUR. Use the 'flag out of date' link on the package page, or the Mailing List.

REPEAT: Do NOT report bugs for outdated packages!
Tasklist

FS#16991 - [slim] causes pam_env to read garbage into environment

Attached to Project: Arch Linux
Opened by Jay Tanzman (jt512) - Tuesday, 03 November 2009, 17:36 GMT
Last edited by Andrea Scarpino (BaSh) - Saturday, 07 November 2009, 01:44 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To Andrea Scarpino (BaSh)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

Description:
/etc/pam.d/slim contains the following line:

session required pam_env.so readenv=1 envfile=/etc/profile.d/local
e.sh

However, the contents of /etc/profile.d/locale.sh, written by /etc/rc.sysinit, are as follows:

export LANG=en_US.utf8
if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e%%G"; fi
if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e(K"; fi

And pam_env attempts to parse these lines as if they were in KEY=VAL format, resulting in garbage being read into the environment. One consequence of this is that it breaks the "at" daemon for users who have logged in using SLiM.

Additional info:
* package version(s) slim-1.3.1-4
* See attached output of `env` and `at -c`

Steps to reproduce:
1. Verify that /etc/profile.d/locale.sh contains lines similar to those above. If not, then see /etc/rc.sysinit.
2. Log in, as ordinary user, using SLiM
3. $ env (Output should contain garbage from /etc/profile.d/locale.sh)
4. $ at now + 1 min
at> echo Hello World
at> Ctl-D
5. $ at -c <job #> (Output should contain garbage, as above)
6. After 1 min, check email. Should receive mail containing error message from 'at' job: "sh: line 58: syntax error: unexpected end of file."

Workaround: Set readenv=0 in /etc/pam.d/slim
   env.txt (2.6 KiB)
   at.txt (3.9 KiB)
This task depends upon

Closed by  Andrea Scarpino (BaSh)
Saturday, 07 November 2009, 01:44 GMT
Reason for closing:  Fixed
Additional comments about closing:  slim 1.3.1-5
Comment by Jay Tanzman (jt512) - Tuesday, 03 November 2009, 17:38 GMT
pam version 1.0.4-2
at version 3.1.10.2-1
Comment by Andrea Scarpino (BaSh) - Tuesday, 03 November 2009, 19:53 GMT
are you sure readenv=0 will not break anything else?
if I don't wrong it is needed to parse environment file
Comment by Jay Tanzman (jt512) - Tuesday, 03 November 2009, 23:08 GMT
I'm just a user, but isn't the correct environment file /etc/environment? If so, mine is empty. Perhaps the better solution would be to set "envfile" to the right file.

Comment by Andrea Scarpino (BaSh) - Thursday, 05 November 2009, 12:04 GMT
can you try with this slim pam configuration?
   slim.pam (0.3 KiB)
Comment by Alex Ferguson (B_Lizzard) - Thursday, 05 November 2009, 14:26 GMT
OK, this line was added by bug  FS#16282 .

Before that line was added, slim did not pass LANG properly, thus creating problems for applications that needed it set.
The problem is that along with parsing the first line, "LANG = ...", it also parses the next lines.

A workaround would be creating a file containing only the necessary assignments for setting LANG properly within slim.
Either that or modifying the actual source code.
Comment by Jay Tanzman (jt512) - Thursday, 05 November 2009, 18:40 GMT
@Andrea: With your slim.pam file, SLIM never asks for my password, and I can't log in.

@Alex: On my computer there doesn't seem to be a problem with how SLIM handles the LANG variable. I don't need to have SLiM read $LANG into the environment. It is already there. /etc/profile.d/locale.sh is evidently sourced when bash starts.
Comment by Alex Ferguson (B_Lizzard) - Thursday, 05 November 2009, 19:03 GMT
If you remove the line, LANG does not get set properly and applications that need it do not behave properly. I had problems with the XFCE terminal, OpenOffice.org and a few other programs. GNOME programs (including GNOME Terminal) do not experience such issues, probably due to the different way GNOME starts its environment. Running 'env' under the XFCE Terminal also brought up improper results.

Simply reverting the fix will not do. Since sourcing the /etc/profile.d/locale.sh file is problematic, and as far as I know, there is no other file we can source (Debian has /etc/default/locale, but I found no such file in Arch), maybe something can be done in /etc/init.d/slim.

In Debian they source and export the values of the /etc/default/locale file, which contains entries in the form of LANG="en_US.utf" using a script under /etc/X11/Xsession.d/.
Comment by Jay Tanzman (jt512) - Thursday, 05 November 2009, 22:28 GMT
@Alex: I have commented out the line and rebooted. `env | grep LANG` returns LANG=en_US.utf8, and there are no obvious problems in either xfce4 Terminal or openoffice. Are you sure the workaround from the previous bug is still needed. It doesn't seem to be on my machine.

Comment by Marco Simeone (skipio) - Friday, 06 November 2009, 15:54 GMT
same problem i guess, since latest pam upgrade i get this in my /var/log/errors.log:
Nov 6 16:05:33 rock slim: pam_env(slim:session): non-alphanumeric key 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e%%G"; fi' in /etc/profile.d/locale.sh', ignoring
Nov 6 16:05:33 rock slim: pam_env(slim:session): non-alphanumeric key 'if [ "$CONSOLE" = "" -a "$TERM" = "linux" -a -t 1 ]; then printf "\e(K"; fi' in /etc/profile.d/locale.sh', ignoring

Comment by Andrea Scarpino (BaSh) - Saturday, 07 November 2009, 01:02 GMT
initscripts-2009.11-1 fix an issue with locale.sh: '\e' isn't ever recognized, so is replaced by '\033'. Could this fix the pam error?
Comment by Jay Tanzman (jt512) - Saturday, 07 November 2009, 01:33 GMT
I doubt it. It sounds like all they're doing is replacing '\e' in the locale.sh file with '\033'. Unless you change (or eliminate) the line that causes pam_env to read the locale.sh file, you'll still get garbage in the environment; it will just be garbage containing '\033' instead of '\e'. The pam_env documentation clearly states that the envfile must be in simple KEY=VAL format.

Why not test slim without the pam_env line at all. It's working on my computer. Maybe the bug that the line was put in to fix has been fixed upstream.
Comment by Andrea Scarpino (BaSh) - Saturday, 07 November 2009, 01:43 GMT
ok, removed pam_env from slim.pam

@Alex
if this cause issues for you, re-open  FS#16282 

Loading...