mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/tglx/remail.git
synced 2024-11-28 07:12:39 +01:00
05ac7bb6ac
When using pipe mode configuration updates are not handled until the next mail is sent to the list. That means that e.g. welcome mails are delayed. Add a command line option to allow the invocation of remail_pipe just to deal with configuration updates without trying to process mail from stdin. The update handling is serialized against concurrent incoming mail via the folder lock, so no extra serialization is required. Whichever comes first handles it. Reported-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
60 lines
1.9 KiB
Python
Executable file
60 lines
1.9 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
# Copyright Thomas Gleixner <tglx@linutronix.de>
|
|
#
|
|
|
|
from remail.utils import logger
|
|
from remail.version import __version__
|
|
from remail.remaild import remaild
|
|
|
|
from argparse import ArgumentParser
|
|
|
|
import sys
|
|
import os
|
|
|
|
def exit_daemon(logger, res):
|
|
logger.log('Stopped\n')
|
|
sys.exit(res)
|
|
|
|
if __name__ == '__main__':
|
|
parser = ArgumentParser(description='remail pipe')
|
|
parser.add_argument('config', help='Config file')
|
|
parser.add_argument('--cfgupdate', '-c', dest='cfgupdate',
|
|
action='store_true',
|
|
help='Handle config file update. No mail processing.')
|
|
parser.add_argument('--syslog', '-s', dest='syslog', action='store_true',
|
|
help='Use syslog for logging. Default is stderr')
|
|
parser.add_argument('--verbose', '-v', dest='verbose', action='store_true',
|
|
help='Verbose logging')
|
|
parser.add_argument('--version', '-V', action='version',
|
|
version='%(prog)s {version}'.format(version=__version__))
|
|
args = parser.parse_args()
|
|
|
|
logger = logger(use_syslog=args.syslog, verbose=args.verbose)
|
|
logger.log("Started\n")
|
|
|
|
# Change into the directory in which the config file resides
|
|
wdir = os.path.dirname(args.config)
|
|
if len(wdir):
|
|
os.chdir(wdir)
|
|
args.config = os.path.basename(args.config)
|
|
|
|
try:
|
|
rd = remaild(args.config, logger)
|
|
except Exception as ex:
|
|
'''
|
|
Exceptions which reach here are fatal
|
|
'''
|
|
logger.log_exception('', ex, verbose=True)
|
|
exit_daemon(logger, 11)
|
|
|
|
try:
|
|
res = rd.handle_pipe(args.cfgupdate)
|
|
except Exception as ex:
|
|
'''
|
|
Exceptions which reach here are fatal
|
|
'''
|
|
logger.log_exception('', ex, verbose=True)
|
|
res = 12
|
|
|
|
exit_daemon(logger, res)
|