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
1=== modified file 'addons/web/http.py'
2--- addons/web/http.py 2013-03-01 17:16:16 +0000
3+++ addons/web/http.py 2013-03-19 10:27:24 +0000
4@@ -20,6 +20,7 @@
5 import urlparse
6 import uuid
7 import xmlrpclib
8+import errno
9
10 import babel.core
11 import simplejson
12@@ -477,8 +478,15 @@
13 except Exception:
14 username = "unknown"
15 path = os.path.join(tempfile.gettempdir(), "oe-sessions-" + username)
16- if not os.path.exists(path):
17+ try:
18 os.mkdir(path, 0700)
19+ except OSError as exc:
20+ if exc.errno == errno.EEXIST:
21+ # directory exists: ensure it has the correct permissions
22+ # this will fail if the directory is not owned by the current user
23+ os.chmod(path, 0700)
24+ else:
25+ raise
26 return path
27
28 class Root(object):