[Bug 398972] [NEW] pbuilder-dist subject to race conditions

Ryan Pavlik abiryan at ryand.net
Mon Jul 13 19:44:23 UTC 2009


Public bug reported:

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

** Affects: ubuntu-dev-tools (Ubuntu)
     Importance: Undecided
         Status: New

-- 
pbuilder-dist subject to race conditions
https://bugs.launchpad.net/bugs/398972
You received this bug notification because you are a member of MOTU,
which is subscribed to ubuntu-dev-tools in ubuntu.




More information about the universe-bugs mailing list