puppetlabs/Razor — pull request #245 by daniel-pittman (2012-11-19 19:01:23+00:00)
Title: Set HOME to current user homedir to help out Net::SSH

If HOME is not set in the environment, the Ruby Net::SSH gem ends up causing
problems by setting it to `.` - which leads to other parts of Ruby failing in
horrible ways.

Since `ENV['HOME']` isn't actually *required* to be set, and various places
like Puppet starting a service, or other launchers, and Ruby does explode in
exciting ways if it isn't ... we set it to something useful.

By "useful" I mean: if we are on Win32, and have their HOMEPATH and possibly
HOMEDRIVE set, use those to point to the home directory. That is going to
point to a fairly sensible location by default.

On Unix, where that isn't set, we grab the pwent for the current process EUID,
and set the HOME value to the home directory of that user. That is the
closest to "right" I can identify, since it pretty directly mirrors what
login(1) would do in the same circumstance.

This closes #239, by ensuring that we have a more sensible (and absolute) path
available at all times.

Signed-off-by: Daniel Pittman