Merge lp:~camptocamp/openerp-web/7.0-fix-1157102 into lp:openerp-web/7.0

Proposed by Alexandre Fayolle - camptocamp
Status: Merged
Merged at revision: 3906
Proposed branch: lp:~camptocamp/openerp-web/7.0-fix-1157102
Merge into: lp:openerp-web/7.0
Diff against target: 28 lines (+9/-1)
1 file modified
addons/web/http.py (+9/-1)
To merge this branch: bzr merge lp:~camptocamp/openerp-web/7.0-fix-1157102
Reviewer Review Type Date Requested Status
Nicolas Vanhoren (OpenERP) (community) Approve
Review via email: mp+154032@code.launchpad.net

Description of the change

[FIX] race condition in session directory creation

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 mentioned in the bug report
are not handled.

To post a comment you must log in.
Revision history for this message
Nicolas Vanhoren (OpenERP) (niv-openerp) wrote :

Seems ok to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/http.py'
--- addons/web/http.py 2013-03-01 17:16:16 +0000
+++ addons/web/http.py 2013-03-19 10:27:24 +0000
@@ -20,6 +20,7 @@
20import urlparse20import urlparse
21import uuid21import uuid
22import xmlrpclib22import xmlrpclib
23import errno
2324
24import babel.core25import babel.core
25import simplejson26import simplejson
@@ -477,8 +478,15 @@
477 except Exception:478 except Exception:
478 username = "unknown"479 username = "unknown"
479 path = os.path.join(tempfile.gettempdir(), "oe-sessions-" + username)480 path = os.path.join(tempfile.gettempdir(), "oe-sessions-" + username)
480 if not os.path.exists(path):481 try:
481 os.mkdir(path, 0700)482 os.mkdir(path, 0700)
483 except OSError as exc:
484 if exc.errno == errno.EEXIST:
485 # directory exists: ensure it has the correct permissions
486 # this will fail if the directory is not owned by the current user
487 os.chmod(path, 0700)
488 else:
489 raise
482 return path490 return path
483491
484class Root(object):492class Root(object):