Skip to content

Accept tab-separated nameserver lines in resolv.conf - #7882

Open
johnkaram02 wants to merge 1 commit into
dotnet:mainfrom
johnkaram02:fix-resolvconf-tab-separator
Open

johnkaram02 wants to merge 1 commit into
dotnet:mainfrom
johnkaram02:fix-resolvconf-tab-separator

Conversation

@johnkaram02

@johnkaram02 johnkaram02 commented Oct 23, 2026 •

Copy link
Copy Markdown

Fixes #7881

ResolvConf.GetServers split each /etc/resolv.conf line on the space character only. A line such as nameserver<TAB>10.0.0.1 became a single token, so that server was skipped without a warning. The resolv.conf format allows any white space between the keyword and its value, and the glibc resolver accepts tabs.

This change splits on all white space, the same way DiskStatsReader splits /proc lines in this repository.

Changes

  • ResolvConf.GetServers splits with Array.Empty<char>() instead of ' '.
  • Adds ResolvConfTests.GetServers_TabSeparated, which reads three nameserver lines (tab, mixed, and space separated) and expects all three servers in order.

Testing

dotnet test test/Libraries/Microsoft.Extensions.ServiceDiscovery.Dns.Tests -f net10.0

  • Without the source change, GetServers_TabSeparated fails: the result is [10.96.0.11:53, 10.96.0.12:53] and the tab-separated 10.96.0.10:53 is missing.
  • With the change, all 118 tests in the project pass.
Microsoft Reviewers: Open in CodeFlow

ResolvConf.GetServers split each line on spaces only, so a line such
as "nameserver<TAB>10.0.0.1" produced a single token and the server
was skipped. resolv.conf allows any white space between the keyword
and its value, and the system resolver accepts tabs.

Split on all white space so tab-separated entries are read.
@johnkaram02

Copy link
Copy Markdown
Author

@dotnet-policy-service agree

@dotnet-comment-bot

Copy link
Copy Markdown
Collaborator

‼️ Found issues ‼️

Project Coverage Type Expected Actual
Microsoft.Extensions.Diagnostics.Testing Line 99 98.65 🔻
Microsoft.Extensions.Telemetry Line 93 92.75 🔻
Microsoft.Extensions.AI Line 89 88.4 🔻
Microsoft.Extensions.AI.OpenAI Line 75 68.24 🔻
Microsoft.Extensions.AI.OpenAI Branch 75 57.54 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Line 75 4.46 🔻
Microsoft.Extensions.DataIngestion.MarkItDown Branch 75 0 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Line 99 96.07 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring Branch 99 92.76 🔻
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Kubernetes Line 99 97.73 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Line 75 42.11 🔻
Microsoft.Extensions.ServiceDiscovery.Abstractions Branch 75 42.86 🔻
Microsoft.Extensions.ServiceDiscovery.Dns Line 75 71.61 🔻
Microsoft.Extensions.ServiceDiscovery Line 75 68.88 🔻
Microsoft.Extensions.ServiceDiscovery Branch 75 71.43 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Line 75 73.85 🔻
Microsoft.Extensions.ServiceDiscovery.Yarp Branch 75 70 🔻
Microsoft.Extensions.VectorData.Abstractions Line 75 37.39 🔻
Microsoft.Extensions.VectorData.Abstractions Branch 75 22.73 🔻

🎉 Good job! The coverage increased 🎉
Update MinCodeCoverage in the project files.

Project Expected Actual
Microsoft.Extensions.Http.Diagnostics 94 95
Microsoft.Gen.BuildMetadata 97 100
Microsoft.Gen.MetadataExtractor 57 73
Microsoft.Gen.MetricsReports 67 69
Microsoft.Extensions.AI.Abstractions 82 86
Microsoft.Extensions.AI.Evaluation.NLP 0 78
Microsoft.Extensions.Caching.Hybrid 82 85
Microsoft.Extensions.DataIngestion 75 89
Microsoft.Extensions.DataIngestion.Markdig 75 90
Microsoft.Extensions.Http.Resilience 97 100

Full code coverage report: https://dev.azure.com/dnceng-public/public/_build/results?buildId=1647322&view=codecoverage-tab

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Managed DNS resolver ignores tab-separated nameserver lines in /etc/resolv.conf

2 participants