-
Notifications
You must be signed in to change notification settings - Fork 129
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
Windows - not updating hosts #180
Comments
You mention great points and I will have to test them out to figure out a better way to manage the Windows prompt. In the meantime try this: https://github.com/cogitatio/vagrant-hostsupdater#windows-uac-prompt |
Hi - thanks for taking a look at this when you have time. I am afraid I can't use your suggestion to add my user write permission to the hosts file - I work in a University and the IT services tend to come down on us like a ton of bricks if they catch us reducing the security of our managed desktops. But thanks for the suggestion all the same. |
Hi
This doesn't work for me or my colleagues on windows 7 and 10 machines - so I took a look at the code, and I'm a little confused how this is working for Windows users in its current setup (unless they have made their systems open to attack by modifying their 'hosts' attributes)...
addToHosts
The line ```if !File.writable_real?(@@hosts_path)`` is used and passes its bash commands to the sudo function. Since Windows 'hosts' files should be read-only for security reasons our machines pass the bash commands to the 'sudo' windows function, which of course fails (there is no sh command).
The windows '''elsif Vagrant::Util::Platform.windows?''' never triggers because of the first ```if`` test is true, so the hosts never updates. Now if we modify this section to allow the windows actions to happen we also have to add in code to make 'hosts' file temporarily writable e.g.
You'll notice I had to comment out
File.delete(tmpPath)
. We found that ruby does not wait for win32ole to complete its action - so while you are typing in your admin credentials ruby has continued and already deleted the temporary file!removeFromHosts
Now this one is stranger as again the test if the 'hosts' file is not writable is true so the bash 'SED' command is again sent to the windows part of the 'sudo' function. SED is not native to windows and all my standalone tests show this command does not work with win32ole. In the cmd windows the '@ui.error' is shown - which is not surprising . But after being asked my admin credentials, my hosts file does get the entries removed! I really cannot work out why that happens!! Inserting @ui.info comments show the alternative 'else' actions are not triggered. The final thing - and it might be a clue about what is happening - is that the removal of the entries converts my 'hosts' file from CRLF to LF. If anyone can explain this to me I would love to hear how
removeFromHosts
is working on Windows.Thanks
The text was updated successfully, but these errors were encountered: