diff options
author | Christian Poessinger <christian@poessinger.com> | 2018-05-12 20:43:10 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2018-05-12 20:43:10 +0200 |
commit | 53e0b1f060c3403ec29658a566d370d12cf7f22f (patch) | |
tree | f3559026db30bcdaf5341bf743b4a259568b08f7 /src/conf-mode | |
parent | acd2822890afa32ded51e2120f6c176916a06f35 (diff) | |
download | vyos-1x-53e0b1f060c3403ec29658a566d370d12cf7f22f.tar.gz vyos-1x-53e0b1f060c3403ec29658a566d370d12cf7f22f.zip |
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 <module>
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
Diffstat (limited to 'src/conf-mode')
-rwxr-xr-x | src/conf-mode/vyos-config-dns-forwarding.py | 10 |
1 files changed, 9 insertions, 1 deletions
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 |