summaryrefslogtreecommitdiff
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:15:41 +0100
commitca202f30fc5fad4c2fd99064ad0eba2643e71a5f (patch)
tree79e370615cb0da1e26a176dc8e4ad4d3bf251221
parent16c495e2eecf72797d7c9981ec909452baa1e990 (diff)
downloadvyos-1x-ca202f30fc5fad4c2fd99064ad0eba2643e71a5f.tar.gz
vyos-1x-ca202f30fc5fad4c2fd99064ad0eba2643e71a5f.zip
lldp: T2230: verify file exists before unlinking it
-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: