summaryrefslogtreecommitdiff
path: root/src/mailman
diff options
context:
space:
mode:
Diffstat (limited to 'src/mailman')
-rw-r--r--src/mailman/bin/master.py10
-rw-r--r--src/mailman/config/schema.cfg5
2 files changed, 13 insertions, 2 deletions
diff --git a/src/mailman/bin/master.py b/src/mailman/bin/master.py
index ef64f3d83..af6486c48 100644
--- a/src/mailman/bin/master.py
+++ b/src/mailman/bin/master.py
@@ -334,7 +334,7 @@ class Loop:
log.info('Master watcher caught SIGINT. Restarting.')
signal.signal(signal.SIGINT, sigint_handler)
- def _start_runner(self, spec):
+ def _start_runner(self, spec, user_string):
"""Start a runner.
All arguments are passed to the process.
@@ -342,6 +342,8 @@ class Loop:
:param spec: A runner spec, in a format acceptable to
bin/runner's --runner argument, e.g. name:slice:count
:type spec: string
+ :param user_string: The user[:group] to run as.
+ :type user_string: string
:return: The process id of the child runner.
:rtype: int
"""
@@ -362,6 +364,9 @@ class Loop:
# config.PYTHON, which is the absolute path to the Python interpreter,
# must be given as argv[0] due to Python's library search algorithm.
args = [sys.executable, sys.executable, exe, rswitch]
+ # Append user option if provided.
+ if user_string:
+ args.append('--user=' + user_string)
# Always pass the explicit path to the configuration file to the
# sub-runners. This avoids any debate about which cfg file is used.
config_file = (config.filename if self._config_file is None
@@ -411,13 +416,14 @@ class Loop:
# Find out how many runners to instantiate. This must be a power
# of 2.
count = int(runner_config.instances)
+ user = runner_config.user
assert (count & (count - 1)) == 0, (
'Runner "{0}", not a power of 2: {1}'.format(name, count))
for slice_number in range(count):
# runner name, slice #, # of slices, restart count
info = (name, slice_number, count, 0)
spec = '{0}:{1:d}:{2:d}'.format(name, slice_number, count)
- pid = self._start_runner(spec)
+ pid = self._start_runner(spec, user)
log = logging.getLogger('mailman.runner')
log.debug('[{0:d}] {1}'.format(pid, spec))
self._kids.add(pid, info)
diff --git a/src/mailman/config/schema.cfg b/src/mailman/config/schema.cfg
index a55c37ff4..79d6c8697 100644
--- a/src/mailman/config/schema.cfg
+++ b/src/mailman/config/schema.cfg
@@ -223,6 +223,11 @@ instances: 1
# Whether to start this runner or not.
start: yes
+# Start under this user. Can have a format of:
+# user
+# user:group
+user:
+
# The maximum number of restarts for this runner. When the runner exits
# because of an error or other unexpected problem, it is automatically
# restarted, until the maximum number of restarts has been reached.