Skip to content

Commit

Permalink
[FIX] race condition in session directory creation
Browse files Browse the repository at this point in the history
try to create the directory and handle the possible exception instead of doing
an unsafe 2 step check and creation. 

The issues related to the naming of the directory mentionned in the bug report
are not handled.

lp bug: https://launchpad.net/bugs/1157102 fixed

bzr revid: alexandre.fayolle@camptocamp.com-20130319102008-omtaka8dtq9v7m1l
  • Loading branch information
gurneyalex committed Mar 19, 2013
1 parent a6a8d71 commit 30073a2
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion addons/web/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import urlparse
import uuid
import xmlrpclib
import errno

import babel.core
import simplejson
Expand Down Expand Up @@ -477,8 +478,15 @@ def session_path():
except Exception:
username = "unknown"
path = os.path.join(tempfile.gettempdir(), "oe-sessions-" + username)
if not os.path.exists(path):
try:
os.mkdir(path, 0700)
except OSError as exc:
if exc.errno == errno.EEXIST:
# directory exists: ensure it has the correct permissions
# this will fail if the directory is not owned by the current user
os.chmod(path, 0700)
else:
raise
return path

class Root(object):
Expand Down

0 comments on commit 30073a2

Please sign in to comment.