Don't allow the server to run as root.

bzr revid: p_christ@hol.gr-20081223081833-q3x6y72cjx3heftn
This commit is contained in:
P. Christeas 2008-12-23 10:18:33 +02:00
parent 2c93807e19
commit 0a91836a8e
1 changed files with 7 additions and 1 deletions

View File

@ -34,7 +34,7 @@ GNU Public Licence.
#----------------------------------------------------------
# python imports
#----------------------------------------------------------
import sys, os, signal
import sys, os, signal,pwd
#----------------------------------------------------------
# ubuntu 8.04 has obsoleted `pyxml` package and installs here.
# the path needs to be updated before any `import xml`
@ -49,6 +49,12 @@ import release
__author__ = release.author
__version__ = release.version
# We DON't log this using the standard logger, because we might mess
# with the logfile's permissions. Just do a quick exit here.
if pwd.getpwuid(os.getuid())[0] == 'root' :
sys.stderr.write("Attempted to run OpenERP server as root. This is not good, aborting.\n")
sys.exit(1)
#----------------------------------------------------------
# get logger
#----------------------------------------------------------