Incorrect SPF record crash policyd-spf

Asked by Birta Levente

Hi

I get a mail with this spf record:

# dig +short txt e-learningcompany.ro
"v=spf1 include:_spf.servers.xservers.org \226\128\147all"

pypolicyd-spf how should handle this?

errors from the log:

Jul 17 11:23:18 srv1 policyd-spf[36724]: None; identity=helo; client-ip=89.45.199.24; helo=mx.servers.xservers.org; <email address hidden>; <email address hidden>
Jul 17 11:23:18 srv1 policyd-spf[36724]: Traceback (most recent call last):
Jul 17 11:23:18 srv1 policyd-spf[36724]: File "/usr/bin/policyd-spf", line 684, in <module>
Jul 17 11:23:18 srv1 policyd-spf[36724]: instance_dict, configData, peruser)
Jul 17 11:23:18 srv1 policyd-spf[36724]: File "/usr/bin/policyd-spf", line 530, in _spfcheck
Jul 17 11:23:18 srv1 policyd-spf[36724]: res = spf.check2(ip, sender, helo)
Jul 17 11:23:18 srv1 policyd-spf[36724]: File "/usr/lib/python2.6/site-packages/spf.py", line 310, in check2
Jul 17 11:23:18 srv1 policyd-spf[36724]: receiver=receiver,timeout=timeout,verbose=verbose,querytime=querytime).check()
Jul 17 11:23:18 srv1 policyd-spf[36724]: File "/usr/lib/python2.6/site-packages/spf.py", line 538, in check
Jul 17 11:23:18 srv1 policyd-spf[36724]: spf = self.dns_spf(self.d)
Jul 17 11:23:18 srv1 policyd-spf[36724]: File "/usr/lib/python2.6/site-packages/spf.py", line 1094, in dns_spf
Jul 17 11:23:18 srv1 policyd-spf[36724]: a = [t for t in self.dns_txt(domain) if RE_SPF.match(t)]
Jul 17 11:23:18 srv1 policyd-spf[36724]: File "/usr/lib/python2.6/site-packages/spf.py", line 1131, in dns_txt
Jul 17 11:23:18 srv1 policyd-spf[36724]: for a in self.dns(domainname, 'TXT')]
Jul 17 11:23:18 srv1 policyd-spf[36724]: File "/usr/lib/python2.6/site-packages/spf.py", line 1130, in <genexpr>
Jul 17 11:23:18 srv1 policyd-spf[36724]: return [''.join(s.decode("ascii") for s in a)
Jul 17 11:23:18 srv1 policyd-spf[36724]: UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 41: ordinal not in range(128)

thanks

Levi

Question information

Language:
English Edit question
Status:
Solved
For:
pypolicyd-spf Edit question
Assignee:
No assignee Edit question
Solved by:
Scott Kitterman
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
Scott Kitterman (kitterman) said :
#1

First, it's not a valid SPF record, so it's an error condition of some kind.

What vesions of policyd-spf and pyspf are you using and did you install from upstream source or distribution packages? I thought I had fixed this, but maybe not.

Revision history for this message
Birta Levente (blevi-linux) said :
#2

pypolicyd-spf: __version__ = "1.1.2: MAY 10, 2013"

and pyspf 2.0.7

Thanks
Levi

Revision history for this message
Scott Kitterman (kitterman) said :
#3

Now I know why I thought I fixed this. It's a bug in pyspf that's been fixed upstream, but there's not release with the fix yet. Here's a patch that should fix the problem:

http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/saucy/pyspf/saucy/view/head:/debian/patches/catch_unicode_spf

You can make that change in your local spf.py or ask your distributor to fix it.

Revision history for this message
Birta Levente (blevi-linux) said :
#4

I installed manually the pyspf and don't remember where downloaded from.

Anyway...patch applied

Thank you for your help!

Levi

Revision history for this message
Birta Levente (blevi-linux) said :
#5

Thanks Scott Kitterman, that solved my question.

Revision history for this message
Scott Kitterman (kitterman) said :
#6

pyspf 2.0.8 has now been released on pypi (and will shortly be on sourceforge too) that contains the fix for this issue. Anyone encountering this problem should ensure they are using this version or later.

Revision history for this message
Birta Levente (blevi-linux) said :
#7

So I updated with

# python-pip install pyspf --upgrade
Downloading/unpacking pyspf from https://pypi.python.org/packages/source/p/pyspf/pyspf-2.0.8.tar.gz#md5=8ef1a5714939d6df5ab40006ac8930ac
  Downloading pyspf-2.0.8.tar.gz (48kB): 48kB downloaded
  Running setup.py egg_info for package pyspf
Installing collected packages: pyspf
  Found existing installation: pyspf 2.0.7
    Uninstalling pyspf:
      Successfully uninstalled pyspf
  Running setup.py install for pyspf
    changing mode of build/scripts-2.6/type99.py from 644 to 755
    changing mode of build/scripts-2.6/spfquery.py from 644 to 755
    changing mode of /usr/bin/spfquery.py to 755
    changing mode of /usr/bin/type99.py to 755
Successfully installed pyspf

Then from the maillog:
Jul 25 19:55:00 srv1 policyd-spf[34233]: Traceback (most recent call last):
Jul 25 19:55:00 srv1 policyd-spf[34233]: File "/usr/bin/policyd-spf", line 684, in <module>
Jul 25 19:55:00 srv1 policyd-spf[34233]: instance_dict, configData, peruser)
Jul 25 19:55:00 srv1 policyd-spf[34233]: File "/usr/bin/policyd-spf", line 350, in _spfcheck
Jul 25 19:55:00 srv1 policyd-spf[34233]: skip_check = _spfbypass(data, 'skip_addresses', configData)
Jul 25 19:55:00 srv1 policyd-spf[34233]: File "/usr/bin/policyd-spf", line 206, in _spfbypass
Jul 25 19:55:00 srv1 policyd-spf[34233]: if _cidrmatch(ip, good_ip, int(cidr_range)):
Jul 25 19:55:00 srv1 policyd-spf[34233]: File "/usr/bin/policyd-spf", line 59, in _cidrmatch
Jul 25 19:55:00 srv1 policyd-spf[34233]: bin = spf.addr2bin
Jul 25 19:55:00 srv1 policyd-spf[34233]: AttributeError: 'module' object has no attribute 'addr2bin'
Jul 25 19:55:01 srv1 policyd-spf[34234]: Traceback (most recent call last):
Jul 25 19:55:01 srv1 policyd-spf[34234]: File "/usr/bin/policyd-spf", line 684, in <module>
Jul 25 19:55:01 srv1 policyd-spf[34234]: instance_dict, configData, peruser)
Jul 25 19:55:01 srv1 policyd-spf[34234]: File "/usr/bin/policyd-spf", line 350, in _spfcheck
Jul 25 19:55:01 srv1 policyd-spf[34234]: skip_check = _spfbypass(data, 'skip_addresses', configData)
Jul 25 19:55:01 srv1 policyd-spf[34234]: File "/usr/bin/policyd-spf", line 206, in _spfbypass
Jul 25 19:55:01 srv1 policyd-spf[34234]: if _cidrmatch(ip, good_ip, int(cidr_range)):
Jul 25 19:55:01 srv1 policyd-spf[34234]: File "/usr/bin/policyd-spf", line 59, in _cidrmatch
Jul 25 19:55:01 srv1 policyd-spf[34234]: bin = spf.addr2bin
Jul 25 19:55:01 srv1 policyd-spf[34234]: AttributeError: 'module' object has no attribute 'addr2bin'

This is Centos 6.4, python 2.6.6

There is something more that I need to do ?

Thanks

Revision history for this message
Scott Kitterman (kitterman) said :
#8

That's a different problem. It looks like pyspf 2.0.8 dropped a function I was using. I'll get a fix done, probably later today.

Revision history for this message
Best Scott Kitterman (kitterman) said :
#9

I've released pypolicyd-spf 1.2 now. That should solve this new problem.

Revision history for this message
Birta Levente (blevi-linux) said :
#10

Thanks Scott Kitterman, that solved my question.