diff options
author | David Michael <david.michael@coreos.com> | 2017-03-08 21:45:03 +0100 |
---|---|---|
committer | David Michael <david.michael@coreos.com> | 2017-03-31 20:34:32 +0200 |
commit | 7357272ed1c2c7a139c9ecbc8f3b8f63f71dd0b0 (patch) | |
tree | 1e18e926aaabc75bf6e6eac0e22bcbf3ac763146 | |
parent | resolved: add a DNSStubListener property to Manager (diff) | |
download | systemd-7357272ed1c2c7a139c9ecbc8f3b8f63f71dd0b0.tar.xz systemd-7357272ed1c2c7a139c9ecbc8f3b8f63f71dd0b0.zip |
nspawn: check if the DNS stub is listening for requests
-rw-r--r-- | src/nspawn/nspawn.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 1fc0501c2e..bce26a383b 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -1321,17 +1321,32 @@ static int setup_timezone(const char *dest) { return 0; } -static int resolved_running(void) { +static int resolved_listening(void) { _cleanup_(sd_bus_flush_close_unrefp) sd_bus *bus = NULL; + _cleanup_free_ char *dns_stub_listener_mode = NULL; int r; - /* Check if resolved is running */ + /* Check if resolved is listening */ r = sd_bus_open_system(&bus); if (r < 0) return r; - return bus_name_has_owner(bus, "org.freedesktop.resolve1", NULL); + r = bus_name_has_owner(bus, "org.freedesktop.resolve1", NULL); + if (r <= 0) + return r; + + r = sd_bus_get_property_string(bus, + "org.freedesktop.resolve1", + "/org/freedesktop/resolve1", + "org.freedesktop.resolve1.Manager", + "DNSStubListener", + NULL, + &dns_stub_listener_mode); + if (r < 0) + return r; + + return STR_IN_SET(dns_stub_listener_mode, "udp", "yes"); } static int setup_resolv_conf(const char *dest) { @@ -1358,7 +1373,7 @@ static int setup_resolv_conf(const char *dest) { } if (access("/usr/lib/systemd/resolv.conf", F_OK) >= 0 && - resolved_running() > 0) { + resolved_listening() > 0) { /* resolved is enabled on the host. In this, case bind mount its static resolv.conf file into the * container, so that the container can use the host's resolver. Given that network namespacing is |