Project

General

Profile

Bug #7897

Feature #7561: Update the Greeter for Jessie

Fix localization of GNOME session in Jessie

Added by alant over 4 years ago. Updated almost 4 years ago.

Status:
Resolved
Priority:
High
Assignee:
Category:
-
Target version:
Start date:
09/14/2014
Due date:
% Done:

100%

QA Check:
Dev Needed
Feature Branch:
greeter:feature/jessie
Type of work:
Code
Blueprint:
Starter:
Affected tool:
Greeter

Description

When one chooses a language in tails-greeter, it as applied in the greeter, but NOT in the session opened afterwards.


Related issues

Related to Tails - Feature #8713: Consider replacing some of our code with the GDM->GNOME session keyboard layout passthrough Resolved 01/16/2015

Associated revisions

Revision 371a7ef7 (diff)
Added by Tails developers over 4 years ago

Fix session localization

Together with changes in tails-greeter, this fixes #7897

History

#1 Updated by alant over 4 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

Adding echo "LANG=${TAILS_LOCALE_NAME}" >> /home/${LIVE_USERNAME}/.xsessionrc@ in /etc/gdm/PostLogin/Default solves the issue.

#2 Updated by alant over 4 years ago

Alternatively, gnome-control-center sets locale through DBus on the system bus: org.freedesktop.locale1 /org/freedesktop/locale1 SetLocale.

#3 Updated by alant over 4 years ago

  • % Done changed from 10 to 20
  • Feature Branch set to greeter:feature/jessie

It should be fixed the xsessionrc way in greeter:feature/jessie. To be tested.

#4 Updated by intrigeri over 4 years ago

  • Category set to 165
  • Assignee set to alant

alant wrote:

Adding echo "LANG=${TAILS_LOCALE_NAME}" >> /home/${LIVE_USERNAME}/.xsessionrc@ in /etc/gdm/PostLogin/Default solves the issue.

Great! I've uploaded a new greeter package that has this change, so that we get the short term workaround.

I'm unsure if that's the right way to fix it, though: it adds one more session initialization point, that might or might not be synchronized with other ones, and I'm kinda scared that we're going to run into more race conditions by doing it with way, and that may require more ugly hacks later, such as the one we already have for setting the keyboard layout.

Alternatively, gnome-control-center sets locale through DBus on the system bus: org.freedesktop.locale1 /org/freedesktop/locale1 SetLocale.

This seems to me this solution would potentially have better chances to correctly synchronize with the rest of the session initialization.

But still, the major question remains IMO: how does the standard GDM greeter set the locale? IMO, we should just do the same.

#5 Updated by alant over 4 years ago

But still, the major question remains IMO: how does the standard GDM greeter set the locale? IMO, we should just do the same.

As far as I found, it doesn't anymore set the locale.

#6 Updated by alant over 4 years ago

  • Category deleted (165)
  • Assignee deleted (alant)

It should be fixed the xsessionrc way in greeter:feature/jessie. To be tested.

It works now but I had to add the line LANG=C in .xsessionrc for it to be modified by grep_n_set in greeter PostLogin script, which looks like a bug in gren_n_set or a misunderstanding I had on how it's supposed to work. At least it enable the translators to work (#7568).

Anyway the right solution seems to set locale through DBus on the system bus: org.freedesktop.locale1 /org/freedesktop/locale1 SetLocale.

#7 Updated by alant over 4 years ago

  • Category set to 165
  • Assignee set to alant

#8 Updated by intrigeri about 4 years ago

alant wrote:

As far as I found, it doesn't anymore set the locale.

So the locale is set by gnome-control-center once its run by the session manager? I'm kinda surprised, as for the correct locale environment to be set, it must be done in a process that's a parent of the entire session.

[...] which looks like a bug in grep_n_set

I've looked at the code, and it seems correct, but I may be missing something.

Anyway the right solution seems to set locale through DBus on the system bus: org.freedesktop.locale1 /org/freedesktop/locale1 SetLocale.

Agreed, if that's how locales are initialized in a non-Tails GNOME session.

#9 Updated by intrigeri about 4 years ago

intrigeri wrote:

[...] which looks like a bug in grep_n_set

I've looked at the code, and it seems correct, but I may be missing something.

Ah, no, indeed it's completely buggy: the vague grep -qs "$1" "$2" check will return true, as our .xsessionrc contains the string TAILS_WIKI_SUPPORTED_LANGUAGES, which contains the string "LANG". So, grep_n_set switches to replacement mode (as opposed to addition mode). This would be fixed by anchoring the grep regexp to the beginning or a line (with whitespace, potentially), e.g. grep -qs "^\s*$1" "$2" or similar. However, one needs to check for each other usage of this function, to see if a stricter regexp breaks anything else.

#10 Updated by intrigeri about 4 years ago

  • Priority changed from Normal to High
  • Target version set to Tails_2.0

(Like parent ticket.)

#11 Updated by alant about 4 years ago

intrigeri wrote:

alant wrote:

As far as I found, it doesn't anymore set the locale.

So the locale is set by gnome-control-center once its run by the session manager? I'm kinda surprised, as for the correct locale environment to be set, it must be done in a process that's a parent of the entire session.

As far as I understand, gdm doesn't take care of that anymore (I didn't find any code to setup locale in gdm). I'll investigate gnome-sesson.

Anyway the right solution seems to set locale through DBus on the system bus: org.freedesktop.locale1 /org/freedesktop/locale1 SetLocale.

Agreed, if that's how locales are initialized in a non-Tails GNOME session.

I tried to boot tails jessie, comment the line modifying .xsessionrc and change org.freedesktop.locale1.Locale with gdbus. It's changed but the locale not applied in the session so it's not the solution.

#12 Updated by alant about 4 years ago

  • Assignee deleted (alant)

There is also a org.freedesktop.Accounts.User.SetLocale dbus method which doesn't seem to work either.

GDM seems to handle $LANG for the session in function build_launch_environment of daemon/gdm-launch-environment.c. If I understand well it looks for $LANG and other variables in /etc/locale.conf but setting this don't work either.

I'm giving up on this.

#13 Updated by intrigeri about 4 years ago

  • Assignee set to alant
  • QA Check set to Info Needed

Asked on tails-dev@ for info about what was already tried.

#14 Updated by intrigeri about 4 years ago

alant wrote:

GDM seems to handle $LANG for the session in function build_launch_environment of daemon/gdm-launch-environment.c. If I understand well it looks for $LANG and other variables in /etc/locale.conf but setting this don't work either.

Well, this function also sets RUNNING_UNDER_GDM to true, so I doubt it's used to set up the (non-GDM) regular user GNOME session.

#15 Updated by intrigeri about 4 years ago

After reading https://help.gnome.org/admin/gdm/stable/configuration.html.en#userconfig, I've tried editing .dmrc in PostLogin/Default. The configured language isn't applied. I guess that this file is loaded earlier, to set the user's default language.

#16 Updated by intrigeri about 4 years ago

Regardless of what language I choose in the Greeter, I see in the logs (language.py):

__apply_locale: Setting session language to en_US.UTF-8

Some more debugging shows that self._locale is always en_US in __apply_locale. That's a first bug, I think. I've not looked at it in more details. Alan, now that we have a first lead, are you interested in having a closer look?

Then, I also see that in the logs:

AccountsService-WARNING **: SetLanguage call failed: GDBus.Error:org.freedesktop.Accounts.Error.PermissionDenied: Not authorized

It seems that we have a second bug here, and even if __apply_locale was fixed, it might be that the correct locale could not be applied. We ship what looks very much like correct permissions to me in org.boum.tails.accounts.pkla: I checked in data/org.freedesktop.Accounts.User.xml the permission name, and tried with ResultAny=yes as well; but pkcheck seems to agree that our greeter's process is not allowed to run this action. I've also tried setting the same permissions on /etc/polkit-1/localauthority that I have on my system, still same results. polkitd is started with --no-debug, it would be great to enable its debug output to understand better what's happening.

#17 Updated by alant about 4 years ago

Regardless of what language I choose in the Greeter, I see in the logs (language.py):

__apply_locale: Setting session language to en_US.UTF-8

Some more debugging shows that self._locale is always en_US in __apply_locale.

You mean even after choosing another language than english, right?

That's a first bug, I think. I've not looked at it in more details. Alan, now that we have a first lead, are you interested in having a closer look?

Yes definately. Thanks for the finding.

Then, I also see that in the logs:

AccountsService-WARNING **: SetLanguage call failed: GDBus.Error:org.freedesktop.Accounts.Error.PermissionDenied: Not authorized

It seems that we have a second bug here, and even if __apply_locale was fixed, it might be that the correct locale could not be applied. We ship what looks very much like correct permissions to me in org.boum.tails.accounts.pkla: I checked in data/org.freedesktop.Accounts.User.xml the permission name, and tried with ResultAny=yes as well; but pkcheck seems to agree that our greeter's process is not allowed to run this action. I've also tried setting the same permissions on /etc/polkit-1/localauthority that I have on my system, still same results. polkitd is started with --no-debug, it would be great to enable its debug output to understand better what's happening.

Oh annoying... I could have a quick look but I'm not an expert of policykit. Would you loke to try again once the 1st bug is fixed

#18 Updated by alant about 4 years ago

  • QA Check changed from Info Needed to Dev Needed

intrigeri wrote:

Asked on tails-dev@ for info about what was already tried.

Please find clarifications below.

E.g. you wrote "I tried to boot tails jessie, comment the line
modifying .xsessionrc and change org.freedesktop.locale1.Locale with
gdbus. It's changed but the locale not applied in the session so it's
not the solution." -- how exactly did you try this?

I set up a root password with rootpw on kernel command line, then
when the greeter was ready I went to a text console, logged in,
changed .xsessionrc and launched gdbus from that text console

(E.g. .xsessionrc is sourced before D-Bus is started, so if you did
it via this file, it couldn't possibly work.)

This call happens on the system bus which is started at this point.

Also, you wrote "If I understand well it looks for $LANG and other
variables in /etc/locale.conf but setting this don't work either"; how
exactly did you try to set this?

I set up a root password and logged in a text console as above but
instead of launching gdbus I edited locale.conf.

The SetLocale method doesn't exist on my system. You really meant
org.freedesktop.Accounts.User.SetLanguage, right?

Yes.

#19 Updated by intrigeri about 4 years ago

Regardless of what language I choose in the Greeter, I see in the logs (language.py):

__apply_locale: Setting session language to en_US.UTF-8

Some more debugging shows that self._locale is always en_US in __apply_locale.

You mean even after choosing another language than english, right?

Right.

Oh annoying... I could have a quick look but I'm not an expert of policykit.
Would you loke to try again once the 1st bug is fixed

I'm no expert in that field either, but sure, I can have a closer look.

#20 Updated by intrigeri about 4 years ago

Please find clarifications below.

Thanks!

#21 Updated by intrigeri about 4 years ago

Another lead (that shouldn't prevent us from finding the bug highlighted above, that's most likely in our own code) would be to use systemd's localed:

#22 Updated by alant almost 4 years ago

  • Assignee changed from alant to intrigeri

intrigeri wrote:

Regardless of what language I choose in the Greeter, I see in the logs (language.py):

__apply_locale: Setting session language to en_US.UTF-8

Some more debugging shows that self._locale is always en_US in __apply_locale. That's a first bug, I think. I've not looked at it in more details. Alan, now that we have a first lead, are you interested in having a closer look?

I tried to reproduce your log with tails-greeter 0.8.6+jessie1 in an iso built from 3a16e4e

I start with rootpw= then go to the text console and edit /usr/share/tails-greeter/tails-logging to set logging level to DEBUG, then restart gdm with service gdm restart.

When the greeter starts, I first get:

18:21:48 amnesia gnome-session[5629]: [DEBUG] language.py:364 __apply_locale: Setting session language to en_US.UTF-8
18:21:48 amnesia gnome-session[5629]: [WARNING] language.py:370 __apply_locale: AccountsManager not ready

Then when I choose french I see two of thses:

18:21:53 amnesia gnome-session[5629]: [DEBUG] language.py:358 __set_default_locale: setting default locale to fr_FR
18:21:53 amnesia gnome-session[5629]: [DEBUG] language.py:364 __apply_locale: Setting session language to fr_FR.UTF-8

These are the last calls to __apply_locale so they should be the one taken into account. That looks right to me. So I fail to find a bug in the greeter code. How exacty did you obtained the log you got intrigeri?

#23 Updated by intrigeri almost 4 years ago

The feature/jessie-localectl branch migrates most of our locale and keyboard settings to localectl. Quickly tested in a live Tails/Jessie, but that's all.

Not looked at the bug I've reported above, that Alan can't reproduced, yet.

#24 Updated by intrigeri almost 4 years ago

  • Related to Feature #8713: Consider replacing some of our code with the GDM->GNOME session keyboard layout passthrough added

#25 Updated by BitingBird almost 4 years ago

  • Subject changed from Fix localization of GNOME session to Fix localization of GNOME session in Jessie

#26 Updated by intrigeri almost 4 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 20 to 100

Fixed with tails-greeter 0.8.8+jessie2 and 24621ee010819cd1e97fbb8e318b7dfc3778f54a.

Also available in: Atom PDF