diff options
author | Claire McQuin <mcquin@users.noreply.github.com> | 2014-04-30 15:54:42 -0700 |
---|---|---|
committer | Claire McQuin <mcquin@users.noreply.github.com> | 2014-04-30 15:54:42 -0700 |
commit | 561b564d28e12731434513f1783cd519690e144b (patch) | |
tree | d78ec643c0c43002a852670e571f6eb38c94b463 /lib | |
parent | 56d6725b9fd1133d3a953b55096460fb4b219679 (diff) | |
parent | 3b77fffe9be2ba02c83dd4598d7072a3821918e3 (diff) | |
download | chef-561b564d28e12731434513f1783cd519690e144b.tar.gz |
Merge pull request #1398 from opscode/config-env
collect :user_home at correct time, for windows
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/config.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/chef/config.rb b/lib/chef/config.rb index f6724354d5..a836c62456 100644 --- a/lib/chef/config.rb +++ b/lib/chef/config.rb @@ -85,7 +85,7 @@ class Chef def self.platform_specific_path(path) if on_windows? # turns /etc/chef/client.rb into C:/chef/client.rb - system_drive = ENV['SYSTEMDRIVE'] ? ENV['SYSTEMDRIVE'] : "" + system_drive = env['SYSTEMDRIVE'] ? env['SYSTEMDRIVE'] : "" path = File.join(system_drive, path.split('/')[2..-1]) # ensure all forward slashes are backslashes path.gsub!(File::SEPARATOR, (File::ALT_SEPARATOR || '\\')) @@ -520,9 +520,18 @@ class Chef set_defaults_for_nix end + # This provides a hook which rspec can stub so that we can avoid twiddling + # global state in tests. + def self.env + ENV + end + + def self.windows_home_path + windows_home_path = env['SYSTEMDRIVE'] + env['HOMEPATH'] if env['SYSTEMDRIVE'] && env['HOMEPATH'] + end + # returns a platform specific path to the user home dir - windows_home_path = ENV['SYSTEMDRIVE'] + ENV['HOMEPATH'] if ENV['SYSTEMDRIVE'] && ENV['HOMEPATH'] - default( :user_home ) { ENV['HOME'] || windows_home_path || ENV['USERPROFILE'] } + default( :user_home ) { env['HOME'] || windows_home_path || env['USERPROFILE'] } # Enable file permission fixup for selinux. Fixup will be done # only if selinux is enabled in the system. |