summaryrefslogtreecommitdiff
path: root/src/conf_mode/interfaces-wirelessmodem.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-11-11 18:37:45 +0100
committerChristian Poessinger <christian@poessinger.com>2020-11-11 18:37:45 +0100
commit7301659a1303669612c7b4120b17ac50a62dbd24 (patch)
tree038f24ea4e9b0f80a5c245510a48a09e90753537 /src/conf_mode/interfaces-wirelessmodem.py
parentad856600ca29ba463de2b288189d3f40b9e91846 (diff)
downloadvyos-1x-7301659a1303669612c7b4120b17ac50a62dbd24.tar.gz
vyos-1x-7301659a1303669612c7b4120b17ac50a62dbd24.zip
wwan: T2529: fix validation logic for non existing devices
A non existing device usb0b1.4p1.?? device was not detected, as find_device_file() returned None which can not be passed into os.path.exists(). Traceback (most recent call last): File "/usr/libexec/vyos/conf_mode/interfaces-wirelessmodem.py", line 126, in <module> verify(c) File "/usr/libexec/vyos/conf_mode/interfaces-wirelessmodem.py", line 60, in verify if dev_path is None or os.path.exists(find_device_file(dev_path)): File "/usr/lib/python3.7/genericpath.py", line 19, in exists os.stat(path) TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
Diffstat (limited to 'src/conf_mode/interfaces-wirelessmodem.py')
-rwxr-xr-xsrc/conf_mode/interfaces-wirelessmodem.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/conf_mode/interfaces-wirelessmodem.py b/src/conf_mode/interfaces-wirelessmodem.py
index 7d8110096..2da1f0863 100755
--- a/src/conf_mode/interfaces-wirelessmodem.py
+++ b/src/conf_mode/interfaces-wirelessmodem.py
@@ -56,7 +56,8 @@ def verify(wwan):
# we can not use isfile() here as Linux device files are no regular files
# thus the check will return False
- if not os.path.exists(find_device_file(wwan['device'])):
+ dev_path = find_device_file(wwan['device'])
+ if dev_path is None or not os.path.exists(dev_path):
raise ConfigError('Device "{device}" does not exist'.format(**wwan))
verify_vrf(wwan)