summaryrefslogtreecommitdiff
path: root/src/conf_mode/lldp.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-31 10:14:59 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-31 10:17:45 +0100
commit6c286fab17e812a4d9aeb45cc5b78066f9a132ab (patch)
tree43ed10e078d699545bb014983614a7b7cdc189d5 /src/conf_mode/lldp.py
parentb33d26ab1e5590ad8954b352ed06f9a74f492d0b (diff)
downloadvyos-1x-6c286fab17e812a4d9aeb45cc5b78066f9a132ab.tar.gz
vyos-1x-6c286fab17e812a4d9aeb45cc5b78066f9a132ab.zip
lldp: T2230: verify file exists before unlinking it
(cherry picked from commit ca202f30fc5fad4c2fd99064ad0eba2643e71a5f)
Diffstat (limited to 'src/conf_mode/lldp.py')
-rwxr-xr-xsrc/conf_mode/lldp.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/conf_mode/lldp.py b/src/conf_mode/lldp.py
index 6b645857a..082c3e128 100755
--- a/src/conf_mode/lldp.py
+++ b/src/conf_mode/lldp.py
@@ -21,7 +21,8 @@ from copy import deepcopy
from sys import exit
from vyos.config import Config
-from vyos.validate import is_addr_assigned,is_loopback_addr
+from vyos.validate import is_addr_assigned
+from vyos.validate import is_loopback_addr
from vyos.version import get_version_data
from vyos import ConfigError
from vyos.util import call
@@ -237,8 +238,10 @@ def apply(lldp):
else:
# LLDP service has been terminated
call('systemctl stop lldpd.service')
- os.unlink(config_file)
- os.unlink(vyos_config_file)
+ if os.path.isfile(config_file):
+ os.unlink(config_file)
+ if os.path.isfile(vyos_config_file):
+ os.unlink(vyos_config_file)
if __name__ == '__main__':
try: