Skip to content

Apple: reimplement DNS configuration reading#750

Merged
bradh352 merged 9 commits intoc-ares:mainfrom
bradh352:macdns
Apr 29, 2024
Merged

Apple: reimplement DNS configuration reading#750
bradh352 merged 9 commits intoc-ares:mainfrom
bradh352:macdns

Conversation

@bradh352
Copy link
Member

@bradh352 bradh352 commented Apr 29, 2024

The DNS configuration for apple is stored in the system configuration database. Apple does provide an emulated /etc/resolv.conf on MacOS (but not iOS), it cannot, however, represent the entirety of the DNS configuration. Alternatively, libresolv could be used to also retrieve some system configuration, but it too is not capable of retrieving the entirety of the DNS configuration.

Attempts to use the preferred public API of SCDynamicStoreCreate() and friends yielded incomplete DNS information. Instead, that leaves some apple "internal" symbols from configd that we need to access in order to get the entire configuration. We can see that we're not the only ones to do this as Google Chrome also does: https://chromium.googlesource.com/chromium/src/+/HEAD/net/dns/dns_config_watcher_mac.cc. These internal functions are what whatlibresolv and scutil use to retrieve the dns configuration. Since these symbols are not publicly available, we will dynamically load the symbols from libSystem and import the dnsinfo.h private header extracted from:
https://opensource.apple.com/source/configd/configd-1109.140.1/dnsinfo/dnsinfo.h.

@bradh352 bradh352 merged commit ce9aa48 into c-ares:main Apr 29, 2024
bradh352 added a commit that referenced this pull request Apr 29, 2024
@bradh352 bradh352 deleted the macdns branch May 8, 2024 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant