From: Patrick Geltinger <patlkli@patlkli.org>
To: connman@lists.linux.dev
Cc: Patrick Geltinger <patlkli@patlkli.org>
Subject: [PATCH] dns: filter invalid addresses for systemd-resolved
Date: Wed, 23 Aug 2023 19:46:13 +0200 [thread overview]
Message-ID: <20230823174613.706596-1-patlkli@patlkli.org> (raw)
systemd-resolved's SetLinkDNS method will refuse to apply any changes if
any of the specified DNS server addresses are invalid (zero address or
their own DNS stub).
To avoid a misconfigured DHCP server leaving the system without any DNS
configuration, filter the server list before calling SetLinkDNS.
---
src/dns-systemd-resolved.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/dns-systemd-resolved.c b/src/dns-systemd-resolved.c
index 912ab3fe..413daf20 100644
--- a/src/dns-systemd-resolved.c
+++ b/src/dns-systemd-resolved.c
@@ -99,11 +99,16 @@ static void setlinkdns_append(DBusMessageIter *iter, void *user_data)
DBG("index: %d, server: %s", iface->index, server);
+ type = connman_inet_check_ipaddress(server);
+
+ if (__connman_inet_is_any_addr(server, type)) {
+ DBG("Ignoring invalid address: %s", server);
+ continue;
+ }
+
dbus_message_iter_open_container(&address_array,
DBUS_TYPE_STRUCT, NULL, &struct_array);
- type = connman_inet_check_ipaddress(server);
-
if (type == AF_INET) {
result = inet_pton(type, server, ipv4_bytes);
if (result != 1) {
--
2.39.2
reply other threads:[~2023-08-23 17:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230823174613.706596-1-patlkli@patlkli.org \
--to=patlkli@patlkli.org \
--cc=connman@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).