If hosts file is writable without sudo, don't use sudo

This commit is contained in:
Ben Doherty 2016-06-03 10:06:23 -04:00
parent c40505f6df
commit 50b34b9659
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)