Bug 105322

Summary: /etc/init.d/network: touch `date`: Problem if LANG != "C"
Product: [openSUSE] SUSE LINUX 10.0 Reporter: Tobias Burnus <burnus>
Component: BasesystemAssignee: Lars Müller <lmuelle>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Minor    
Priority: P5 - None CC: samba-maintainers
Version: Beta 2   
Target Milestone: ---   
Hardware: Other   
OS: All   
Whiteboard:
Found By: Other Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Tobias Burnus 2005-08-17 20:37:53 UTC
I did an installation in German and saw during startup a message like like that:
touch: Ungültiges Datumsformat „Mi Aug 17 22:34:26 CEST 2005“


In /etc/init.d/network you find:
   touch -d "`date -d "-20sec"`" $NETWORK_RUNFILE
and touch does not accept a German time format

tob2@tux:~> touch -d "`date -d "-20sec"`" test
touch: Ungültiges Datumsformat „Mi Aug 17 22:34:26 CEST 2005“
tob2@tux:~> LANG=C touch -d "`date -d "-20sec"`" test
touch: invalid date format `Mi Aug 17 22:34:32 CEST 2005'

I don't know whether TOUCH should understand the date format of the current
locale or not, but doing a LC_ALL=C should not hurt:
LC_ALL=C touch -d "`LC_ALL=C date -d "-20sec"`" $NETWORK_RUNFILE
Comment 1 Dr. Werner Fink 2005-08-18 10:05:46 UTC
fixed
Comment 2 Lars Müller 2006-02-25 18:33:01 UTC
Gerald Carter, member of the Samba Team asked: Why does SuSE set these lines in /etc/rc.status
# Do _not_ be fooled by non POSIX locale
LC_ALL=POSIX
xport LC_ALL

We're having some problems with is resulting in smbd not running with a UTF-8 charset and is breaking creating printers with extended characters in the name.
Comment 3 Lars Müller 2006-02-25 18:36:08 UTC
Werner or Mike:  Should we get LANG from /etc/sysconfig/language and export it before we start smbd and unset it after?
Comment 4 Dr. Werner Fink 2006-02-27 11:18:21 UTC
This depends on the requirement of the samba people. If you
need this than do this. The allmost other boot scripts do
require POSIX for LANG.
Comment 5 Mike Fabian 2006-02-27 12:06:49 UTC
Lars> Should we get LANG from /etc/sysconfig/language and export it
Lars> before we start smbd

In the /etc/init.d/kbd script, I used:

    test -e /etc/profile.d/lang.sh  && . /etc/profile.d/lang.sh
    LOCALE_CHARMAP=`locale charmap`
    LC_ALL=POSIX

This will work only if ROOT_USES_LANG="ctype" or "yes".
If ROOT_USES_LANG="no", it will not work because then

    . /etc/profile.d/lang.sh

will not even set LC_CTYPE.

According to comment #2 it looks like you need only the charmap of the
locale, i.e. sourcing /etc/profile.d/lang.sh should be enough unless
somebody sets ROOT_USES_LANG="no"

If ROOT_USES_LANG="yes", sourcing /etc/profile/lang.sh will give you
the same locale as for regular (non-root) users.

If you don't want to depend on the setting of ROOT_USES_LANG
you have to source /etc/sysconfig/language and use
at the values of RC_*.

For example:

   . /etc/sysconfig/language
   export LANG=$RC_LANG
   export LC_ALL=$RC_LC_ALL
   export LC_MESSAGES=$RC_LC_MESSAGES
   ...

   do something which needs correct locale settings

   unset LANG
   unset LC_ALL
   unset LC_MESSAGES
   ...

Lars> and unset it after?

This depends on what you do in the smbd start script.
Are you parsing any output which might break if it comes in
a different language? Do you depend on a certain sorting order
when parsing output?

If you do such stuff, better use LC_ALL=POSIX to make sure
that your parser doesn't break. If not, it doesn't matter.

Comment 6 Lars Müller 2006-02-27 17:44:18 UTC
Fixed with next Samba package.  And thanks Werner and Mike.