summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2024-12-17 20:17:02 +0100
committerChristian Breunig <christian@breunig.cc>2024-12-17 20:17:02 +0100
commitbbae4221e39d81e81136c047dfa487a21d0022a9 (patch)
tree7b3996cefbde95bd5e3617757fa20c72b2207f07
parent14c42992bb66923c52e7bf849afb29782c32da1f (diff)
downloadvyos-1x-bbae4221e39d81e81136c047dfa487a21d0022a9.tar.gz
vyos-1x-bbae4221e39d81e81136c047dfa487a21d0022a9.zip
frrender: T6746: ensure there are no empty lines in the rendered FRR configuration
-rw-r--r--python/vyos/frrender.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/python/vyos/frrender.py b/python/vyos/frrender.py
index 95d6c7243..7221d5053 100644
--- a/python/vyos/frrender.py
+++ b/python/vyos/frrender.py
@@ -136,7 +136,7 @@ class FRRender:
output += '\n'
if 'vrf' in config and 'name' in config['vrf']:
- output += render_to_string('frr/zebra.vrf.route-map.frr.j2', config['vrf']) + '\n'
+ output += render_to_string('frr/zebra.vrf.route-map.frr.j2', config['vrf'])
for vrf, vrf_config in config['vrf']['name'].items():
if 'protocols' not in vrf_config:
continue
@@ -145,6 +145,12 @@ class FRRender:
output += inline_helper(vrf_config['protocols'])
+ # remove any accidently added empty newline to not confuse FRR
+ output = os.linesep.join([s for s in output.splitlines() if s])
+
+ if '!!' in output:
+ raise ConfigError('FRR configuration contains "!!" which is not allowed')
+
debug(output)
debug('======< RENDERING CONFIG COMPLETE >======')
write_file(self._frr_conf, output)