summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2023-01-04 20:12:47 +0100
committerChristian Poessinger <christian@poessinger.com>2023-01-04 20:13:04 +0100
commitd1ef90e1eb51334b99ad716969e17c7f257e1a39 (patch)
tree117e59bce79d5f74d2bb76fa02e92b466f118bf6 /src
parent87cc636bd2baf576a2a5ece7a4f8318eb4f69c2e (diff)
downloadvyos-1x-d1ef90e1eb51334b99ad716969e17c7f257e1a39.tar.gz
vyos-1x-d1ef90e1eb51334b99ad716969e17c7f257e1a39.zip
ssh: T2651: extend verify() when both source-address and source-interface is used
We need to ensure that source-address is assigned on source-interface before applying the configuration, else SSH client will have a hard time talking to someone.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/conf_mode/system-option.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/conf_mode/system-option.py b/src/conf_mode/system-option.py
index ceac3dc16..e6c7a0ed2 100755
--- a/src/conf_mode/system-option.py
+++ b/src/conf_mode/system-option.py
@@ -27,6 +27,7 @@ from vyos.template import render
from vyos.util import cmd
from vyos.util import is_systemd_service_running
from vyos.validate import is_addr_assigned
+from vyos.validate import is_intf_addr_assigned
from vyos.xml import defaults
from vyos import ConfigError
from vyos import airbag
@@ -69,10 +70,17 @@ def verify(options):
if 'ssh_client' in options:
config = options['ssh_client']
if 'source_address' in config:
+ address = config['source_address']
if not is_addr_assigned(config['source_address']):
- raise ConfigError('No interface with give address specified!')
+ raise ConfigError('No interface with address "{address}" configured!')
+
if 'source_interface' in config:
verify_source_interface(config)
+ if 'source_address' in config:
+ address = config['source_address']
+ interface = config['source_interface']
+ if not is_intf_addr_assigned(interface, address):
+ raise ConfigError(f'Address "{address}" not assigned on interface "{interface}"!')
return None