From 9a7ca06cfa8f2f84d6566875d3393b3509056b71 Mon Sep 17 00:00:00 2001 From: Sam Gronblom Date: Thu, 10 Oct 2013 14:42:48 +0900 Subject: [PATCH] Disallow dot and hyphen as first character of hostnames - Causes hostname to be set to an invalid value on some systems which also causes malfunction of hostname -f so it cannot be changed --- plugins/kernel_v2/config/vm.rb | 2 +- templates/locales/en.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index cc789d21a..3be717eb0 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -353,7 +353,7 @@ module VagrantPlugins errors << I18n.t("vagrant.config.vm.box_not_found", :name => box) if \ box && !box_url && !machine.box errors << I18n.t("vagrant.config.vm.hostname_invalid_characters") if \ - @hostname && @hostname !~ /^[-.a-z0-9]+$/i + @hostname && @hostname !~ /^[a-z0-9][-.a-z0-9]+$/i has_nfs = false used_guest_paths = Set.new diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 1f82cfb14..762218255 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -691,7 +691,7 @@ en: box_not_found: "The box '%{name}' could not be found." hostname_invalid_characters: |- The hostname set for the VM should only contain letters, numbers, - and hyphens. + hyphens or dots. It cannot start with a hyphen or dot. network_invalid: |- The network type '%{type}' is not valid. Please use 'hostonly' or 'bridged'.