remove some environment settings during startup

This commit is contained in:
lars 2007-01-20 20:50:36 +00:00
parent c18cec2107
commit b33263b11c

View file

@ -26,6 +26,9 @@
__revision__ = "$Id"
REMOVE_ENV_SETTINGS = [ "LANG", "LC", "LC_ALL", "LC_COLLATE", "LC_CTYPE",
"LC_MESSAGES", "LC_NUMERIC", "BASH_ENV", "SHELLOPTS" ]
import os, sys
import cryptobox.web.sites
from cryptobox.core.exceptions import *
@ -340,6 +343,14 @@ def parseOptions():
return options
def clean_environment(settings_list):
"""Remove some environment settings with side effects (e.g. LANG)
Useful, as some plugins depend on the output of other commands - localized
output would be quite ugly for them ...
"""
for one_setting in settings_list:
os.unsetenv(one_setting)
if __name__ == "__main__":
@ -349,6 +360,8 @@ if __name__ == "__main__":
os.umask(022)
## initialize the webserver class (before forking to get some error messages)
cbw = CryptoBoxWebserver(options)
## remove some environment settings
clean_environment(REMOVE_ENV_SETTINGS)
## fork to background before cbw.start() - otherwise we lose the socket
if options.background:
fork_to_background()