Merge pull request #176 from criticalstack/fix-selinux-permissions-on-etc-hosts
Ensure permissions on /etc/hosts stay intact
This commit is contained in:
commit
d1ba474417
|
@ -17,17 +17,14 @@ module VagrantPlugins
|
||||||
|
|
||||||
if (machine.communicate.test("uname -s | grep SunOS"))
|
if (machine.communicate.test("uname -s | grep SunOS"))
|
||||||
realhostfile = '/etc/inet/hosts'
|
realhostfile = '/etc/inet/hosts'
|
||||||
move_cmd = 'mv'
|
|
||||||
elsif (machine.communicate.test("test -d $Env:SystemRoot"))
|
elsif (machine.communicate.test("test -d $Env:SystemRoot"))
|
||||||
windir = ""
|
windir = ""
|
||||||
machine.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents|
|
machine.communicate.execute("echo %SYSTEMROOT%", {:shell => :cmd}) do |type, contents|
|
||||||
windir << contents.gsub("\r\n", '') if type == :stdout
|
windir << contents.gsub("\r\n", '') if type == :stdout
|
||||||
end
|
end
|
||||||
realhostfile = "#{windir}\\System32\\drivers\\etc\\hosts"
|
realhostfile = "#{windir}\\System32\\drivers\\etc\\hosts"
|
||||||
move_cmd = 'mv -force'
|
|
||||||
else
|
else
|
||||||
realhostfile = '/etc/hosts'
|
realhostfile = '/etc/hosts'
|
||||||
move_cmd = 'mv -f'
|
|
||||||
end
|
end
|
||||||
# download and modify file with Vagrant-managed entries
|
# download and modify file with Vagrant-managed entries
|
||||||
file = @global_env.tmp_path.join("hosts.#{machine.name}")
|
file = @global_env.tmp_path.join("hosts.#{machine.name}")
|
||||||
|
@ -37,11 +34,9 @@ module VagrantPlugins
|
||||||
# upload modified file and remove temporary file
|
# upload modified file and remove temporary file
|
||||||
machine.communicate.upload(file, '/tmp/hosts')
|
machine.communicate.upload(file, '/tmp/hosts')
|
||||||
if windir
|
if windir
|
||||||
machine.communicate.sudo("#{move_cmd} /tmp/hosts/hosts.#{machine.name} #{realhostfile}")
|
machine.communicate.sudo("mv -force /tmp/hosts/hosts.#{machine.name} #{realhostfile}")
|
||||||
elsif machine.communicate.test('test -f /.dockerinit')
|
|
||||||
machine.communicate.sudo("cat /tmp/hosts > #{realhostfile}")
|
|
||||||
else
|
else
|
||||||
machine.communicate.sudo("#{move_cmd} /tmp/hosts #{realhostfile}")
|
machine.communicate.sudo("cat /tmp/hosts > #{realhostfile}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue