remove some environment settings during startup
This commit is contained in:
parent
c18cec2107
commit
b33263b11c
1 changed files with 13 additions and 0 deletions
|
@ -26,6 +26,9 @@
|
||||||
|
|
||||||
__revision__ = "$Id"
|
__revision__ = "$Id"
|
||||||
|
|
||||||
|
REMOVE_ENV_SETTINGS = [ "LANG", "LC", "LC_ALL", "LC_COLLATE", "LC_CTYPE",
|
||||||
|
"LC_MESSAGES", "LC_NUMERIC", "BASH_ENV", "SHELLOPTS" ]
|
||||||
|
|
||||||
import os, sys
|
import os, sys
|
||||||
import cryptobox.web.sites
|
import cryptobox.web.sites
|
||||||
from cryptobox.core.exceptions import *
|
from cryptobox.core.exceptions import *
|
||||||
|
@ -340,6 +343,14 @@ def parseOptions():
|
||||||
return options
|
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__":
|
if __name__ == "__main__":
|
||||||
|
@ -349,6 +360,8 @@ if __name__ == "__main__":
|
||||||
os.umask(022)
|
os.umask(022)
|
||||||
## initialize the webserver class (before forking to get some error messages)
|
## initialize the webserver class (before forking to get some error messages)
|
||||||
cbw = CryptoBoxWebserver(options)
|
cbw = CryptoBoxWebserver(options)
|
||||||
|
## remove some environment settings
|
||||||
|
clean_environment(REMOVE_ENV_SETTINGS)
|
||||||
## fork to background before cbw.start() - otherwise we lose the socket
|
## fork to background before cbw.start() - otherwise we lose the socket
|
||||||
if options.background:
|
if options.background:
|
||||||
fork_to_background()
|
fork_to_background()
|
||||||
|
|
Loading…
Reference in a new issue