mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 21:10:25 +01:00
ifcfg-rh: distinguish in reader and writer between unset and empty dns-options
This commit is contained in:
parent
d5e948e482
commit
51b1fd976f
5 changed files with 23 additions and 6 deletions
|
|
@ -677,6 +677,9 @@ parse_dns_options (NMSettingIPConfig *ip_config, char *value)
|
|||
if (!value)
|
||||
return;
|
||||
|
||||
if (!nm_setting_ip_config_has_dns_options (ip_config))
|
||||
nm_setting_ip_config_clear_dns_options (ip_config, TRUE);
|
||||
|
||||
options = g_strsplit (value, " ", 0);
|
||||
if (options) {
|
||||
char **item;
|
||||
|
|
@ -927,7 +930,7 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
/* Get the connection ifcfg device name and the global gateway device */
|
||||
value = svGetValue (ifcfg, "DEVICE", FALSE);
|
||||
gatewaydev = svGetValue (network_ifcfg, "GATEWAYDEV", FALSE);
|
||||
dns_options = svGetValue (network_ifcfg, "RES_OPTIONS", FALSE);
|
||||
dns_options = svGetValueFull (network_ifcfg, "RES_OPTIONS", FALSE);
|
||||
|
||||
/* If there was a global gateway device specified, then only connections
|
||||
* for that device can be the default connection.
|
||||
|
|
@ -1105,7 +1108,7 @@ make_ip4_setting (shvarFile *ifcfg,
|
|||
}
|
||||
|
||||
/* DNS options */
|
||||
value = svGetValue (ifcfg, "RES_OPTIONS", FALSE);
|
||||
value = svGetValueFull (ifcfg, "RES_OPTIONS", FALSE);
|
||||
parse_dns_options (s_ip4, value);
|
||||
parse_dns_options (s_ip4, dns_options);
|
||||
g_free (value);
|
||||
|
|
@ -1317,7 +1320,7 @@ make_ip6_setting (shvarFile *ifcfg,
|
|||
value = svGetValue (ifcfg, "DEVICE", FALSE);
|
||||
ipv6_defaultgw = svGetValue (network_ifcfg, "IPV6_DEFAULTGW", FALSE);
|
||||
ipv6_defaultdev = svGetValue (network_ifcfg, "IPV6_DEFAULTDEV", FALSE);
|
||||
dns_options = svGetValue (network_ifcfg, "RES_OPTIONS", FALSE);
|
||||
dns_options = svGetValueFull (network_ifcfg, "RES_OPTIONS", FALSE);
|
||||
|
||||
if (ipv6_defaultgw) {
|
||||
default_dev = strchr (ipv6_defaultgw, '%');
|
||||
|
|
@ -1515,7 +1518,7 @@ make_ip6_setting (shvarFile *ifcfg,
|
|||
}
|
||||
|
||||
/* DNS options */
|
||||
value = svGetValue (ifcfg, "RES_OPTIONS", FALSE);
|
||||
value = svGetValueFull (ifcfg, "RES_OPTIONS", FALSE);
|
||||
parse_dns_options (s_ip6, value);
|
||||
parse_dns_options (s_ip6, dns_options);
|
||||
g_free (value);
|
||||
|
|
|
|||
|
|
@ -18,3 +18,4 @@ IPV6ADDR=dead:beaf::1
|
|||
IPV6ADDR_SECONDARIES="dead:beaf::2/56"
|
||||
DNS3=1:2:3:4::a
|
||||
DNS4=1:2:3:4::b
|
||||
RES_OPTIONS=
|
||||
|
|
|
|||
|
|
@ -13,3 +13,4 @@ DNS2=4.2.2.2
|
|||
IPADDR=192.168.1.5
|
||||
NETMASK=255.255.255.0
|
||||
GATEWAY=192.168.1.1
|
||||
RES_OPTIONS=
|
||||
|
|
|
|||
|
|
@ -484,6 +484,9 @@ test_read_wired_static (const char *file,
|
|||
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL);
|
||||
g_assert (nm_setting_ip_config_get_may_fail (s_ip4));
|
||||
|
||||
g_assert (nm_setting_ip_config_has_dns_options (s_ip4));
|
||||
g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip4), ==, 0);
|
||||
|
||||
/* DNS Addresses */
|
||||
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip4), ==, 2);
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip4, 0), ==, "4.2.2.1");
|
||||
|
|
@ -506,6 +509,9 @@ test_read_wired_static (const char *file,
|
|||
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_MANUAL);
|
||||
g_assert (nm_setting_ip_config_get_may_fail (s_ip6));
|
||||
|
||||
g_assert (nm_setting_ip_config_has_dns_options (s_ip6));
|
||||
g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip6), ==, 0);
|
||||
|
||||
/* DNS Addresses */
|
||||
g_assert_cmpint (nm_setting_ip_config_get_num_dns (s_ip6), ==, 2);
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_dns (s_ip6, 0), ==, "1:2:3:4::a");
|
||||
|
|
@ -525,6 +531,7 @@ test_read_wired_static (const char *file,
|
|||
g_assert_cmpstr (nm_ip_address_get_address (ip6_addr), ==, "dead:beaf::2");
|
||||
} else {
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip6), ==, NM_SETTING_IP6_CONFIG_METHOD_IGNORE);
|
||||
g_assert (!nm_setting_ip_config_has_dns_options (s_ip6));
|
||||
}
|
||||
|
||||
g_object_unref (connection);
|
||||
|
|
@ -563,6 +570,9 @@ test_read_wired_static_no_prefix (gconstpointer user_data)
|
|||
g_assert (s_ip4);
|
||||
g_assert_cmpstr (nm_setting_ip_config_get_method (s_ip4), ==, NM_SETTING_IP4_CONFIG_METHOD_MANUAL);
|
||||
|
||||
g_assert (!nm_setting_ip_config_has_dns_options (s_ip4));
|
||||
g_assert_cmpint (nm_setting_ip_config_get_num_dns_options (s_ip4), ==, 0);
|
||||
|
||||
g_assert_cmpint (nm_setting_ip_config_get_num_addresses (s_ip4), ==, 1);
|
||||
ip4_addr = nm_setting_ip_config_get_address (s_ip4, 0);
|
||||
g_assert (ip4_addr);
|
||||
|
|
|
|||
|
|
@ -2506,14 +2506,16 @@ write_res_options (NMConnection *connection, shvarFile *ifcfg, GError **error)
|
|||
}
|
||||
}
|
||||
|
||||
if (array->len > 0) {
|
||||
if (array->len > 0
|
||||
|| (s_ip4 && nm_setting_ip_config_has_dns_options (s_ip4))
|
||||
|| (s_ip6 && nm_setting_ip_config_has_dns_options (s_ip6))) {
|
||||
value = g_string_new (NULL);
|
||||
for (i = 0; i < array->len; i++) {
|
||||
if (i > 0)
|
||||
g_string_append_c (value, ' ');
|
||||
g_string_append (value, array->pdata[i]);
|
||||
}
|
||||
svSetValue (ifcfg, "RES_OPTIONS", value->str, FALSE);
|
||||
svSetValueFull (ifcfg, "RES_OPTIONS", value->str, FALSE);
|
||||
g_string_free (value, TRUE);
|
||||
} else
|
||||
svSetValue (ifcfg, "RES_OPTIONS", NULL, FALSE);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue