From 53e0b1f060c3403ec29658a566d370d12cf7f22f Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Sat, 12 May 2018 20:43:10 +0200 Subject: T560: bugfix access to NoneType object Commit f1bbc20716 ("Add jinja2 and ipaddrcheck to dependencies.") introduced access to a NoneType object when the service was removed. This happened after: $ delete service dns forwarding $ commit File "/opt/vyatta/sbin/vyos-config-dns-forwarding.py", line 201, in verify(c) File "/opt/vyatta/sbin/vyos-config-dns-forwarding.py", line 164, in verify if not dns['interfaces']: TypeError: 'NoneType' object is not subscriptable --- src/conf-mode/vyos-config-dns-forwarding.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/conf-mode') diff --git a/src/conf-mode/vyos-config-dns-forwarding.py b/src/conf-mode/vyos-config-dns-forwarding.py index 750a0c843..df273b321 100755 --- a/src/conf-mode/vyos-config-dns-forwarding.py +++ b/src/conf-mode/vyos-config-dns-forwarding.py @@ -160,6 +160,10 @@ def get_config(): return dns def verify(dns): + # bail out early - looks like removal from running config + if dns is None: + return None + if not dns['interfaces']: raise ConfigError('Error: DNS forwarding requires a configured listen interface!') @@ -177,6 +181,10 @@ def verify(dns): return None def generate(dns): + # bail out early - looks like removal from running config + if dns is None: + return None + tmpl = jinja2.Template(config_tmpl) config_text = tmpl.render(dns) @@ -185,7 +193,7 @@ def generate(dns): return None def apply(dns): - if dns: + if dns is not None: os.system("systemctl restart pdns-recursor") else: # DNS forwarding is removed in the commit -- cgit v1.2.3