summaryrefslogtreecommitdiff
path: root/src/conf_mode/dynamic_dns.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2019-12-06 18:49:37 +0100
committerChristian Poessinger <christian@poessinger.com>2019-12-06 18:51:06 +0100
commitc4c0cc382ffa98cd9e0adb31dabc46ba4aa30674 (patch)
tree495681a82ecb75bd4f5fb97d7c66c6f9d0dd60cf /src/conf_mode/dynamic_dns.py
parent3559244db333132101a7ab70a11ce50f8bb08f08 (diff)
downloadvyos-1x-c4c0cc382ffa98cd9e0adb31dabc46ba4aa30674.tar.gz
vyos-1x-c4c0cc382ffa98cd9e0adb31dabc46ba4aa30674.zip
ddclient: T1853: bugfix TypeError exception
When service was deleted we tried accessing a key in the dictionary. But there was no dictionary at all as get_config() returned 'None' instead of 'dyndns'.
Diffstat (limited to 'src/conf_mode/dynamic_dns.py')
-rwxr-xr-xsrc/conf_mode/dynamic_dns.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/conf_mode/dynamic_dns.py b/src/conf_mode/dynamic_dns.py
index 7c3b9ff6a..9ba8659a1 100755
--- a/src/conf_mode/dynamic_dns.py
+++ b/src/conf_mode/dynamic_dns.py
@@ -95,6 +95,7 @@ default_service_protocol = {
default_config_data = {
'interfaces': [],
'cache_file': cache_file,
+ 'deleted': False,
'pid_file': pid_file
}
@@ -102,7 +103,8 @@ def get_config():
dyndns = default_config_data
conf = Config()
if not conf.exists('service dns dynamic'):
- return None
+ dyndns['deleted'] = True
+ return dyndns
else:
conf.set_level('service dns dynamic')
@@ -194,7 +196,7 @@ def get_config():
def verify(dyndns):
# bail out early - looks like removal from running config
- if dyndns is None:
+ if dyndns['deleted']:
return None
# A 'node' corresponds to an interface
@@ -239,7 +241,10 @@ def verify(dyndns):
def generate(dyndns):
# bail out early - looks like removal from running config
- if dyndns is None:
+ if dyndns['deleted']:
+ if os.path.exists(config_file):
+ os.unlink(config_file)
+
return None
dirname = os.path.dirname(dyndns['pid_file'])
@@ -264,7 +269,7 @@ def apply(dyndns):
if os.path.exists('/etc/ddclient.conf'):
os.unlink('/etc/ddclient.conf')
- if dyndns is None:
+ if dyndns['deleted']:
os.system('/etc/init.d/ddclient stop')
if os.path.exists(dyndns['pid_file']):
os.unlink(dyndns['pid_file'])