diff options
author | Christian Breunig <christian@breunig.cc> | 2024-01-03 11:51:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-03 11:51:27 +0100 |
commit | 48f2a0a8d2fe182f057a09e0af7ed78746a223a2 (patch) | |
tree | a8ac8e975d10c8b764cecea94490a20e6588f6cb /python | |
parent | 03a74692b4ac5d7e8d31976676af8930ac7c84ac (diff) | |
parent | d61f5a269b17b4926ad848a14786ef7291ec0352 (diff) | |
download | vyos-1x-48f2a0a8d2fe182f057a09e0af7ed78746a223a2.tar.gz vyos-1x-48f2a0a8d2fe182f057a09e0af7ed78746a223a2.zip |
Merge pull request #2732 from vyos/mergify/bp/sagitta/pr-2728
T5880: verify_source_interface() should not allow dynamic interfaces like ppp, l2tp, ipoe or sstpc client interfaces (backport #2728)
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/configverify.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/python/vyos/configverify.py b/python/vyos/configverify.py index 27055c863..85423142d 100644 --- a/python/vyos/configverify.py +++ b/python/vyos/configverify.py @@ -281,16 +281,22 @@ def verify_source_interface(config): perform recurring validation of the existence of a source-interface required by e.g. peth/MACvlan, MACsec ... """ + import re from netifaces import interfaces - if 'source_interface' not in config: - raise ConfigError('Physical source-interface required for ' - 'interface "{ifname}"'.format(**config)) - if config['source_interface'] not in interfaces(): - raise ConfigError('Specified source-interface {source_interface} does ' - 'not exist'.format(**config)) + ifname = config['ifname'] + if 'source_interface' not in config: + raise ConfigError(f'Physical source-interface required for "{ifname}"!') src_ifname = config['source_interface'] + # We do not allow sourcing other interfaces (e.g. tunnel) from dynamic interfaces + tmp = re.compile(r'(ppp|pppoe|sstpc|l2tp|ipoe)[0-9]+') + if tmp.match(src_ifname): + raise ConfigError(f'Can not source "{ifname}" from dynamic interface "{src_ifname}"!') + + if src_ifname not in interfaces(): + raise ConfigError(f'Specified source-interface {src_ifname} does not exist') + if 'source_interface_is_bridge_member' in config: bridge_name = next(iter(config['source_interface_is_bridge_member'])) raise ConfigError(f'Invalid source-interface "{src_ifname}". Interface ' @@ -303,7 +309,6 @@ def verify_source_interface(config): if 'is_source_interface' in config: tmp = config['is_source_interface'] - src_ifname = config['source_interface'] raise ConfigError(f'Can not use source-interface "{src_ifname}", it already ' \ f'belongs to interface "{tmp}"!') |