From 98a9b47567560f1ef9aef2cbbe5843b96674d66d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 9 Mar 2013 10:07:55 -0800 Subject: [PATCH] Validate the hostname setting --- plugins/kernel_v2/config/vm.rb | 2 ++ templates/locales/en.yml | 3 +++ 2 files changed, 5 insertions(+) diff --git a/plugins/kernel_v2/config/vm.rb b/plugins/kernel_v2/config/vm.rb index 3e0e6d102..43f864604 100644 --- a/plugins/kernel_v2/config/vm.rb +++ b/plugins/kernel_v2/config/vm.rb @@ -243,6 +243,8 @@ module VagrantPlugins errors << I18n.t("vagrant.config.vm.box_missing") if !box 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 has_nfs = false @synced_folders.each do |id, options| diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 68ad72d09..86901f28e 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -425,6 +425,9 @@ en: base_mac_invalid: "Base MAC address for eth0/NAT must be set. Contact box maintainer for more information." box_missing: "A box must be specified." 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. network_invalid: |- The network type '%{type}' is not valid. Please use 'hostonly' or 'bridged'.