diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/mailman/config/config.py | 22 | ||||
| -rw-r--r-- | src/mailman/config/mailman.cfg | 2 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/mailman/config/config.py b/src/mailman/config/config.py index e7d8b6b17..1aab4a82a 100644 --- a/src/mailman/config/config.py +++ b/src/mailman/config/config.py @@ -46,6 +46,8 @@ from zope.interface import implementer SPACE = ' ' +SPACERS = '\n' + MAILMAN_CFG_TEMPLATE = """\ # AUTOMATICALLY GENERATED BY MAILMAN ON {} @@ -185,26 +187,32 @@ class Configuration: lock_file = category.lock_file, pid_file = category.pid_file, ) + # Add the path to the .cfg file, if one was given on the command line. + if self.filename is not None: + substitutions['cfg_file'] = self.filename # Now, perform substitutions recursively until there are no more # variables with $-vars in them, or until substitutions are not # helping any more. last_dollar_count = 0 while True: + expandables = [] # Mutate the dictionary during iteration. - dollar_count = 0 - for key in substitutions.keys(): + for key in substitutions: raw_value = substitutions[key] value = Template(raw_value).safe_substitute(substitutions) if '$' in value: # Still more work to do. - dollar_count += 1 + expandables.append((key, value)) substitutions[key] = value - if dollar_count == 0: + if len(expandables) == 0: break - if dollar_count == last_dollar_count: - print('Path expansion infloop detected', file=sys.stderr) + if len(expandables) == last_dollar_count: + print('Path expansion infloop detected:\n', + SPACERS.join('\t{}: {}'.format(key, value) + for key, value in sorted(expandables)), + file=sys.stderr) sys.exit(1) - last_dollar_count = dollar_count + last_dollar_count = len(expandables) # Ensure that all paths are normalized and made absolute. Handle the # few special cases first. Most of these are due to backward # compatibility. diff --git a/src/mailman/config/mailman.cfg b/src/mailman/config/mailman.cfg index 24e81ec91..80da56ddc 100644 --- a/src/mailman/config/mailman.cfg +++ b/src/mailman/config/mailman.cfg @@ -25,7 +25,7 @@ [paths.dev] # Convenient development layout where everything is put in the current # directory. -var_dir: var +var_dir: $cfg_file/../.. [paths.fhs] # Filesystem Hiearchy Standard 2.3 |
