FS#24544 - [dcron] Locale is not set by DCron init script
Attached to Project:
Community Packages
Opened by Paul Gideon Dann (giddie) - Thursday, 02 June 2011, 09:12 GMT
Last edited by Evangelos Foutras (foutrelis) - Thursday, 17 January 2013, 01:57 GMT
Opened by Paul Gideon Dann (giddie) - Thursday, 02 June 2011, 09:12 GMT
Last edited by Evangelos Foutras (foutrelis) - Thursday, 17 January 2013, 01:57 GMT
|
Details
Description:
The dcron init script clears the environment (with "env -i"), and manually adds a PATH. I have a daily backup script that invokes bsdtar, which chokes on /etc/ssl/certs, stating that it can't convert linkpaths to UTF8. The following demonstrates this issue from a normal shell on my system: # LANG= LC_CTYPE= bsdtar cf test.tar -C /etc/ssl certs To prevent this, I believe the dcron init script should not be clearing out locale environment variables when it's started. Additional info: Version: 4.5-2 |
This task depends upon
Closed by Evangelos Foutras (foutrelis)
Thursday, 17 January 2013, 01:57 GMT
Reason for closing: Won't fix
Additional comments about closing: systemd has made init scripts obsolete and unsupported now.
Thursday, 17 January 2013, 01:57 GMT
Reason for closing: Won't fix
Additional comments about closing: systemd has made init scripts obsolete and unsupported now.
(It changes much of the context in which cron scripts are started, and could potentially break those)
Could you report this upstream?
Although it seems "http://www.jimpryor.net/linux/dcron.html" is down.
Also, could you try setting the locale manually in your backup script? That might be easier.
What I mean is:
# LANG=en_US.UTF-8 bsdtar cf test.tar -C /etc/ssl certs
FS#18722In the case of man-db (/etc/cron.daily/man-db):
I had to add 'export LC_CTYPE=zh_CN.UTF-8' at the beginning of the file (just below '#!/...'). Adding 'LC_CTYPE=zh_CN.UTF-8' (without 'export') will result in the same error messages.
What will also work is add 'LC_CTYPE=zh_CN.UTF-8 ' in front of '${UPDATEMANDB}' (on the same line), just like in Fabian's example.
Make sure you have the locale by doing 'locale -a', and I believe that '*.utf8' is the same as '*.UTF-8'.
FS#22085.What I was referring to was a different page about dcron not supporting inheriting environment variables in general, however, I can't seem to find that now.
(I'm not even sure that's right, might have misunderstood)
However, the Gentoo guide (http://www.gentoo.org/doc/en/cron-guide.xml) mentions:
"Dcron aims to be a simple, elegant and secure implementation of cron. It does not allow the specification of environment variables in crontabs and all cron-jobs are run from /bin/sh. "
About DAEMON_LOCALE....I think that's not the right solution, as I generally want my daemons error messages to be english (for better bug reporting)
UPDATE: Checked, http://www.jimpryor.net/linux/dcron-README says "Unlike other fatter cron daemons, though, this cron doesn't even try to manage
environment variables or act as a shell. All jobs are run with `/bin/sh` for
conformity and portability."
Now do I misunderstand that or does it mean that inheriting environment variables with dcron doesn't work?
I'm pretty sure that jobs do in fact inherit environment variables. The Readme indicates that dcron does nothing special with environment variables, so we can assume it doesn't make any effort to mask them. It simply spawns /bin/sh and passes in the command from the crontab.
it seems that leaves me with 2 choices (once the init script doesn't clean it anymore) :
1) Let it run in the default locale, in my case de_DE.UTF-8
2) Let it run as C
Now I don't want 1, because that gives me german error messages when dcron fails,
and I don't want 2, because that chokes on UTF-8 paths.
What would work would be to be able to set "DAEMON_LOCALE=en_GB.UTF-8" and run any daemon as english in UTF-8.
This would need a patch to initscripts though.
Description:
If DAEMON_LOCALE is [yY][eE][sS] or [nN][oO] (or unset/empty) do as usual,
else assume DAEMON_LOCALE is a valid locale and set accordingly.
Now because every daemon-script sources /etc/rc.d/functions,
this should set the locale for every one of those properly.
NOTE: I do _NOT_ know what this does if DAEMON_LOCALE is set to an invalid LOCALE (like
"no_LANG.UTF-3.14")
DAEMON_LOCALE.patch (0.3 KiB)
Forgot one export, so I attached the fixed patch again.
Sorry for the noise.
Simply removing "env -i" should suffice, maybe even stop overriding $PATH (or even reuse the cronie script, they look the same)
Merging the patch:
I probably need to send it to [arch-projects] and have Tom Gundersen (initscripts maintainer) take a look at it and see what he thinks.
I'll try to do that when I get time, I'm setting up my new laptop right now.