From 2084d400c7c3b5176d7084844758362c05cc6413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Wed, 10 May 2023 13:00:57 +0200 Subject: [PATCH] fixup! Correct releasing of serv_domain Ensure correct domain entries are prepared also for DBus specified domains. Initialize server_domain when adding new nameserver, no matter what is its source. Do not wait for check_servers() to domain initialization. Resolves: rhbz#2186481 --- dnsmasq-2.85-serv_domain-rh2186481-2.patch | 83 ++++++++++++++++++++++ dnsmasq.spec | 9 ++- 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 dnsmasq-2.85-serv_domain-rh2186481-2.patch diff --git a/dnsmasq-2.85-serv_domain-rh2186481-2.patch b/dnsmasq-2.85-serv_domain-rh2186481-2.patch new file mode 100644 index 0000000..4a62c59 --- /dev/null +++ b/dnsmasq-2.85-serv_domain-rh2186481-2.patch @@ -0,0 +1,83 @@ +From 312e9f812a6b2f5ca2c2db866ffed3a0b289b945 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= +Date: Wed, 10 May 2023 12:57:17 +0200 +Subject: [PATCH] fixup! Correct releasing of serv_domain + +--- + src/dnsmasq.h | 2 +- + src/network.c | 20 +++++++++++--------- + 2 files changed, 12 insertions(+), 10 deletions(-) + +diff --git a/src/dnsmasq.h b/src/dnsmasq.h +index e8a1320..711ffd3 100644 +--- a/src/dnsmasq.h ++++ b/src/dnsmasq.h +@@ -1331,7 +1331,7 @@ int label_exception(int index, int family, struct all_addr *addr); + int fix_fd(int fd); + int tcp_interface(int fd, int af); + struct server_domain *server_domain_find_domain(const char *domain); +-struct server_domain *server_domain_new(struct server *serv); ++void server_domain_new(struct server *serv); + #ifdef HAVE_IPV6 + int set_ipv6pktinfo(int fd); + #endif +diff --git a/src/network.c b/src/network.c +index b8d77fe..6faaad4 100644 +--- a/src/network.c ++++ b/src/network.c +@@ -1544,6 +1544,7 @@ void add_update_server(int flags, + serv->addr = *addr; + if (source_addr) + serv->source_addr = *source_addr; ++ server_domain_new(serv); + } + } + +@@ -1571,14 +1572,20 @@ struct server_domain *server_domain_find_domain(const char *domain) + /**< Test structure has already set domain pointer. + * + * If not, create a new record. */ +-struct server_domain *server_domain_new(struct server *serv) ++void server_domain_new(struct server *serv) + { + struct server_domain *sd; ++ const char *domain = server_get_domain(serv); + +- if ((sd = whine_malloc(sizeof(struct server_domain)))) ++ sd = server_domain_find_domain(domain); ++ if (sd) + { +- const char *domain = server_get_domain(serv); ++ serv->serv_domain = sd; ++ return; ++ } + ++ if ((sd = whine_malloc(sizeof(struct server_domain)))) ++ { + /* Ensure all serv->domain values have own record in server_domain. + * Add a new record. */ + if (domain) +@@ -1592,7 +1599,6 @@ struct server_domain *server_domain_new(struct server *serv) + serv->serv_domain = sd; + daemon->server_domains = sd; + } +- return sd; + } + + /**< Test structure has already set domain pointer. +@@ -1605,11 +1611,7 @@ static void server_domain_check(struct server *serv) + if (sd) + sd->flags &= (~SERV_MARK); /* found domain, mark active */ + else +- { +- sd = server_domain_find_domain(serv->domain); +- if (!sd) +- server_domain_new(serv); +- } ++ server_domain_new(serv); + } + + void check_servers(void) +-- +2.40.1 + diff --git a/dnsmasq.spec b/dnsmasq.spec index e4f04a8..8c5ed9b 100644 --- a/dnsmasq.spec +++ b/dnsmasq.spec @@ -13,7 +13,7 @@ Name: dnsmasq Version: 2.79 -Release: 28%{?extraversion:.%{extraversion}}%{?dist} +Release: 29%{?extraversion:.%{extraversion}}%{?dist} Summary: A lightweight DHCP/caching DNS server License: GPLv2 or GPLv3 @@ -88,6 +88,9 @@ Patch40: dnsmasq-2.89-edns0-size.patch # Downstream only patch; https://bugzilla.redhat.com/show_bug.cgi?id=2186481 # Fixes issue in Patch4 Patch41: dnsmasq-2.85-serv_domain-rh2186481.patch +# Downstream only patch; https://bugzilla.redhat.com/show_bug.cgi?id=2186481 +# complements patch10 +Patch42: dnsmasq-2.85-serv_domain-rh2186481-2.patch # This is workaround to nettle bug #1549190 # https://bugzilla.redhat.com/show_bug.cgi?id=1549190 @@ -162,6 +165,7 @@ server's leases. %patch39 -p1 -b .rh2169355 %patch40 -p1 -b .CVE-2023-28450 %patch41 -p1 -b .rh2186481 +%patch42 -p1 -b .rh2186481-2 # use /var/lib/dnsmasq instead of /var/lib/misc for file in dnsmasq.conf.example man/dnsmasq.8 man/es/dnsmasq.8 src/config.h; do @@ -261,6 +265,9 @@ install -Dpm 644 %{SOURCE2} %{buildroot}%{_sysusersdir}/dnsmasq.conf %{_mandir}/man1/dhcp_* %changelog +* Wed May 10 2023 Petr Menšík - 2.79-29 +- Fix also dynamically set resolvers over dbus (#2186481) + * Fri Apr 21 2023 Petr Menšík - 2.79-28 - Correct possible crashes when server=/example.net/# is used (#2186481)