From 74ffc8d323b9b001265593b8a98134390735b01e Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sat, 6 Aug 2016 17:09:27 +0530 Subject: [PATCH] networks: Fix incorrect access of DNS settings Network manager's libnm throws a critical message for when accessing DNS entries from IPv4 configuration when there are none available. See the number of entries available before accessing them. --- plinth/modules/networks/networks.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/plinth/modules/networks/networks.py b/plinth/modules/networks/networks.py index 668e852c7..272de3587 100644 --- a/plinth/modules/networks/networks.py +++ b/plinth/modules/networks/networks.py @@ -150,16 +150,15 @@ def edit(request, uuid): form_data['ipv4_netmask'] = network.ipv4_int_to_string(netmask) gateway = settings_ipv4.get_gateway() - dns = settings_ipv4.get_dns(0) - second_dns = settings_ipv4.get_dns(1) if gateway: form_data['ipv4_gateway'] = gateway - if dns: - form_data['ipv4_dns'] = dns + number_of_dns = settings_ipv4.get_num_dns() + if number_of_dns: + form_data['ipv4_dns'] = settings_ipv4.get_dns(0) - if second_dns: - form_data['ipv4_second_dns'] = second_dns + if number_of_dns > 1: + form_data['ipv4_second_dns'] = settings_ipv4.get_dns(1) if settings_connection.get_connection_type() == 'generic': form = GenericForm(form_data)