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
fix: implement limit on number of hosts per line in /etc/hosts because Safari has problems with long lines, fixes #2817 #4805
Conversation
Tested locally with real world /etc/hosts filehere are the results:
Test command: for item in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
sudo ddev hostname a$item.ddev.site 127.0.0.1
done Resulting /etc/hosts under macOS Ventura (project related entries where masked due to privacy) Other infosWhat problems does occur without this fix?macOS Safari can not handle too long lines in /etc/hosts and will not read domains on the end of the line (e.g. 127.0.0.0.1 entry with ~100 domain names) Apple Bug Report?I already created a bug report. If I get any response I let you know here in this PR/issue :-) |
Did it really change "broadcast" to "boardcast" ? I do see this in goodhosts issue queue: Please link your safari issue with Apple here. |
For test purposes, here's a plain vanilla macOS starter version of /etc/hosts:
|
Sorry, was just a typo. See the screenshot in my comment. |
I have reported the problem at Apple: Feedback-ID |
Opened And created demonstration repository at goodhosts/hostsfile#42 |
Please test with the updated build here. After running the suggested test against a stock macOS hosts file I see
Default hosts file is at https://raw.githubusercontent.com/rfay/goodhostsbug/main/hosts After changing the example to remove:
I see this:
I don't like that the comments have been removed, see |
@josefglatz if you have trouble again, please provide the starting version of your /etc/hosts so I can experiment with it as well. Thanks! |
I'm not sure this is going to be an acceptable approach @josefglatz because of the rearranging of the file and loss of comments. Maybe we'll have to wait until something happens with However, I'd love it if you could test it anyway... |
No response from @josefglatz on this at this point, and I'm not very happy about the idea idea of completely rewriting hosts file. Closing for now, happy to reopen and to discuss. I'm following the issue, |
I tested a little bit. But I can't figure out how to adopt this to make this more bulletproof. Should we add a note about this in the DDEV documentation @rfay ? |
You didn't respond on the PR, would have loved to have your input on that. I think there's code in there to warn windows users, but there's no way to warn safari users. A docs PR would be fine. |
Although is being worked on at this point, I'm not sure that will get attention, but it might! |
2a53837
to
52429e4
Compare
Reopened, as
|
Download the artifacts for this pull request:
See Testing a PR |
@josefglatz Please take a look at this again, I think it's working great with the excellent fixes to goodhosts/hostsfile, thanks! Artifacts for testing in #4805 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested it on Linux:
$ cat /etc/hosts
# Host addresses
127.0.0.1 localhost
127.0.1.1 my-machine-name
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
$ for item in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do sudo ddev hostname a$item.ddev.site 127.0.0.1; done
$ cat /etc/hosts
# Host addresses
127.0.0.1 localhost a1.ddev.site a2.ddev.site a3.ddev.site a4.ddev.site a5.ddev.site a6.ddev.site a7.ddev.site
127.0.0.1 a8.ddev.site a9.ddev.site a10.ddev.site a11.ddev.site a12.ddev.site a13.ddev.site a14.ddev.site a15.ddev.site
127.0.1.1 my-machine-name
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
$ for item in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do sudo ddev hostname -r a$item.ddev.site 127.0.0.1; done
$ cat /etc/hosts
# Host addresses
127.0.0.1 localhost
127.0.1.1 my-machine-name
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
This can now be tested in HEAD, using https://ddev.readthedocs.io/en/latest/developers/building-contributing/#testing-latest-commits-on-head |
I also did a prerelease that can be used for testing this, https://github.com/ddev/ddev/releases/tag/v1.22.5-alpha1 |
Tested the feature successfully. Sorry for the delay @rfay |
Yay, thanks! |
The Issue
I thought we were already limiting the number of hosts per line in /etc/hosts, but it turns out it required extra code.
See https://github.com/goodhosts/hostsfile
How This PR Solves The Issue
Minor change to goodhosts/hostsfile usage to implement 9-hosts-per-line limit
We may want to wait on this because of non-critical
Manual Testing Instructions
Then inspect hosts file. This needs to be done on macOS, Linux, and traditional Windows.
Automated Testing Overview
We don't test this behavior I don't think because requires sudo
Related Issue Link(s)
Release/Deployment Notes