Skip to content
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

Trim nameserver line in resolv.conf before parsing #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

cyqsimon
Copy link

@cyqsimon cyqsimon commented Dec 6, 2022

Currently, a line like this in /etc/resolv.conf will cause the name server to not be picked up:

nameserver    1.1.1.1

Trimming the string before parsing fixes that.


P.s. it is worth discussing whether this is a valid configuration at all. (I.e. is multiple spaces actually allowed?)

So I took a look at the man page, and only found this small paragraph addressing the format:

The keyword and value must appear on a single line, and the keyword (e.g., nameserver) must start the line. The value follows the keyword, separated by white space.

Yeah... The description is very ambiguous - it didn't say either "a white space" or "one or more white spaces". On the other hand, dig seems to be okay with multiple white spaces, so I think it's best to be defensive and trim first. There's no real downsides so why not.

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