Merge pull request #194 from bendoh/check-hosts-writability

If hosts file is writable without sudo, don't use sudo
This commit is contained in:
Seth Reeser 2016-06-15 23:02:28 -04:00 committed by GitHub
commit 559748285c
1 changed files with 1 additions and 1 deletions

View File

@ -56,7 +56,7 @@ module VagrantPlugins
copy_proc = Proc.new { windows_copy_file(file, hosts_location) }
else
hosts_location = '/etc/hosts'
copy_proc = Proc.new { `sudo cp #{file} #{hosts_location}` }
copy_proc = Proc.new { `[ -w #{hosts_location} ] && cat #{file} > #{hosts_location} || sudo cp #{file} #{hosts_location}` }
end
FileUtils.cp(hosts_location, file)