lightdm: Language selection is ignored in session, $LANG is system default

Bug #1019314 reported by Yves-Alexis Perez
34
This bug affects 7 people
Affects Status Importance Assigned to Milestone
Light Display Manager
Fix Released
Undecided
Unassigned
lightdm (Debian)
Fix Released
Unknown

Bug Description

 affects lightdm
 affects debian
 done

On jeu., 2012-06-28 at 14:21 +0400, Vladimir K wrote:
> Package: lightdm
> Version: 1.2.2-1
> Severity: normal
>
> Dear Maintainer,
> After upgrade to 1.2.2 (tried both 1.2.2-1 and 1.2.2-3) language selection stopped working.
> home directory is not encrypted or anything. It is available before login.
> .dmrc is updated, (although encoding syntax for Language is different: "utf8" instead of "UTF-8")
> But $LANG inside session is still same as system default, not what I selected in lightdm.
>

It seems I can confirm this. I can't test with previous version, but I'm
forwarding this upstream.

Regards,
--
Yves-Alexis

Related branches

Revision history for this message
Yves-Alexis Perez (corsac) wrote : Re: Re: [Pkg-xfce-devel] Bug#679386: lightdm: Language selection is ignored in session, $LANG is system default

Add Debian information

affects: debian → lightdm (Debian)
Changed in lightdm (Debian):
importance: Undecided → Unknown
status: New → Unknown
Changed in lightdm (Debian):
status: Unknown → Confirmed
Revision history for this message
Yves-Alexis Perez (corsac) wrote :

Any idea?

Revision history for this message
Yves-Alexis Perez (corsac) wrote :

After searching a bit, it seems that this was done on purpose: http://bazaar.launchpad.net/~lightdm-team/lightdm/1.2/revision/1438/src/session.c seems to indicate that set_locale() (and the call to user_get_locale()) was removed because it would override PAM settings.

I'm a bit unsure how people are supposed to set those settings in PAM, but at least from an user point of view, it's now broken.

In 1.0, an user could select the locale in LightDM greeter, it was set for the session and saved in .dmrc. Then for the following sessions, .dmrc was read and the locale set to the user choice.

In 1.2, when the user selects the locale in LightDM greeter, it's set for the session and saved in .dmrc. Then for the following sessions, nothing loads .dmrc and the locale is not correctly set.

I'm not completely against switching from .dmrc to PAM stuff, as long as it's still convenient for the user. So imho either lightdm is able to save the user choice to PAM, or the .dmrc handling has to be back. And it doesn't need to override PAM, it can just set the locale if PAM doesn't have anything for the user.

Revision history for this message
Yves-Alexis Perez (corsac) wrote :

I was corrected by one of the reporting user. In lightdm 1.2, when selecting a language in the greeter, it's *NOT* correctly set for the current session, so right now it's plain useless (I guess language selector might even have been removed from the unity greeter?)

Revision history for this message
Yves-Alexis Perez (corsac) wrote :

Sorry for the spam, but to make it clearer: right now there's *no* way to select the locale from LightDM, which is usually the first interface you're presented from and the more convenient to do so. Advanced users are able to edit .xsessionrc (for example in Debian and I guess Ubuntu, .profile is completely irrelevant, it's for bourne login shells) to set those locale but most other just expect to be able to chose it at logon.

Revision history for this message
John Paul Adrian Glaubitz (glaubitz) wrote :

I'm experiencing the same problem with the session setting which isn't stored either. Lightdm will always login with the default xsession, no matter what has been set in ~/.dmrc.

I guess the reason for the session problem is the very same change which affects the language selection. I think the priority for this bug should be set to high.

Cheers,

Adrian

Revision history for this message
John Paul Adrian Glaubitz (glaubitz) wrote :

The reporter of the Debian bug report came up with the idea to set LANG as a workaround during Xsession setup.

In order to make language selection work, create the script /etc/X11/Xsession.d/39-lightdm-dmrc-fix with the following lines:

#!/bin/bash
TEMPLANG=$(cat "$HOME/.dmrc" | grep ^Language= | cut -d '=' -f 2 | sed 's/utf8/UTF8/')
[ ! -z "$TEMPLANG" ] && export LANG=$TEMPLANG
TEMPLANG="$(echo "$LANG" | sed -e 's/\([a-z]*_[A-Z]*\)\.[A-Z]*\-[0-9]/\1/g')"":""$(echo "$LANG" | sed -e 's/\([a-z]*\)_[A-Z]*\.[A-Z]*\-[0-9]/\1/g')"
[ ! -z "$TEMPLANG" ] && export LANGUAGE=$TEMPLANG

Due to another bug in lightdm, however, the information from ${HOME}/.dmrc is invalid, please see Debian bug #690899 if the above script doesn't work.

Adrian

summary: - Re: [Pkg-xfce-devel] Bug#679386: lightdm: Language selection is ignored
- in session, $LANG is system default
+ lightdm: Language selection is ignored in session, $LANG is system
+ default
Revision history for this message
Psy[H[] (vovik-wfa) wrote :

Updated the workaround: added lightdm check, so this script does not mess with any other DM.

/etc/X11/Xsession.d/39-lightdm-dmrc-fix:
--------------
#!/bin/bash

# workaround for session language selection in lightdm greeter
# use .dmrc or accountsservice data (if accounts-daemon is running)

# we need this only if lightdm is being used
if pidof lightdm
then
 # if accountsservice is used, get info from there.
 if pidof accounts-daemon
 then
  LANGFILE="/var/lib/AccountsService/users/$USER"
 # if not, use .dmrc
 else
  LANGFILE="$HOME/.dmrc"
 fi

 # extract, fix and export $LANG
 TEMPLANG=$(cat "$LANGFILE" | grep ^Language= | cut -d '=' -f 2 | sed 's/utf8/UTF8/')
 [ ! -z "$TEMPLANG" ] && export LANG=$TEMPLANG
 # convert $LANG to $LANGUAGE and export
 TEMPLANGUAGE="$(echo $LANG | cut -d '@' -f 1 | cut -d '.' -f 1):$(echo $LANG | cut -d '@' -f 1 | cut -d '.' -f 1 | cut -d '_' -f 1)"
 [ ! -z "$TEMPLANGUAGE" ] && export LANGUAGE=$TEMPLANGUAGE

fi
--------------

Revision history for this message
Guido Berhoerster (gber) wrote :

Attached patch fixes saving/retrieving of the language setting.
More specifically, it adds a new function user_get_language() for retrieving the language setting and actually uses it to retrieve the language setting and export the locale via LANG and GDM_LANG environment variables. This should not interfere with pam_env which will overwrite LANG and GDM_LANG if set in /etc/environment.
It also always save the language to both accountsservice and dmrc in order to ensure consistency.

Note that in order to make language selection fully work again in consumers like lightdm-gtk-greeter the patch attached to bug #1074946 is needed as well.

Revision history for this message
Guido Berhoerster (gber) wrote :

Updated the patch with a fix setting LANG/GDM_LANG only if there is a per-user language setting.

Revision history for this message
Claude Durocher (claude-durocher) wrote :

Also affected today : just upgraded to lightdm 1.2.3 as it's in the update channel and locale settings (french language selected) are not applied anymore. Note that we are using PBIS (likewise-open) to login to a domain account.

The script #8 was not working for me and I changed it for :

#!/bin/bash
if pidof lightdm
then
 if pidof accounts-daemon
 then
  LANGFILE="/var/lib/AccountsService/users/$USER"
 else
  LANGFILE="$HOME/.dmrc"
 fi
 TEMPLANG=$(cat "$LANGFILE" | grep ^FormatsLocale= | cut -d '=' -f 2 | sed 's/utf8/UTF8/')
 [ ! -z "$TEMPLANG" ] && export LANG=$TEMPLANG
 TEMPLANGUAGE="$(echo $LANG | cut -d '@' -f 1 | cut -d '.' -f 1 | cut -d '_' -f 1):en"
 [ ! -z "$TEMPLANGUAGE" ] && export LANGUAGE=$TEMPLANGUAGE
fi

Revision history for this message
Claude Durocher (claude-durocher) wrote :
Revision history for this message
Helge Willum Thingvad (helgesdk) wrote :

Thank you, Claude! *thumbs up*
I am encountering the same problem using likewise-open 6.1.0.406-0ubuntu5.
Looking forward to fix in the 6.1.0.406-0ubuntu8 release :-)

Revision history for this message
Guido Berhoerster (gber) wrote :

Updated fix.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

Could you please convert this into a merge proposal?

Process is:
$ bzr branch lp:lightdm lightdm-branchname
$ cd lightdm-branchname
(make changes)
$ bzr commit -m "Blah blah" --fixes lp:1019314
$ bzr push lp:~gber/lightdm/branchname
Go to https://code.launchpad.net/~gber/lightdm/branchname and click "Propose for merging"

Thanks,
--Robert

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

Fix committed into lp:lightdm at revision 1654, scheduled for release in lightdm, milestone Unknown

Changed in lightdm:
status: New → Fix Committed
Changed in lightdm:
milestone: none → 1.7.0
status: Fix Committed → Fix Released
Changed in lightdm (Debian):
status: Confirmed → Fix Released
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.