If hosts file is writable without sudo, don't use sudo
This commit is contained in:
parent
c40505f6df
commit
50b34b9659
|
@ -56,7 +56,7 @@ module VagrantPlugins
|
||||||
copy_proc = Proc.new { windows_copy_file(file, hosts_location) }
|
copy_proc = Proc.new { windows_copy_file(file, hosts_location) }
|
||||||
else
|
else
|
||||||
hosts_location = '/etc/hosts'
|
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
|
end
|
||||||
|
|
||||||
FileUtils.cp(hosts_location, file)
|
FileUtils.cp(hosts_location, file)
|
||||||
|
|
Loading…
Reference in New Issue