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.
---
 src/resolver.c |   33 +++++++++++++++++++++++++++------
 src/service.c  |   18 ++++++++++++++++--
 2 files changed, 43 insertions(+), 8 deletions(-)

diff --git a/src/resolver.c b/src/resolver.c
index 8957645..8440e35 100644
--- a/src/resolver.c
+++ b/src/resolver.c
@@ -146,7 +146,7 @@ static int append_resolver(const char *interface, const 
char *domain,
        DBG("interface %s domain %s server %s flags %d",
                                        interface, domain, server, flags);
 
-       if (server == NULL)
+       if (server == NULL && domain == NULL)
                return -EINVAL;
 
        entry = g_try_new0(struct entry_data, 1);
@@ -392,17 +392,38 @@ 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) {
+                       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;
-               g_string_append_printf(content, "nameserver %s\n",
+
+               if (entry->server) {
+                       g_string_append_printf(content, "nameserver %s\n",
                                                                entry->server);
-               count++;
+                       count++;
+               }
        }
 
        old_umask = umask(022);
diff --git a/src/service.c b/src/service.c
index b1842d6..5867e30 100644
--- a/src/service.c
+++ b/src/service.c
@@ -368,6 +368,15 @@ static void update_nameservers(struct connman_service 
*service)
        } else if (service->nameserver != NULL)
                connman_resolver_append(ifname, NULL, service->nameserver);
 
+       if (service->domains != NULL) {
+               int i;
+
+               for (i = 0; service->domains[i]; i++)
+                       connman_resolver_append(ifname, service->domains[i],
+                                               NULL);
+       } else if (service->domainname != NULL)
+               connman_resolver_append(ifname, service->domainname, NULL);
+
        connman_resolver_flush();
 }
 
@@ -1516,7 +1525,10 @@ const char *connman_service_get_domainname(struct 
connman_service *service)
        if (service == NULL)
                return NULL;
 
-       return service->domainname;
+       if (service->domains != NULL)
+               return service->domains[0];
+       else
+               return service->domainname;
 }
 
 const char *connman_service_get_nameserver(struct connman_service *service)
@@ -1986,7 +1998,7 @@ static DBusMessage *set_property(DBusConnection *conn,
 
                g_string_free(str, TRUE);
 
-               //update_domains(service);
+               update_nameservers(service);
                domain_configuration_changed(service);
 
                __connman_storage_save_service(service);
@@ -3007,6 +3019,7 @@ int __connman_service_indicate_state(struct 
connman_service *service,
 
                update_nameservers(service);
                dns_changed(service);
+               domain_changed(service);
 
                __connman_wpad_start(service);
 
@@ -3022,6 +3035,7 @@ int __connman_service_indicate_state(struct 
connman_service *service,
 
                update_nameservers(service);
                dns_changed(service);
+               domain_changed(service);
 
                __connman_notifier_disconnect(service->type);
        }
-- 
1.7.0.4


_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to