Commit 223ef2a6 authored by Chris McDonough's avatar Chris McDonough

Redid signal handling code.

A couple of documentation and formatting cleanups.

Warn if users are using Python 2.1.X where X < 3.

Warn if users are using Python 2.2.
parent 9d947e72
...@@ -36,7 +36,7 @@ Options: ...@@ -36,7 +36,7 @@ Options:
relative to the Zope location. relative to the Zope location.
To prevent use of a separate management process, provide an To prevent use of a separate management process, provide an
empty string: -Z '' empty string: -Z=''
-t n -t n
...@@ -246,9 +246,6 @@ dummy = codecs.lookup('iso-8859-1') ...@@ -246,9 +246,6 @@ dummy = codecs.lookup('iso-8859-1')
sys.setcheckinterval(120) sys.setcheckinterval(120)
program=sys.argv[0] program=sys.argv[0]
here=os.path.join(os.getcwd(), os.path.split(program)[0]) here=os.path.join(os.getcwd(), os.path.split(program)[0])
Zpid='' Zpid=''
...@@ -291,12 +288,10 @@ HTTP_PORT=8080 ...@@ -291,12 +288,10 @@ HTTP_PORT=8080
# HTTP enivornment settings. # HTTP enivornment settings.
HTTP_ENV={} HTTP_ENV={}
# Should we close all HTTP connections, ignoring the (usually absent) # Should we close all HTTP connections, ignoring the (usually absent)
# 'Connection:' header? # 'Connection:' header?
FORCE_HTTP_CONNECTION_CLOSE=0 FORCE_HTTP_CONNECTION_CLOSE=0
# Port for the special "WebDAV source view" HTTP handler. There is no # Port for the special "WebDAV source view" HTTP handler. There is no
# standard port for this handler, which is disabled by default. # standard port for this handler, which is disabled by default.
WEBDAV_SOURCE_PORT=[] WEBDAV_SOURCE_PORT=[]
...@@ -324,12 +319,9 @@ MODULE='Zope' ...@@ -324,12 +319,9 @@ MODULE='Zope'
# The size of the thread pool, if ZODB3 is used. # The size of the thread pool, if ZODB3 is used.
NUMBER_OF_THREADS=4 NUMBER_OF_THREADS=4
# Localization support # Localization support
LOCALE_ID=None LOCALE_ID=None
# Socket path or port for the FastCGI Server # Socket path or port for the FastCGI Server
FCGI_PORT=None FCGI_PORT=None
...@@ -367,8 +359,27 @@ def server_info(old, v, offset=0): ...@@ -367,8 +359,27 @@ def server_info(old, v, offset=0):
try: try:
if sys.version.split()[0] < '2.1': python_version = sys.version.split()[0]
raise 'Invalid python version', sys.version.split()[0] if python_version < '2.1':
raise 'Invalid python version', python_version
if python_version[:3] == '2.1':
if python_version[4:5] < '3':
import warnings
err = ('You are running Python version %s. This Python version '
'has known bugs that may cause Zope to run improperly. '
'Consider upgrading to a Python in the 2.1 series '
'with at least version number 2.1.3. (Note that Zope does '
'not yet run under any Python 2.2 version).' %
python_version)
warnings.warn(err)
if python_version[:3] == '2.2':
import warnings
err = ('You are running Python version %s. This Python version '
'has not yet been tested with Zope and you may experience '
'operational problems as a result. Consider using '
'Python 2.1.3 instead.' % python_version)
warnings.warn(err)
opts, args = getopt.getopt(sys.argv[1:], opts, args = getopt.getopt(sys.argv[1:],
'hz:Z:t:i:a:d:u:w:W:f:p:m:Sl:2DP:rF:L:XM:C', 'hz:Z:t:i:a:d:u:w:W:f:p:m:Sl:2DP:rF:L:XM:C',
...@@ -499,10 +510,6 @@ def set_locale(val): ...@@ -499,10 +510,6 @@ def set_locale(val):
if LOCALE_ID is not None: if LOCALE_ID is not None:
set_locale(LOCALE_ID) set_locale(LOCALE_ID)
# Import SignalHandler to install the default signal handlers.
from SignalHandler import SignalHandler
# from this point forward we can use the zope logger # from this point forward we can use the zope logger
# Import ZServer before we open the database or get at interesting # Import ZServer before we open the database or get at interesting
...@@ -511,19 +518,23 @@ from SignalHandler import SignalHandler ...@@ -511,19 +518,23 @@ from SignalHandler import SignalHandler
import ZServer import ZServer
import zdaemon import zdaemon
# install signal handlers
from SignalHandler import SignalHandler
if Zpid and not READ_ONLY: if Zpid and not READ_ONLY:
import App.FindHomes, posix import App.FindHomes
sys.ZMANAGED=1 sys.ZMANAGED=1
# zdaemon.run creates a process which "manages" the actual Zope
zdaemon.run(sys.argv, os.path.join(CLIENT_HOME, Zpid), # process (restarts it if it dies). The management process passes along
SignalHandler.getRegisteredSignals()) # signals that it receives to its child.
zdaemon.run(sys.argv, os.path.join(CLIENT_HOME, Zpid))
os.chdir(CLIENT_HOME) os.chdir(CLIENT_HOME)
def _warn_nobody(): def _warn_nobody():
zLOG.LOG("z2", zLOG.INFO, "Running Zope as 'nobody' can compromise " + \ zLOG.LOG("z2", zLOG.INFO, ("Running Zope as 'nobody' can compromise "
"your Zope files; consider using a " + \ "your Zope files; consider using a "
"dedicated user account for Zope") "dedicated user account for Zope") )
try: try:
# Import logging support # Import logging support
...@@ -593,7 +604,9 @@ try: ...@@ -593,7 +604,9 @@ try:
zLOG.LOG('z2', zLOG.BLATHER, 'Logging access log to stdout') zLOG.LOG('z2', zLOG.BLATHER, 'Logging access log to stdout')
elif os.environ.has_key('ZSYSLOG_ACCESS'): elif os.environ.has_key('ZSYSLOG_ACCESS'):
if os.environ.has_key("ZSYSLOG_ACCESS_FACILITY"): if os.environ.has_key("ZSYSLOG_ACCESS_FACILITY"):
lg = logger.syslog_logger(os.environ['ZSYSLOG_ACCESS'],facility=os.environ['ZSYSLOG_ACCESS_FACILITY']) lg = logger.syslog_logger(
os.environ['ZSYSLOG_ACCESS'],
facility=os.environ['ZSYSLOG_ACCESS_FACILITY'])
else: else:
lg = logger.syslog_logger(os.environ['ZSYSLOG_ACCESS']) lg = logger.syslog_logger(os.environ['ZSYSLOG_ACCESS'])
zLOG.LOG('z2', zLOG.BLATHER, 'Using local syslog access log') zLOG.LOG('z2', zLOG.BLATHER, 'Using local syslog access log')
...@@ -757,8 +770,8 @@ try: ...@@ -757,8 +770,8 @@ try:
except: except:
raise SystemExit, 'initgroups is required to safely setuid' raise SystemExit, 'initgroups is required to safely setuid'
if UID == None: if UID == None:
raise SystemExit, 'A user was not specified to setuid ' + \ raise SystemExit, ('A user was not specified to setuid '
'to; fix this to start as root' 'to; fix this to start as root')
import stat import stat
client_home_stat = os.stat(CLIENT_HOME) client_home_stat = os.stat(CLIENT_HOME)
client_home_faults = [] client_home_faults = []
...@@ -766,10 +779,11 @@ try: ...@@ -766,10 +779,11 @@ try:
client_home_faults.append('does not have the sticky bit set') client_home_faults.append('does not have the sticky bit set')
if client_home_stat[stat.ST_UID] != 0: if client_home_stat[stat.ST_UID] != 0:
client_home_faults.append('is not owned by root') client_home_faults.append('is not owned by root')
if len(client_home_faults) > 0: if client_home_faults:
raise SystemExit, CLIENT_HOME + ' ' + \ client_home_faults.append('fix this to start as root.')
string.join(client_home_faults, ', ') + \ err = '%s %s' % (CLIENT_HOME, ', '.join(client_home_faults))
'; fix this to start as root' raise SystemExit, err
try: try:
try: UID = string.atoi(UID) try: UID = string.atoi(UID)
except: pass except: pass
...@@ -809,11 +823,10 @@ try: ...@@ -809,11 +823,10 @@ try:
os.umask(current_umask) os.umask(current_umask)
if current_umask != 077: if current_umask != 077:
current_umask = '%03o' % current_umask current_umask = '%03o' % current_umask
zLOG.LOG("z2", zLOG.INFO, 'Your umask of ' + current_umask + \ zLOG.LOG("z2", zLOG.INFO, (
' may be too permissive; for the security of your ' + \ 'Your umask of %s may be too permissive; for the security of '
'Zope data, it is recommended you use 077') 'your Zope data, it is recommended you use 077' % current_umask
))
except: except:
# Log startup exception and tell zdaemon not to restart us. # Log startup exception and tell zdaemon not to restart us.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment