-
-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Resolver uses nameserver commented out in /etc/resolv.conf #237
Comments
FreeBSD bug tracker: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=278721 |
Hopefully found a title that makes more sense now 😄 |
This /etc/resolv.conf: # x # nameserver 8.8.8.8 Still configured 8.8.8.8 as nameserver, because the comment detection in `ldns_resolver_new_frm_fp_l()` didn't anticipate empty lines before the comment. This fix removed all comment handling from `ldns_resolver_new_frm_fp_l()`. Instead a new function is introduced `ldns_fget_token_l_resolv_conf()` that skips comments that start with '#' and ';'. The old `ldns_fget_token_l()` (that is used for zonefiles too) still accepts only ';' for comments.
Thank you @grembo . I prefer that one, and then remove all comment handling from resolver.c. I just added a bit more (in PR #238) so that zonefile parsing does not accept comments to start with '#' too. |
Fixed by #238, thank you guys! |
And thank you for reporting! @dag-erling I've put a bugfix release on the calender for June. |
The most prominent fix is for the bug where ldns would, under certain conditions, use a commented out resolver in /etc/resolv.conf: NLnetLabs/ldns#237 Changelog: https://github.com/NLnetLabs/ldns/blob/1.8.4/Changelog PR: 280404 278721 MFH: 2024Q3
The most prominent fix is for the bug where ldns would, under certain conditions, use a commented out resolver in /etc/resolv.conf: NLnetLabs/ldns#237 Changelog: https://github.com/NLnetLabs/ldns/blob/1.8.4/Changelog PR: 280404 278721 MFH: 2024Q3 (cherry picked from commit 7fe9f43)
TL;DR
Comment parsing in /etc/resolv.conf is broken since 889f7c7
How to reproduce
Create a basic resolv.conf containing comments:
Then run drill on some zone:
Expected outcome
Since there are no nameservers configured, this outcome would be expected:
Actual outcome
The commented out nameserver entry is used:
Analysis
Commit 889f7c7 introduced this change:
Which breaks comment handling in resolver.c, which only removes characters until the end of line, in case line_nr doesn't change:
Potential Fixes
The parser isn't necessarily the kind of code one just jumps into and reasons about, yet the three suggestions below worked for my limited use case:
ldns_fget_token_l_st
understand comments starting with#
(unclear which side-effects this might have)Real life resolv.conf
This is the configuration where we first encountered issues (it would request a local zone from google DNS and fail with NXDOMAIN, even though we would expect the call to be handled by unbound running locally)
The text was updated successfully, but these errors were encountered: