Cron does send mails with wrong charset

Bug #140896 reported by Sebastian Wiesinger
50
This bug affects 9 people
Affects Status Importance Assigned to Milestone
cron (Debian)
Fix Released
Unknown
cron (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: cron

Hello,

cron does use the wrong charset when sending mails. With Feisty the default charset is UTF8 but cron uses charset=ANSI_X3.4-1968. There is already a debian bug report and a possible solution here:

http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=410057

Changed in cron:
status: Unknown → New
Changed in cron:
status: New → Fix Released
Revision history for this message
Wouter Stomp (wouterstomp-deactivatedaccount) wrote :

This is fixed in debian in 3.0pl1-101. This version also has all the remaining changes in ubuntu, so it can be synced to ubuntu.

Revision history for this message
Jean-Baptiste Lallement (jibel) wrote :

Fixed in Intrepid. Please see https://wiki.ubuntu.com/StableReleaseUpdates if you would like to pursue
a fix in stable releases.

Thanks for your time.

Changed in cron:
status: New → Fix Released
Revision history for this message
Belyaev Nikolay (werru82) wrote :

9.10 server. it's still here
wer@wer-desktop:~$ locale
LANG=ru_RU.UTF-8
LANGUAGE=ru_RU:ru:en_GB:en
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=

but i have this header in mail
Content-Type: text/plain; charset=ANSI_X3.4-1968

Revision history for this message
Belyaev Nikolay (werru82) wrote :

i haven't acess to server now, but locale on my desktop and server equal

Revision history for this message
foolishchild (j-clark) wrote :

Still there with 10.10 server

Revision history for this message
huangjs (j-launchpad-net-hjs-twbbs-org) wrote :

Still with ANSI_X3.4-1968 instead of UTF-8 on Ubuntu 10.04 LTS.
(Environment was set.)

Revision history for this message
Olivier Cortès (olive) wrote :

Hi,

My Ubuntu 12.04 LTS servers seem to still send email with the wrong charset. They are configured in the french locale (/etc/default/locale:LANG="fr_FR.UTF-8"), and even the subject is unreadable. See this unattended-upgrade mail example:

--------
To: olive@xxxx
Subject: unattended-upgrades a retourné : xxx
Date: Mon, 23 Jul 2012 06:26:53 +0200 (CEST)
From: root@xxxx

La mise à niveau automatique a retourné : True

Paquets mis à niveau :
 libqt4-dbus libqt4-declarative libqt4-designer libqt4-network
 libqt4-qt3support libqt4-script libqt4-sql libqt4-sql-mysql
 libqt4-xml libqt4-xmlpatterns libqtcore4 libqtgui4 qdbus

[other content stripped]
--------

Examining the mail source, it doesn't seem to have any content-encoding related header at all.

Revision history for this message
Josep Pujadas-Jubany (jpujades) wrote :
Revision history for this message
Walter (wdoekes) wrote :

@Josep: that bug report is unrelated. (Although it touches the same cron_default_mail_charset code.)

This issue is that:

(A) The cron daemon starts with no LANG (LANG=C)
(B) The processes start with the lang environment from /etc/default/locale (LANG=en_US.UTF-8)

Now the processes will print stuff like:

    $ rm abc
    rm: cannot remove ‘abc’ <-- note the non-ascii characters, because it has LANG=...UTF-8

But the mail with that error, will use:

    Content-Type: text/plain; charset=ANSI_X3.4-1968

instead of:

    Content-Type: text/plain; charset=UTF-8

That causes mail clients to get UTF-8 while it is told that it gets ASCII, resulting in a crappy reading experience.

A working fix for me is to add the LANG variable to /etc/init/cron.conf so the cron process gets

    # echo 'env LANG=en_US.UTF-8' > /etc/init/cron.override
    # stop cron; start cron

(Or alternately, the CONTENT_TYPE= setting in crontab as suggested in https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=410057 )

I believe this bug got introduced by using upstart instead of the init script:
- the processes get the environment from /etc/pam.d/cron (LANG=en_US.UTF-8)
- cron gets the environment from /etc/default/locale BUT ONLY if it was started from /etc/init.d/cron. the upstart script does not load /etc/environment nor /etc/default/locale.

.. so .. that should probably mean that this is a ubuntu/cron bug, not an ubuntu/+source/cron bug.

And it first starts showing in Trusty because the tools use fancier tokens when unicode is available:

    ubuntu precise:
    # locale | grep ^LANG=; rm /tmp/abc
    LANG=en_US.UTF-8
    rm: cannot remove `/tmp/abc': No such file or directory

    ubuntu trusty
    # locale | grep ^LANG=; rm /tmp/abc
    LANG=en_US.UTF-8
    rm: cannot remove ‘/tmp/abc’: No such file or directory <-- see the fancy quotes here

Cheers,
Walter Doekes
OSSO B.V.

# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty
# dpkg -l cron | grep ^ii
ii cron 3.0pl1-124ubuntu2

Revision history for this message
Walter (wdoekes) wrote :

Ok. So this bug was really old and closed. Rereported as #1321227.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.