summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2018-05-23 16:19:45 +0200
committerDaniil Baturin <daniil@baturin.org>2018-05-23 16:19:45 +0200
commita79b6babd9fc897799eb14fbfcaaf1e8f6cb94d5 (patch)
tree1159c497263e73a726ca8f07b49a1414247cb427
parent682f8ffdd7cd71b77277719b114d4ca813175da4 (diff)
downloadvyos-1x-a79b6babd9fc897799eb14fbfcaaf1e8f6cb94d5.tar.gz
vyos-1x-a79b6babd9fc897799eb14fbfcaaf1e8f6cb94d5.zip
Use normal assignment by key instead of setdefault() everywhere.
The setdefault() dict object method updates the value only if it's not already set, so it's useless for what we want to do, despite its deceptive name.
-rwxr-xr-xsrc/conf_mode/dns_forwarding.py2
-rwxr-xr-xsrc/conf_mode/ssh.py18
2 files changed, 10 insertions, 10 deletions
diff --git a/src/conf_mode/dns_forwarding.py b/src/conf_mode/dns_forwarding.py
index f5ad2e482..391dc14ea 100755
--- a/src/conf_mode/dns_forwarding.py
+++ b/src/conf_mode/dns_forwarding.py
@@ -118,7 +118,7 @@ def get_config():
dns['domains'].append(domain)
if conf.exists('ignore-hosts-file'):
- dns.setdefault('export_hosts_file', "no")
+ dns['export_hosts_file'] = "no"
if conf.exists('name-server'):
name_servers = conf.return_values('name-server')
diff --git a/src/conf_mode/ssh.py b/src/conf_mode/ssh.py
index 7071a6ab4..f1ac19473 100755
--- a/src/conf_mode/ssh.py
+++ b/src/conf_mode/ssh.py
@@ -157,26 +157,26 @@ def get_config():
if conf.exists('access-control allow user'):
allow_users = conf.return_values('access-control allow user')
- ssh.setdefault('allow_users', allow_users)
+ ssh['allow_users'] = allow_users
if conf.exists('access-control allow group'):
allow_groups = conf.return_values('access-control allow group')
- ssh.setdefault('allow_groups', allow_groups)
+ ssh['allow_groups'] = allow_groups
if conf.exists('access-control deny user'):
deny_users = conf.return_values('access-control deny user')
- ssh.setdefault('deny_users', deny_users)
+ ssh['deny_users'] = deny_users
if conf.exists('access-control deny group'):
deny_groups = conf.return_values('access-control deny group')
- ssh.setdefault('deny_groups', deny_groups)
+ ssh['deny_groups'] = deny_groups
if conf.exists('allow-root'):
ssh['allow-root'] = 'yes'
if conf.exists('ciphers'):
ciphers = conf.return_values('ciphers')
- ssh.setdefault('ciphers', ciphers)
+ ssh['ciphers'] = ciphers
if conf.exists('disable-host-validation'):
ssh['host_validation'] = 'no'
@@ -186,7 +186,7 @@ def get_config():
if conf.exists('key-exchange'):
kex = conf.return_values('key-exchange')
- ssh.setdefault('key_exchange', kex)
+ ssh['key_exchange'] = kex
if conf.exists('listen-address'):
# We can listen on both IPv4 and IPv6 addresses
@@ -198,18 +198,18 @@ def get_config():
for addr in addresses:
listen.append(addr)
- ssh.setdefault('listen_on', listen)
+ ssh['listen_on'] = listen
if conf.exists('loglevel'):
ssh['log_level'] = conf.return_value('loglevel')
if conf.exists('mac'):
mac = conf.return_values('mac')
- ssh.setdefault('mac', mac)
+ ssh['mac'] = mac
if conf.exists('port'):
port = conf.return_value('port')
- ssh.setdefault('port', port)
+ ssh['port'] = port
return ssh