mitchellh/vagrant — pull request #2358 by sgronblo (2013-10-10 05:55:12+00:00)
Title: 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

So I spent many hours yesterday trying to debug what I assumed was a folder related to synced folders. After having a good night's sleep (6h is what we all get right?) I realized I had actually messed up the hostname.

Initially I misremembered the key name for ENV so I set it to something like `config.vm.hostname = "#{ENV['username']}-starter"` which probably caused some command to fail with a lovely "No Error" in pagefuls of Vagrant log output. Some sort of sedding of /etc/hosts and /etc/hostname had already taken place though. This meant that even after I noticed my hostname was dodgy I couldn't change it through the config because hostname -f would fail. I guess the the function that changes the hostname could be made more robust by assuming that hostname -f can fail or something but I concluded that the biggest culprit here was that you can set a hostname that starts with a dash. I was also skeptical about having a hostname that starts with a dot so I added that as a bonus.