mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-03-10 00:58:20 +03:00
Merge pull request #5558 from dm0-/nspawn-resolved
nspawn: fix DNS when the stub listener is disabled
This commit is contained in:
commit
3007f25fd4
@ -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
|
||||
|
@ -1450,6 +1450,8 @@ static int bus_property_get_ntas(
|
||||
return sd_bus_message_close_container(reply);
|
||||
}
|
||||
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(bus_property_get_dns_stub_listener_mode, dns_stub_listener_mode, DnsStubListenerMode);
|
||||
|
||||
static int bus_method_reset_statistics(sd_bus_message *message, void *userdata, sd_bus_error *error) {
|
||||
Manager *m = userdata;
|
||||
DnsScope *s;
|
||||
@ -1577,6 +1579,7 @@ static const sd_bus_vtable resolve_vtable[] = {
|
||||
SD_BUS_PROPERTY("DNSSECStatistics", "(tttt)", bus_property_get_dnssec_statistics, 0, 0),
|
||||
SD_BUS_PROPERTY("DNSSECSupported", "b", bus_property_get_dnssec_supported, 0, 0),
|
||||
SD_BUS_PROPERTY("DNSSECNegativeTrustAnchors", "as", bus_property_get_ntas, 0, 0),
|
||||
SD_BUS_PROPERTY("DNSStubListener", "s", bus_property_get_dns_stub_listener_mode, offsetof(Manager, dns_stub_listener_mode), 0),
|
||||
|
||||
SD_BUS_METHOD("ResolveHostname", "isit", "a(iiay)st", bus_method_resolve_hostname, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
SD_BUS_METHOD("ResolveAddress", "iiayt", "a(is)t", bus_method_resolve_address, SD_BUS_VTABLE_UNPRIVILEGED),
|
||||
|
Loading…
x
Reference in New Issue
Block a user