mirror of
https://github.com/inspec/inspec
synced 2024-11-23 13:13:22 +00:00
Fix issue where absent HOME would break Dir.home
Signed-off-by: Vivek Singh <vivek.singh@msystechnologies.com>
This commit is contained in:
parent
8a608dac76
commit
896e5fa261
1 changed files with 11 additions and 2 deletions
|
@ -1,11 +1,20 @@
|
|||
require_relative "utils/install_context"
|
||||
|
||||
require 'etc' unless defined?(Etc)
|
||||
|
||||
module Inspec
|
||||
|
||||
extend Inspec::InstallContextHelpers
|
||||
|
||||
|
||||
def self.config_dir
|
||||
ENV["INSPEC_CONFIG_DIR"] ? ENV["INSPEC_CONFIG_DIR"] : File.join(Dir.home, ".inspec")
|
||||
begin
|
||||
home = Dir.home
|
||||
rescue ArgumentError, NoMethodError
|
||||
# $HOME is not set in systemd service File.expand_path('~') will not work here
|
||||
home = Etc.getpwuid(Process.uid).dir
|
||||
end
|
||||
|
||||
ENV["INSPEC_CONFIG_DIR"] ? ENV["INSPEC_CONFIG_DIR"] : File.join(home, ".inspec")
|
||||
end
|
||||
|
||||
def self.src_root
|
||||
|
|
Loading…
Reference in a new issue