diff options
-rw-r--r-- | src/settings/plugins/ifcfg-rh/reader.c | 51 | ||||
-rw-r--r-- | src/settings/plugins/ifcfg-rh/writer.c | 33 |
2 files changed, 82 insertions, 2 deletions
diff --git a/src/settings/plugins/ifcfg-rh/reader.c b/src/settings/plugins/ifcfg-rh/reader.c index febbd90ac6..0edf98ab1d 100644 --- a/src/settings/plugins/ifcfg-rh/reader.c +++ b/src/settings/plugins/ifcfg-rh/reader.c @@ -1079,6 +1079,25 @@ make_ip4_setting (shvarFile *ifcfg, g_free (value); } + /* DNS options */ + value = svGetValue (ifcfg, "RES_OPTIONS", FALSE); + if (value) { + char **options = NULL; + + options = g_strsplit (value, " ", 0); + if (options) { + char **item; + for (item = options; *item; item++) { + if (strlen (*item)) { + if (!nm_setting_ip_config_add_dns_option (s_ip4, *item)) + PARSE_WARNING ("duplicate DNS option '%s'", *item); + } + } + g_strfreev (options); + } + g_free (value); + } + /* Static routes - route-<name> file */ route_path = utils_get_route_path (ifcfg->fileName); @@ -4644,6 +4663,35 @@ check_dns_search_domains (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) } } +static void +check_dns_options (shvarFile *ifcfg, NMSetting *s_ip4, NMSetting *s_ip6) +{ + if (!s_ip6) + return; + + /* If there is no IPv4 config or it doesn't contain DNS options, + * read RES_OPTIONS and put the domains into IPv6. + */ + if (!s_ip4 || nm_setting_ip_config_get_num_dns_options (NM_SETTING_IP_CONFIG (s_ip4)) == 0) { + /* DNS options */ + char *value = svGetValue (ifcfg, "RES_OPTIONS", FALSE); + if (value) { + char **options = g_strsplit (value, " ", 0); + if (options) { + char **item; + for (item = options; *item; item++) { + if (strlen (*item)) { + if (!nm_setting_ip_config_add_dns_option (NM_SETTING_IP_CONFIG (s_ip6), *item)) + PARSE_WARNING ("duplicate DNS option '%s'", *item); + } + } + g_strfreev (options); + } + g_free (value); + } + } +} + static NMConnection * connection_from_file_full (const char *filename, const char *network_file, /* for unit tests only */ @@ -4814,6 +4862,9 @@ connection_from_file_full (const char *filename, */ check_dns_search_domains (parsed, s_ip4, s_ip6); + /* The same for RES_OPTIONS */ + check_dns_options (parsed, s_ip4, s_ip6); + /* Bridge port? */ s_port = make_bridge_port_setting (parsed); if (s_port) diff --git a/src/settings/plugins/ifcfg-rh/writer.c b/src/settings/plugins/ifcfg-rh/writer.c index 75547641b1..858083238c 100644 --- a/src/settings/plugins/ifcfg-rh/writer.c +++ b/src/settings/plugins/ifcfg-rh/writer.c @@ -1841,7 +1841,7 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) gint32 j; guint32 i, n, num; gint64 route_metric; - GString *searches; + GString *searches, *options; gboolean success = FALSE; gboolean fake_ip4 = FALSE; const char *method = NULL; @@ -2013,6 +2013,19 @@ write_ip4_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) } else svSetValue (ifcfg, "DOMAIN", NULL, FALSE); + num = nm_setting_ip_config_get_num_dns_options (s_ip4); + if (num > 0) { + options = g_string_new (NULL); + for (i = 0; i < num; i++) { + if (i > 0) + g_string_append_c (options, ' '); + g_string_append (options, nm_setting_ip_config_get_dns_option (s_ip4, i)); + } + svSetValue (ifcfg, "RES_OPTIONS", options->str, FALSE); + g_string_free (options, TRUE); + } else + svSetValue (ifcfg, "RES_OPTIONS", NULL, FALSE); + /* DEFROUTE; remember that it has the opposite meaning from never-default */ svSetValue (ifcfg, "DEFROUTE", nm_setting_ip_config_get_never_default (s_ip4) ? "no" : "yes", @@ -2291,7 +2304,7 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) char *addr_key; char *tmp; guint32 i, num, num4; - GString *searches; + GString *searches, *options; NMIPAddress *addr; const char *dns; gint64 route_metric; @@ -2400,6 +2413,22 @@ write_ip6_setting (NMConnection *connection, shvarFile *ifcfg, GError **error) g_free (ip4_domains); } + /* Write out DNS options - 'RES_OPTIONS' key is shared for both IPv4 and IPv6 domains */ + num = nm_setting_ip_config_get_num_dns_options (s_ip6); + if (num > 0) { + char *ip4_options; + ip4_options = svGetValue (ifcfg, "RES_OPTIONS", FALSE); + options = g_string_new (ip4_options); + for (i = 0; i < num; i++) { + if (options->len > 0) + g_string_append_c (options, ' '); + g_string_append (options, nm_setting_ip_config_get_dns_option (s_ip6, i)); + } + svSetValue (ifcfg, "RES_OPTIONS", options->str, FALSE); + g_string_free (options, TRUE); + g_free (ip4_options); + } + /* handle IPV6_DEFROUTE */ /* IPV6_DEFROUTE has the opposite meaning from 'never-default' */ if (nm_setting_ip_config_get_never_default(s_ip6)) |