mirror of
https://github.com/hickory-dns/hickory-dns.git
synced 2026-04-25 11:15:54 +03:00
[GH-ISSUE #1985] Malformed label: -- when parsing resolv.conf #839
Labels
No labels
blocked
breaking-change
bug
bug:critical
bug:tests
cleanup
compliance
compliance
compliance
crate:all
crate:client
crate:native-tls
crate:proto
crate:recursor
crate:resolver
crate:resolver
crate:rustls
crate:server
crate:util
dependencies
docs
duplicate
easy
easy
enhance
enhance
enhance
feature:dns-over-https
feature:dns-over-quic
feature:dns-over-tls
feature:dnsssec
feature:global_lb
feature:mdns
feature:tsig
features:edns
has workaround
ops
perf
platform:WASM
platform:android
platform:fuchsia
platform:linux
platform:macos
platform:windows
pull-request
question
test
tools
tools
trust
unclear
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/hickory-dns#839
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Jake-Shadle on GitHub (Jul 6, 2023).
Original GitHub issue: https://github.com/hickory-dns/hickory-dns/issues/1985
Describe the bug
My local
/etc/resolv.conftriggers this error, due to the presence of the linesearch -- lan.To Reproduce
Attemp to parse this file:
Expected behavior
I would expect this file to be parsed, if it is actually valid, which I'm assuming it is since my system works, but I honestly have no clue if trust-dns or systemd is in the wrong here since my efforts to figure out what the valid form(s) of the search entry in the resolv.conf is/are was met with defeat.
After playing around with my
/etc/systemd/resolved.confI'm becoming more convinced that this is a systemd bug, as doing any changes to theDomains=field (which controls the search field in resolv.conf) will always result in--being appended or prepended to whatever entries I make.System:
Version:
Crate: proto
Version: 0.22.0
Additional context
I didn't configure this myself and since I've never had this issue in the past, I'm assuming a recent system update added/changed the
search -- lanentry in the resolv.conf, so I'm assuming other people will start hitting this issue if this is a general update to Fedora 38/systemd-resolv, but that's just a guess.That being said, I'm not certain this is a bug in trust-dns, but more likely systemd, but figured I would open this issue just in case that is not the case, or at least have a record of this issue if others hit it, as I was unable to find much info elsewhere about this.
@Jake-Shadle commented on GitHub (Jul 6, 2023):
Oh and as a workaround, one can just edit
/etc/resolv.confto remove the--from the search field, just be aware that those changes will be overwritten if you re/start thesystemd-resolvedservice or reboot.@Jake-Shadle commented on GitHub (Jul 6, 2023):
Took a look at my laptop running PopOS instead of Fedora, but still using systemd, and sure enough the resolv.conf just has
search lanwith no--.@CodeDead commented on GitHub (Jul 23, 2023):
Still, the double dashes are valid config options for /etc/resolv.conf . This bug also impacts the MongoDB Rust driver on Linux.
@Jake-Shadle commented on GitHub (Jul 23, 2023):
Do you have a reference for it in a spec? I tried and failed to find what - - even means.
@CodeDead commented on GitHub (Jul 23, 2023):
https://man.archlinux.org/man/resolv.conf.5#search
On Sun, 23 Jul 2023, 12:07 Jake Shadle, @.***> wrote:
@bluejekyll commented on GitHub (Jul 24, 2023):
I have no idea what
—would mean in this context?I think one option would be for us to change the resolve.conf parsing to be lossy and ignore illegal input? My guess is this is some awkward default based on other configurations in the system, like no hostname?
@CodeDead commented on GitHub (Jul 24, 2023):
It would mean nothing. This is because of faulty hostnames for example or faulty network managers adding things that make no sense. If only double dashes are present, double dashes in the search can be ignored.
@djc commented on GitHub (Jul 24, 2023):
@CodeDead how do you conclude that from those docs? I didn't see anything relevant in that man page?
Maybe we should look at the code (presumably in libc implementations) that parses
resolv.conf?@CodeDead commented on GitHub (Jul 24, 2023):
Because
--is not a valid search domain and meaningless. Most likely added due to a network manager since most distro's use a network manager to manage/etc/resolv.conf(in my case the latest version of systemd-resolved)If I, for example do a
dig +search googlethe dig command will fail too with the error message:You could either panic and fail, which is now the case for both dig and trust-dns repo or ignore the search domain because it is invalid. Whether this is a systemd bug is hard to tell, because it might be intended behavior to ignore double dashes when using systemd because systems with systemd running still work when search is set to the double dashes. It is still valid to place double dashes in the search field because there are no standards or restrictions listed in the manual that prevent you from doing that but it will not form a valid domain according to the domain standards. The question is how to handle that; to fail or to ignore the dashes.
Journaling systemd-resolved (with google dns) and no domain name set in the system will give me something like this:
Which stems from a 'faulty' connection profile. The best (read: fastest) way to solve this problem for systemd, is to re-create the connection profile (delete the connection profile and create a new one) in systemd devices if the double dashes are present (probably stemming from faulty router / DHCP setup) in the hopes that the search field will then be retrieved and set correctly.
Whether or not to fail for invalid domains is another matter (because most of systemd will absolutely work and just ignore the problem) whereas some tools (like
dig) will panic.Ignoring the double dashes might be the way to go for systemd because it is not a valid domain and perhaps trust-dns should ignore invalid search domains too, but that is a decision to make and take for the maintainers. Either way,
search --is an invalid search domain but still, nothing prevents you from adding invalid search domains in resolv.conf or the actual router.