Skip to content

Commit

Permalink
nightly status checks could fail if any domains had non-ASCII characters
Browse files Browse the repository at this point in the history
https://discourse.mailinabox.email/t/status-check-emails-empty-after-upgrading-to-v0-16/1082/3

A user on that thread suggests an alternate solution, adding `PYTHONIOENCODING=utf-8` to `/etc/environment`. Python docs say that affects stdin/out/err. But we also use these environment variables elsewhere to ensure that config files we read/write are opened with UTF8 too. Maybe all that can be simplified too.
  • Loading branch information
JoshData committed Feb 13, 2016
1 parent 4ed23f4 commit 8ea4284
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ In Development
* On multi-homed machines, Postfix now binds to the right network interface when sending outbound mail so that SPF checks on the receiving end will pass.
* Backup times were displayed with the wrong time zone.
* On low-usage systems, don't hold backups for quite so long by taking a full backup more often.
* Nightly status checks might fail if any domains had non-ASCII characters.

v0.16 (January 30, 2016)
------------------------
Expand Down
4 changes: 2 additions & 2 deletions conf/management-initscript
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ EXEC_AS_USER=root

# Ensure Python reads/writes files in UTF-8. If the machine
# triggers some other locale in Python, like ASCII encoding,
# Python may not be able to read/write files. Here and in
# Python may not be able to read/write files. Set also
# setup/start.sh (where the locale is also installed if not
# already present).
# already present) and management/daily_tasks.sh.
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
Expand Down
8 changes: 8 additions & 0 deletions management/daily_tasks.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/bash
# This script is run daily (at 3am each night).

# Set character encoding flags to ensure that any non-ASCII
# characters don't cause problems. See setup/start.sh and
# the management daemon startup script.
export LANGUAGE=en_US.UTF-8
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_TYPE=en_US.UTF-8

# Take a backup.
management/backup.py | management/email_administrator.py "Backup Status"

Expand Down
4 changes: 2 additions & 2 deletions setup/start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ source setup/preflight.sh

# Ensure Python reads/writes files in UTF-8. If the machine
# triggers some other locale in Python, like ASCII encoding,
# Python may not be able to read/write files. Here and in
# the management daemon startup script.
# Python may not be able to read/write files. This is also
# in the management daemon startup script and the cron script.

if [ -z `locale -a | grep en_US.utf8` ]; then
# Generate locale if not exists
Expand Down

0 comments on commit 8ea4284

Please sign in to comment.