[FIX]Fixed the issue of session storage directory created with wrong username when someone restart the server using sudo.

bzr revid: msh@openerp.com-20130521105206-8oka7n7t9z13uiwo
This commit is contained in:
Mohammed Shekha 2013-05-21 16:22:06 +05:30
parent c8136cee66
commit 0dc578fc9c
1 changed files with 7 additions and 3 deletions

View File

@ -488,9 +488,13 @@ class DisableCacheMiddleware(object):
def session_path():
try:
username = getpass.getuser()
except Exception:
username = "unknown"
import pwd
username = pwd.getpwuid(os.getuid()).pw_name
except ImportError:
try:
username = getpass.getuser()
except Exception:
username = "unknown"
path = os.path.join(tempfile.gettempdir(), "oe-sessions-" + username)
try:
os.mkdir(path, 0700)