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
Hosts plugin allows setting invalid hostnames #2185
Comments
Thank you for reporting the bug! Unfortunately we do not have a plugin checking for valid (base) names at the moment. What about adding check/validation/match = BASENAME support in the validation plugin. Then we could specify a regex in src/plugins/hosts/contract.h which checks for valid hostnames (and aliases). Do you know which hostnames and aliases are allowed? This would also fix the problem with newlines in hostnames + aliases, see #1719 (but not the problem of newlines in comments...) |
i couldn't find any specification for /etc/hosts. RFC952 states
the grammar doesn't have that limitation though. according to RFC1034 a FQDN is 254 characters max (including root). and a hostname is 63 characters max (which seems to be the more common than the 24 character limit) what all have in common is that they can't end in a hypen, should start with either an alphanumeric character of a numeric character (depending on which documentation you read) and end with an alphanumeric character. i'd go with the FQDN definition, and imho a simple check if the basename qualifies at a valid FQDN should be done in the what do you think ? |
Sounds good! If you can give it a quick check with what glibc/musl does, it is even better. |
musl does the bare minimum
not sure what glibc does, too just too much to read, did a few greps, but couldn't find any validation of the hostname in i'd go with musl's check but add maybe |
Sounds good!
Only if somebody needs both options. Otherwise simply implement one. |
@tom-wa actually we already have a kind-of "strict" option: the --with-recommends option. So everything directly implemented in hosts is "non-strict", what you implement as regex in the contract (which is only applied when --with-recommends is used) is "strict". |
@tom-wa any update here? |
I mark this issue stale as it did not have any activity for one year. I'll close it in two weeks if no further activity occurs. If you want it to be alive again, ping the issue by writing a message here or create a new issue with the remainder of this issue. |
I closed this issue now because it has been inactive for more than one year. If I closed it by mistake, please do not hesitate to reopen it or create a new issue with the remainder of this issue. |
Steps to Reproduce the Problem
according to
man 5 hosts
this should be invalid:kdb set system/hosts/ipv4/-invalidhost- 127.0.0.1
not sure if there are any length limits for hostnames in
/etc/hosts
files, but at least FQNDs are limited to 254 characters so i guess this should also be invalid:Expected Result
Validation error
Actual Result
entry is written to hosts file
System Information
Further Log Files and Output
The text was updated successfully, but these errors were encountered: