After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 485852 - Copies $LC_CTYPE into $LANG
Copies $LC_CTYPE into $LANG
Status: RESOLVED FIXED
Product: gdm
Classification: Core
Component: general
2.20.x
Other Linux
: Normal normal
: ---
Assigned To: GDM maintainers
GDM maintainers
Depends on:
Blocks:
 
 
Reported: 2007-10-11 20:39 UTC by Josselin Mouette
Modified: 2007-11-21 19:12 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
proposed patch (927 bytes, patch)
2007-11-18 15:54 UTC, Sjoerd Simons
none Details | Review
Patch for daemon/gdm.c and daemon/slave.c (956 bytes, patch)
2007-11-21 17:21 UTC, Takao Fujiwara
committed Details | Review

Description Josselin Mouette 2007-10-11 20:39:53 UTC
When the system is configured to set $LC_CTYPE without setting $LANG, it is copied into $LANG nevertheless when starting a session.

The faulty code seems to be around these lines:

gdm.c:1589:             gdm_system_locale = g_strdup (setlocale (LC_CTYPE, NULL));
slave.c:4805:                   if ((gdm_system_locale != NULL) && (!has_language)) {
slave.c:4806:                           lang = gdm_system_locale;
Comment 1 Brian Cameron 2007-10-11 20:46:25 UTC
Could you explain a bit more about why this causes problems, and what you think GDM should be doing here?  Why would you want to configure a system to have LC_CTYPE without setting LANG?
Comment 2 Josselin Mouette 2007-10-11 20:51:59 UTC
If you want to have some language settings of your country, but not all of them (especially not LC_MESSAGES), you're going to set some LC_* variables to the value of your choice. If one of the values is put back into LANG, that makes the point rather moot.

I think GDM's setlocale call is fine, but using it to set LANG sounds wrong. IMHO  it should only change LANG when the user has selected a language in the menu, and otherwise pass all LANG and LC_* variables unmodified to the created session (which should be automatic since the new process will inherit these variables).
Comment 3 Brian Cameron 2007-10-11 22:02:10 UTC
Would you be willing to provide a patch for the code to change it the way you would like it to work, and test it to make sure it works properly?  Then attach it to the bug report for review, and we can see about getting such a fix upstream.
Comment 4 Takao Fujiwara 2007-10-24 11:38:29 UTC
I think the better change is to use getenv $LANG.

gdm_system_locale = g_strdup (getenv ("LANG"));

We used $LC_CTYPE histrically because old SuSE sysconfig script unset $LANG for users but currently we don't work for SuSE closely so it's ok to use $LANG only for gdm_system_locale.

Comment 5 Josselin Mouette 2007-10-24 12:27:51 UTC
This looks indeed like an easy fix, and I don't see why it wouldn't work.
Comment 6 Ray Strode [halfline] 2007-10-24 13:29:26 UTC
I don't know the context, but probably better to use

gdm_system_locale = g_get_language_names () [0];

than getenv ("LANG") in most contexts.
Comment 7 Brian Cameron 2007-10-24 17:37:21 UTC
Again, could someone provide a patch?
Comment 8 Sjoerd Simons 2007-11-18 15:54:15 UTC
Created attachment 99292 [details] [review]
proposed patch

Use g_get_language_names instead of LC_CTYPE as suggested earlier in this bug
Comment 9 Sjoerd Simons 2007-11-18 15:55:10 UTC
(In reply to comment #8)
> Created an attachment (id=99292) [edit]
> proposed patch
> 
> Use g_get_language_names instead of LC_CTYPE as suggested earlier in this bug
> 

Note that this is against the gnome-2.20 svn branch
Comment 10 Takao Fujiwara 2007-11-19 14:53:45 UTC
The patch of gdm.c is needed but the change of slave.c is not needed.

Probably you may want to check the following change.
http://bugzilla.gnome.org/attachment.cgi?id=88610
I will need to check the GDM HEAD again.
Comment 11 Brian Cameron 2007-11-19 18:04:47 UTC
Takao, I am unclear about your statement.  You say the patch of gdm is needed but the change of slave.c is not needed.  It seems to make more sense to use a standard g_get_language_names function rather than messing around with environment variables, no?  I'd think it would make sense to apply the same change in both places.  Please explain why you think different.
Comment 12 Takao Fujiwara 2007-11-20 01:43:38 UTC
As I noted in bug 108820 comment#44, setlocale() needs to be removed in gdm_slave_session_start().
Yes, using g_get_language_names() in gdm.c is ok. the parameter gdm_system_locale remembers the initial locale only.

Thanks.
Comment 13 Brian Cameron 2007-11-20 15:17:34 UTC
Takao, so your suggestion is to apply the provided patch for gdm.c, and to remove the call to set gdm_system_locale completely from slave.c?  Is that correct?

Sjoerd, does this seem reasonable to you also?  I'll go ahead and apply the change to gdm.c and remove the call to set gdm_system_locale completely from slave.c if I get word from you that this resolves the problem best.
Comment 14 Takao Fujiwara 2007-11-21 17:21:32 UTC
Created attachment 99446 [details] [review]
Patch for daemon/gdm.c and daemon/slave.c

Yes, it's right.

I verified the suggestion works fine with the attachment.
Comment 15 Brian Cameron 2007-11-21 19:12:54 UTC
Fixed in 2.20 branch.