[IMP] cli: allows to run odoo with openshift

For containers using random uids[1], use the higher level method getpass.getuser
which as the same effect but also looks consider the environment variables to
determine the user name.

Details from
http://blog.dscpl.com.au/2015/12/unknown-user-when-running-docker.html

CLA signature for akram

Closes #26452

[1] openshift or docker as explained at
http://blog.dscpl.com.au/2015/12/random-user-ids-when-running-docker.html
This commit is contained in:
Akram Ben Aissi
2018-08-21 08:34:14 +02:00
committed by Martin Trigaux
parent f4ee61f950
commit cae7c71635
2 changed files with 11 additions and 2 deletions
+2 -2
View File
@@ -36,8 +36,8 @@ _logger = logging.getLogger('odoo')
def check_root_user():
"""Warn if the process's user is 'root' (on POSIX system)."""
if os.name == 'posix':
import pwd
if pwd.getpwuid(os.getuid())[0] == 'root':
import getpass
if getpass.getuser() == 'root':
sys.stderr.write("Running as user 'root' is a security risk.\n")
def check_postgres_user():