Fix traceback to correctly deal with source port already in use errors

Bug #1318264 reported by Scott Kitterman on 2014-05-11
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
py3dns
Status tracked in Trunk
3.0
High
Unassigned
Trunk
High
Unassigned
py3dns (Ubuntu)
High
Unassigned
Precise
Low
Unassigned
Quantal
Low
Unassigned
Saucy
Low
Unassigned
Trusty
High
Scott Kitterman
Utopic
High
Unassigned

Bug Description

[Impact]

 * Causes random tracebacks on DNS lookups when break functionality of packages that use the module. In the case the bug was filed for, the impact would be a postfix server returning servfail and deferring message traffic.

 * The code represents a missed change for the port from python to python3.

[Test Case]

 * This bug only happens when multiple DNS queries attempt to use the same port at the same time. It's very difficult to reproduce and as far as I know impossible to do it consistently. The attached script demonstrates the new code working and the old code failing. That and code inspection are the best ways to verify this.

[Regression Potential]

 * Regression potential is nil.

Note: This is an extract from a private bug.

Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/DNS/Base.py", line 192, in getSource
self.s.bind(('', source_port))
OSError: [Errno 98] Address already in use

During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/policyd-spf", line 662, in <module>
instance_dict, configData, peruser)
File "/usr/bin/policyd-spf", line 508, in _spfcheck
res = spf.check2(ip, sender, helo)
File "/usr/lib/python3/dist-packages/spf.py", line 363, in check2
receiver=receiver,timeout=timeout,verbose=verbose,querytime=querytime).check()
File "/usr/lib/python3/dist-packages/spf.py", line 607, in check
spf = self.dns_spf(self.d)
File "/usr/lib/python3/dist-packages/spf.py", line 1179, in dns_spf
a = [t for t in self.dns_txt(domain) if RE_SPF.match(t)]
File "/usr/lib/python3/dist-packages/spf.py", line 1227, in dns_txt
dns_list = self.dns(domainname, rr)
File "/usr/lib/python3/dist-packages/spf.py", line 1357, in dns
for k, v in DNSLookup(name, qtype, self.strict, timeout):
File "/usr/lib/python3/dist-packages/spf.py", line 193, in DNSLookup
resp = req.req()
File "/usr/lib/python3/dist-packages/DNS/Base.py", line 238, in req
self.sendUDPRequest(server)
File "/usr/lib/python3/dist-packages/DNS/Base.py", line 263, in sendUDPRequest
self.conn()
File "/usr/lib/python3/dist-packages/DNS/Base.py", line 199, in conn
self.getSource()
File "/usr/lib/python3/dist-packages/DNS/Base.py", line 196, in getSource
if msg[0] != 98: raise
TypeError: 'OSError' object is not subscriptable
warning: missing attribute action in input from private/policyd-spf
warning: command /usr/bin/policyd-spf exit status 1

Note that the policy server exiting non-zero will intefere with mail delivery.

Scott Kitterman (kitterman) wrote :

Fixed upstream in 3.1.0 and in trunk for the 3.0 branch for if that's ever released again.

Scott Kitterman (kitterman) wrote :

Low priority for pre-14.04 due to lack of rdepends likely to have significant usage.

Changed in py3dns (Ubuntu Utopic):
status: New → Fix Released
importance: Undecided → High
Changed in py3dns (Ubuntu Trusty):
status: New → In Progress
importance: Undecided → High
assignee: nobody → Scott Kitterman (kitterman)
milestone: none → ubuntu-14.04.1
Changed in py3dns (Ubuntu Precise):
status: New → Won't Fix
Changed in py3dns (Ubuntu Quantal):
status: New → Won't Fix
Changed in py3dns (Ubuntu Saucy):
status: New → Won't Fix
importance: Undecided → Low
Changed in py3dns (Ubuntu Quantal):
importance: Undecided → Low
Changed in py3dns (Ubuntu Precise):
importance: Undecided → Low
Scott Kitterman (kitterman) wrote :
description: updated

Hello Scott, or anyone else affected,

Accepted py3dns into trusty-proposed. The package will build now and be available at http://launchpad.net/ubuntu/+source/py3dns/3.0.4-1ubuntu1 in a few hours, and then in the -proposed repository.

Please help us by testing this new package. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Your feedback will aid us getting this update out to other Ubuntu users.

If this package fixes the bug for you, please add a comment to this bug, mentioning the version of the package you tested, and change the tag from verification-needed to verification-done. If it does not fix the bug for you, please add a comment stating that, and change the tag to verification-failed. In either case, details of your testing will help us make a better decision.

Further information regarding the verification process can be found at https://wiki.ubuntu.com/QATeam/PerformingSRUVerification . Thank you in advance!

Changed in py3dns (Ubuntu Trusty):
status: In Progress → Fix Committed
tags: added: verification-needed
Scott Kitterman (kitterman) wrote :

I ran the upstream pypolicyd-spf test suite multiple times with the new package and was unable to reproduce the error (in the past I was able to at least intermittently reproduce it with the test suite) and confirmed via code inspection that the installed package has the correct change.

tags: added: verification-done
removed: verification-needed

The verification of the Stable Release Update for py3dns has completed successfully and the package has now been released to -updates. Subsequently, the Ubuntu Stable Release Updates Team is being unsubscribed and will not receive messages about this bug report. In the event that you encounter a regression using the package from -updates please report a new bug using ubuntu-bug and tag the bug report regression-update so we can easily find any regresssions.

Launchpad Janitor (janitor) wrote :

This bug was fixed in the package py3dns - 3.0.4-1ubuntu1

---------------
py3dns (3.0.4-1ubuntu1) trusty-proposed; urgency=medium

  * Backport fix from 3.1/trunk to correctly deal with source port already in
    use errors (LP: #1318264)
 -- Scott Kitterman <email address hidden> Sat, 10 May 2014 20:42:17 -0400

Changed in py3dns (Ubuntu Trusty):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers