diff options
Diffstat (limited to 'src/resolver.c')
-rw-r--r-- | src/resolver.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/resolver.c b/src/resolver.c index cbb628e5..6ee4d483 100644 --- a/src/resolver.c +++ b/src/resolver.c @@ -164,7 +164,7 @@ static int append_resolver(const char *interface, const char *domain, DBG("interface %s domain %s server %s lifetime %d flags %d", interface, domain, server, lifetime, flags); - if (server == NULL) + if (server == NULL && domain == NULL) return -EINVAL; entry = g_try_new0(struct entry_data, 1); @@ -409,14 +409,37 @@ static int resolvfile_export(void) content = g_string_new("# Generated by Connection Manager\n"); /* - * Nameservers are added in reverse so that the most recently - * appended entry is the primary nameserver. No more than MAXNS - * nameservers are used. + * Domains and nameservers are added in reverse so that the most + * recently appended entry is the primary one. No more than + * MAXDNSRCH/MAXNS entries are used. */ + + for (count = 0, list = g_list_last(resolvfile_list); + list && (count < MAXDNSRCH); + list = g_list_previous(list)) { + struct resolvfile_entry *entry = list->data; + + if (!entry->domain) + continue; + + if (count == 0) + g_string_append_printf(content, "search "); + + g_string_append_printf(content, "%s ", entry->domain); + count++; + } + + if (count) + g_string_append_printf(content, "\n"); + for (count = 0, list = g_list_last(resolvfile_list); list && (count < MAXNS); list = g_list_previous(list)) { struct resolvfile_entry *entry = list->data; + + if (!entry->server) + continue; + g_string_append_printf(content, "nameserver %s\n", entry->server); count++; |