[FIX] possible race condition when creating the session file for the web server

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

bzr revid: nicolas.vanhoren@openerp.com-20130422082952-yldmbmmx2rhol2pw
This commit is contained in:
niv-openerp
2013-04-22 10:29:52 +02:00
+9 -1
View File
@@ -20,6 +20,7 @@ import traceback
import urlparse
import uuid
import xmlrpclib
import errno
import babel.core
import simplejson
@@ -523,8 +524,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):