summaryrefslogtreecommitdiff
path: root/src/mailman/commands/cli_control.py
diff options
context:
space:
mode:
authorBarry Warsaw2015-01-20 14:53:16 -0500
committerBarry Warsaw2015-01-20 14:53:16 -0500
commit559eac349a08f8eda8f11e7b8254285a0c2d393e (patch)
tree730953962ff1ae4113f83c651a0aa6c2f2eaf3f0 /src/mailman/commands/cli_control.py
parent7023082164c5ee67cd183b74af0b756707b87818 (diff)
downloadmailman-559eac349a08f8eda8f11e7b8254285a0c2d393e.tar.gz
mailman-559eac349a08f8eda8f11e7b8254285a0c2d393e.tar.zst
mailman-559eac349a08f8eda8f11e7b8254285a0c2d393e.zip
Diffstat (limited to 'src/mailman/commands/cli_control.py')
-rw-r--r--src/mailman/commands/cli_control.py19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/mailman/commands/cli_control.py b/src/mailman/commands/cli_control.py
index 7b0291229..f58005e0f 100644
--- a/src/mailman/commands/cli_control.py
+++ b/src/mailman/commands/cli_control.py
@@ -103,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()
@@ -117,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 = (config.filename if args.config is None
- else os.path.abspath(args.config))
+ # 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.