No Clean Feed - Stop Internet Censorship in Australia

Fixing UUID generation on DreamHost

Dreamhost recently changed their configuration (at least on our server) to prevent users from running ifconfig. This causes UUID generation to fail, with an error like this showing up in the Rails log:

An exception was thrown while generating the temp path. all of /sbin/ifconfig /bin/ifconfig ifconfig ipconfig /all failed.

Long story, short form: the uuid Gem relies upon the macaddr Gem, which in turn uses one of the above binaries to determine the MAC address of the machine it's running on. So if you can't execute ifconfig (or ipconfig if you're on Windows) then UUID.generate will fail.

There are two possible fixes. Either you can change your code to use the uuidtools Gem, which seems to work nicely without being able to run ifconfig. Or, you can tell the macaddr Gem what the MAC address is in your environment.rb file:

require 'uuid'

# Specify a MAC address because Dreamhost doesn't allow us to run ifconfig.
Mac.mac_address = '00:1f:e0:8c:0f:23'

Either works - I think the former is a better way of doing it (or you'll be modifying your environment.rb file for every machine to which you deploy) but the latter is certainly faster if you're in a hurry.