chiark / gitweb /
machine: make sure unpriviliged "machinectl status" can show the machine's OS version
[elogind.git] / src / resolve / resolved-manager.c
index ba2380d68287dd9c1df085fef52b40cecb6f6015..1b6dc8a4a3a685c7de188a0113a3d4f609db9faf 100644 (file)
@@ -359,7 +359,6 @@ static int on_hostname_change(sd_event_source *es, int fd, uint32_t revents, voi
 }
 
 static int manager_watch_hostname(Manager *m) {
-        _cleanup_free_ char *h = NULL;
         int r;
 
         assert(m);
@@ -1053,7 +1052,7 @@ int manager_send(Manager *m, int fd, int ifindex, int family, const union in_add
         return -EAFNOSUPPORT;
 }
 
-bool manager_known_dns_server(Manager *m, int family, const union in_addr_union *in_addr) {
+DnsServer* manager_find_dns_server(Manager *m, int family, const union in_addr_union *in_addr) {
         DnsServer *s;
 
         assert(m);
@@ -1061,16 +1060,16 @@ bool manager_known_dns_server(Manager *m, int family, const union in_addr_union
 
         LIST_FOREACH(servers, s, m->dns_servers)
                 if (s->family == family && in_addr_equal(family, &s->address, in_addr) > 0)
-                        return true;
+                        return s;
 
         LIST_FOREACH(servers, s, m->fallback_dns_servers)
                 if (s->family == family && in_addr_equal(family, &s->address, in_addr) > 0)
-                        return true;
+                        return s;
 
-        return false;
+        return NULL;
 }
 
-static DnsServer *manager_set_dns_server(Manager *m, DnsServer *s) {
+DnsServer *manager_set_dns_server(Manager *m, DnsServer *s) {
         assert(m);
 
         if (m->current_dns_server == s)
@@ -1081,10 +1080,13 @@ static DnsServer *manager_set_dns_server(Manager *m, DnsServer *s) {
 
                 in_addr_to_string(s->family, &s->address, &ip);
                 log_info("Switching to system DNS server %s.", strna(ip));
-        } else
-                log_info("No system DNS server set.");
+        }
 
         m->current_dns_server = s;
+
+        if (m->unicast_scope)
+                dns_cache_flush(&m->unicast_scope->cache);
+
         return s;
 }