From c399f075d55a01c4b0f2d76c910fae8cc3e18161 Mon Sep 17 00:00:00 2001 From: Mikhail Zholobov Date: Sat, 4 Apr 2015 16:26:38 +0300 Subject: [PATCH] darwin/cap/change_host_name: Fixed invalid argument LocalHostName --- plugins/guests/darwin/cap/change_host_name.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/guests/darwin/cap/change_host_name.rb b/plugins/guests/darwin/cap/change_host_name.rb index ad7242c91..c65c32642 100644 --- a/plugins/guests/darwin/cap/change_host_name.rb +++ b/plugins/guests/darwin/cap/change_host_name.rb @@ -6,7 +6,9 @@ module VagrantPlugins if !machine.communicate.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'") machine.communicate.sudo("scutil --set ComputerName #{name}") machine.communicate.sudo("scutil --set HostName #{name}") - machine.communicate.sudo("scutil --set LocalHostName #{name}") + # LocalHostName shouldn't contain dots. + # It is used by Bonjour and visible through file sharing services. + machine.communicate.sudo("scutil --set LocalHostName #{name.gsub(/\.+/, '')}") machine.communicate.sudo("hostname #{name}") end end