summaryrefslogtreecommitdiff
path: root/src/resolver.c
diff options
context:
space:
mode:
authorHenri Bragge <henri.bragge@ixonos.com>2010-12-07 10:49:38 +0200
committerSamuel Ortiz <sameo@linux.intel.com>2010-12-07 19:04:42 +0100
commit2cc48d91f82cf1aaa2c002b5e617cfa5df5f2545 (patch)
treebf4ba01f851dc897860f41c1103c4e0e21620c5b /src/resolver.c
parent0ab9afa9c8edf471ec9b669c125662336dd0d379 (diff)
downloadconnman-2cc48d91f82cf1aaa2c002b5e617cfa5df5f2545.tar.gz
connman-2cc48d91f82cf1aaa2c002b5e617cfa5df5f2545.tar.bz2
connman-2cc48d91f82cf1aaa2c002b5e617cfa5df5f2545.zip
resolver: Add support for multiple search domains
Domains are appended to entry list just like nameservers, and finally exported to /etc/resolv.conf. Domains are written to resolv.conf in reverse order so that the most recently appended domain will have the highest priority. Search domains should only be useful for resolvfile_resolver and should be ignored by dnsproxy_resolver.
Diffstat (limited to 'src/resolver.c')
-rw-r--r--src/resolver.c31
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++;