FS#22600 - [initscripts] bad locales during init process

Attached to Project: Arch Linux
Opened by Sébastien Luttringer (seblu) - Tuesday, 25 January 2011, 14:52 GMT
Last edited by Thomas Bächler (brain0) - Sunday, 27 February 2011, 11:00 GMT
Task Type Bug Report
Category Packages: Core
Status Closed
Assigned To Thomas Bächler (brain0)
Roman Kyrylych (Romashka)
Architecture All
Severity Medium
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

At boot start, global $LANG env var is not available on process started in DAEMONS var in rc.conf.

So, for example, smbnetfs which use this variables when it starts to dertermine its charset conversion between samba server and locale system is broken.

The previous behaviour it's unexpected for me because I thought bash will load /etc/profile.d/locales.sh during boot time (but no).

rc.sysinit and rc.single not need to have locale set. but rc.multi which run DAMEONS should.

I propose the following patch.

Regards,
This task depends upon

Closed by  Thomas Bächler (brain0)
Sunday, 27 February 2011, 11:00 GMT
Reason for closing:  Fixed
Comment by Thomas Bächler (brain0) - Tuesday, 25 January 2011, 19:52 GMT
I've always been against running daemons with a non-C locale and I actually don't want it on my system. That said, there has never been a vote among Arch developers on the issue.

Another point I'd like to raise is that the locale conversion in configurable everywhere I've seen it before (ntfs-3g, mount.cifs and so on) and should default to UTF8 for any sane program.

I would be willing to accept a patch that made this configurable via rc.conf - but please only send patches against the current git master branch.
Comment by Sébastien Luttringer (seblu) - Tuesday, 25 January 2011, 22:06 GMT
You make me doubt. It's maybe an useless feature! Watching on debian distro startup system, it have POSIX local during system init.

About smbnetfs, this can be setted in master config file (i will do that). smbnetfs behaviour is not insane. Running locale command during boot process show "POSIX" as local, so smbnetfs guess that system locale is C/POSIX (!= UTF8) and decide to use it.

ok for patch from master. I can do an another patch with an ENABLE_LOCALE_DURING_BOOT var in rc.conf, but it's maybe not useful. Tell me what you want.
Comment by Thomas Bächler (brain0) - Tuesday, 25 January 2011, 22:47 GMT
Considering this is by far not the first request for this, maybe it is useful. The only real reason I see is to enable UTF8 charsets everywhere (which should be the default, it's 2011).
Comment by Sébastien Luttringer (seblu) - Tuesday, 25 January 2011, 22:50 GMT
ok i will do a patch. free for you to include it or not.
Comment by Jan de Groot (JGC) - Wednesday, 26 January 2011, 09:27 GMT
If we want to keep this the way it is, we have to make sure that there's no difference in starting daemons from DAEMONS or restarting them from a bash prompt. It's not nice if Apache starts up with C locale on bootup, while it switches to something like de_DE when you do /etc/rc.d/httpd restart
Comment by Thomas Bächler (brain0) - Wednesday, 26 January 2011, 10:15 GMT
Yes, but that problem isn't new. We would need to sanitize the LANG and LC_* at the beginning of each daemon script to
1) LANG=C, unset LC_*, or
2) the value from rc.conf
to be consistent here. The same holds for TZ - I keep forgetting to unset TZ before running 'apachectl graceful' on our server, which has an effect on log files. Maybe we should solve all these problems together and at the same time make the DAEMON locale configurable as mentioned above.
Comment by Sébastien Luttringer (seblu) - Thursday, 27 January 2011, 06:44 GMT
about JGC comment, this patch only locale difference between init boot et /etc/rc.d/httpd starts!
Usually there is many more env var in your shell (a less secure PATH for example).
It could be useful to have a "run" command which run like with init.
Comment by Thomas Bächler (brain0) - Thursday, 27 January 2011, 07:59 GMT
I had a look into /etc/rc.d/functions while researching a minor problem with the new initscripts release. It seems that it has 'unset TZ' in there - the same place would be good for setting the locale. The issues pointed out by JGC would be solved there, as well as yours. In that case, 'EARLYLOCALE' would be a weird name though.
Comment by Thomas Bächler (brain0) - Thursday, 27 January 2011, 08:12 GMT Comment by Sébastien Luttringer (seblu) - Thursday, 27 January 2011, 10:37 GMT
ok, it will not be my first patch for archlinux :'(

about naming of the option, i draw your attention on DAEMON_LOCALE which may mislead. rc.local script is run under this new env and something like BOOT_LOCAL or EARLY LOCALE is maybe more clear.
Comment by Thomas Bächler (brain0) - Thursday, 27 January 2011, 12:57 GMT
BOOT_LOCALE and EARLY_LOCALE are misleading as well - this is taken to effect any time /etc/rc.d/$FOO start or similar is run, not only at boot.

Loading...