← Back to team overview

touch-packages team mailing list archive

[Bug 1321227] Re: Cron sends mails with ASCII charset while running tasks in UTF-8

 

Status changed to 'Confirmed' because the bug affects multiple users.

** Changed in: cron (Ubuntu)
       Status: New => Confirmed

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to cron in Ubuntu.
https://bugs.launchpad.net/bugs/1321227

Title:
  Cron sends mails with ASCII charset while running tasks in UTF-8

Status in “cron” package in Ubuntu:
  Confirmed

Bug description:
  Seeing that #140896 is closed and fixed, I'm rereporting this bug here for Trusty (and earlier).
  https://bugs.launchpad.net/ubuntu/+source/cron/+bug/140896

  
  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: cannot remove ‘abc’ <-- note the non-ascii characters, because
  it has LANG=...UTF-8

  But the cron 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

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/cron/+bug/1321227/+subscriptions