policyd-spf crashing with IndexError
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
pypolicyd-spf |
Fix Released
|
Undecided
|
Unassigned | ||
pypolicyd-spf (Ubuntu) |
Fix Released
|
High
|
Scott Kitterman |
Bug Description
The following from my /var/log/mail.info file:
Oct 20 13:00:24 xxxxxxx postfix/
Oct 20 13:00:25 xxxxxxx postfix/
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "request=
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "protocol_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "protocol_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "client_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "client_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "reverse_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "helo_name=
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "sender=
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "<email address hidden>"
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "recipient_count=0"
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "queue_id="
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "instance=
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "size=4427"
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "etrn_domain="
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "stress="
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "sasl_method="
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "sasl_username="
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "sasl_sender="
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "ccert_subject="
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "ccert_issuer="
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "ccert_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "encryption_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "encryption_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: "encryption_
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Read line: ""
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Found the end of entry
Oct 20 13:00:25 xxxxxxx policyd-spf[13876]: Config: {'Mail_
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: spfcheck: pyspf result: "['None', '', 'helo']"
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: None; identity=helo; client-
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: Traceback (most recent call last):
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: File "/usr/bin/
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: instance_dict, configData)
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: File "/usr/bin/
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: mfrom_resultpolicy, local = get_resultcodes
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: File "/usr/bin/
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: if spf.domainmatch
Oct 20 13:00:26 xxxxxxx policyd-spf[13876]: IndexError: list index out of range
Oct 20 13:00:26 xxxxxxx postfix/
Oct 20 13:00:26 xxxxxxx postfix/
ProblemType: Bug
Architecture: amd64
DistroRelease: Ubuntu 9.04
Package: postfix-
PackageArchitec
ProcEnviron:
SHELL=/bin/bash
PATH=(custom, user)
LANG=en_AU.UTF-8
SourcePackage: pypolicyd-spf
Uname: Linux 2.6.28-15-generic x86_64
Related branches
Changed in pypolicyd-spf: | |
status: | New → Fix Released |
The problem is This code:
sender_domain = string. split(sender, '@', 1) (reject_ domain_ list, sender_domain[1]):
if spf.domainmatch
If sender has no '@' character, sender_domain ends up as a single element list and trying to index it by [1] results in an IndexError exception.
A robust solution to this (available for python >= 2.5) is:
sender_domain = sender.partition ('@')[2] (reject_ domain_ list, sender_domain):
if spf.domainmatch
The parition method applied to the sender string is guaranteed to return a 3 element tuple of which the [2] indexing grabs the last element.
I've hacked the policy-spf script on my incoming mail gateway as above and its been running for 20 plus hours without a hitch.