Skip to content

Commit

Permalink
Merge pull request #194 from bendoh/check-hosts-writability
Browse files Browse the repository at this point in the history
If hosts file is writable without sudo, don't use sudo
  • Loading branch information
seth-reeser committed Jun 16, 2016
2 parents dcbcd44 + 50b34b9 commit 5597482
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/vagrant-hostmanager/hosts_file/updater.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class << self
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)
Expand Down

0 comments on commit 5597482

Please sign in to comment.