diff options
Diffstat (limited to 'src/mailman/commands/cli_control.py')
| -rw-r--r-- | src/mailman/commands/cli_control.py | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/src/mailman/commands/cli_control.py b/src/mailman/commands/cli_control.py index 7b8d17723..f58005e0f 100644 --- a/src/mailman/commands/cli_control.py +++ b/src/mailman/commands/cli_control.py @@ -1,4 +1,4 @@ -# Copyright (C) 2009-2013 by the Free Software Foundation, Inc. +# Copyright (C) 2009-2015 by the Free Software Foundation, Inc. # # This file is part of GNU Mailman. # @@ -15,11 +15,8 @@ # You should have received a copy of the GNU General Public License along with # GNU Mailman. If not, see <http://www.gnu.org/licenses/>. -"""Module stuff.""" +"""Start/stop/reopen/restart commands.""" -from __future__ import absolute_import, print_function, unicode_literals - -__metaclass__ = type __all__ = [ 'Reopen', 'Restart', @@ -34,12 +31,11 @@ import errno import signal import logging -from zope.interface import implementer - from mailman.bin.master import WatcherState, master_state from mailman.config import config from mailman.core.i18n import _ from mailman.interfaces.command import ICLISubCommand +from zope.interface import implementer qlog = logging.getLogger('mailman.runner') @@ -107,6 +103,19 @@ class Start: def log(message): if not args.quiet: print(message) + # Try to find the path to a valid, existing configuration file, and + # refuse to start if one cannot be found. + if args.config is not None: + config_path = args.config + elif config.filename is not None: + config_path = config.filename + else: + config_path = os.path.join(config.VAR_DIR, 'etc', 'mailman.cfg') + if not os.path.exists(config_path): + print(_("""\ +No valid configuration file could be found, so Mailman will refuse to start. +Use -C/--config to specify a valid configuration file."""), file=sys.stderr) + sys.exit(1) # Daemon process startup according to Stevens, Advanced Programming in # the UNIX Environment, Chapter 13. pid = os.fork() @@ -121,11 +130,7 @@ class Start: os.setsid() # Instead of cd'ing to root, cd to the Mailman runtime directory. # However, before we do that, set an environment variable used by the - # subprocesses to calculate their path to the $VAR_DIR. Before we - # chdir() though, calculate the absolute path to the configuration - # file. - config_path = (os.path.abspath(args.config) - if args.config else None) + # subprocesses to calculate their path to the $VAR_DIR. os.environ['MAILMAN_VAR_DIR'] = config.VAR_DIR os.chdir(config.VAR_DIR) # Exec the master watcher. @@ -135,8 +140,9 @@ class Start: ] if args.force: execl_args.append('--force') - if config_path: - execl_args.extend(['-C', config_path]) + # Always pass the config file path to the master projects, so there's + # no confusion about which cfg is being used. + execl_args.extend(['-C', config_path]) qlog.debug('starting: %s', execl_args) os.execl(*execl_args) # We should never get here. |
