Package: postfix-policyd-spf-python Version: 1.3.2-1 Severity: normal Tags: patch upstream
Dear Maintainer, While testing the new SMTP UTF8 support of postfix3 on my mail server I noticed that policyd-spf can crash if the message contains a UTF-8 sender and the SPF result is reject Mar 5 13:04:49 pinero policyd-spf[32559]: Traceback (most recent call last): Mar 5 13:04:49 pinero policyd-spf[32559]: File "/usr/bin/policyd-spf", line 708, in <module> Mar 5 13:04:49 pinero policyd-spf[32559]: sys.stdout.write('action=550 %s\n\n' % checkerReason) Mar 5 13:04:49 pinero policyd-spf[32559]: UnicodeEncodeError: 'ascii' codec can't encode characters in position 112-114: ordinal not in range(128) Mar 5 13:04:50 pinero postfix/spawn[32558]: warning: command /usr/bin/policyd-spf exit status 1 Mar 5 13:04:50 pinero postfix/smtpd[32543]: warning: premature end-of-input on private/policy-spf while reading input attribute name . All the code paths right below this catch the UnicodeEncodeError and do the right thing so the patch is trivial. -- System Information: Debian Release: stretch/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 4.4.0-1-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: sysvinit (via /sbin/init) Versions of packages postfix-policyd-spf-python depends on: ii adduser 3.113+nmu3 ii postfix 3.0.4-5 ii python3 3.5.1-2 ii python3-authres 0.800-2 ii python3-spf 2.0.12t-1 pn python3:any <none> postfix-policyd-spf-python recommends no packages. postfix-policyd-spf-python suggests no packages. -- no debconf information
--- policyd-spf.orig 2016-03-05 13:22:48.314039539 -0500 +++ policyd-spf 2016-03-05 13:23:14.930919022 -0500 @@ -705,7 +705,10 @@ # handle results {{{3 if debugLevel >= 3: syslog.syslog('Action: {0}: Text: {1}'.format(checkerValue, checkerReason)) if checkerValue == 'reject': - sys.stdout.write('action=550 %s\n\n' % checkerReason) + try: + sys.stdout.write('action=550 %s\n\n' % checkerReason) + except UnicodeEncodeError: + sys.stdout.write('action=550 %s\n\n' % str(checkerReason.encode("UTF-8"))[1:].strip("'")) elif checkerValue == 'prepend': if configData.get('Prospective'):