pbuilder-dist subject to race conditions

Bug #398972 reported by Rylie Pavlik
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
ubuntu-dev-tools (Ubuntu)
Won't Fix
Undecided
Unassigned

Bug Description

Binary package hint: ubuntu-dev-tools

In the Python code of pbuilder-dist, a number of calls are of the "look before you leap" form (rather than the pythonic "Easier to ask forgiveness" idiom) which can lead to race conditions. An example "bad call" is on line 93:

if not os.path.exists(self.base):
    os.makedirs(self.base)

Should be more like this:

try:
    os.makedirs(self.base)
except os.error, e:
    if e.errno != errno.EEXIST:
    raise

In a quick skim, I see at least these line numbers in Jaunty:
78 possibly (better to just do run a "which " + builder command, like getoutput('which ' + self.builder) and parse it, IMHO)
93 (example above)
104 (open inside of a try-catch and catch only the error meaning file not found/inaccessible)
204

A reference on EAFP vs LBYL is here:
http://jaynes.colorado.edu/PythonIdioms.html#eafp

Revision history for this message
Siegfried Gevatter (rainct) wrote :

The exception is slower and less readable, and the risk of a race condition here is pretty much negligible.

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Siegfried, should this ticket be set to wontfix, then?

Changed in ubuntu-dev-tools (Ubuntu):
status: New → Won't Fix
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.