1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
# frozen_string_literal: true
module Puppet
module Util
module Platform
FIPS_STATUS_FILE = "/proc/sys/crypto/fips_enabled"
WINDOWS_FIPS_REGISTRY_KEY = 'System\\CurrentControlSet\\Control\\Lsa\\FipsAlgorithmPolicy'
def windows?
# Ruby only sets File::ALT_SEPARATOR on Windows and the Ruby standard
# library uses that to test what platform it's on. In some places we
# would use Puppet.features.microsoft_windows?, but this method can be
# used to determine the behavior of the underlying system without
# requiring features to be initialized and without side effect.
!!File::ALT_SEPARATOR
end
module_function :windows?
def solaris?
RUBY_PLATFORM.include?('solaris')
end
module_function :solaris?
def default_paths
return [] if windows?
%w[/usr/sbin /sbin]
end
module_function :default_paths
@fips_enabled = if windows?
require 'win32/registry'
begin
Win32::Registry::HKEY_LOCAL_MACHINE.open(WINDOWS_FIPS_REGISTRY_KEY) do |reg|
reg.values.first == 1
end
rescue Win32::Registry::Error
false
end
else
File.exist?(FIPS_STATUS_FILE) &&
File.read(FIPS_STATUS_FILE, 1) == '1'
end
def fips_enabled?
@fips_enabled
end
module_function :fips_enabled?
def self.jruby?
RUBY_PLATFORM == 'java'
end
def jruby_fips?
@@jruby_fips ||= if RUBY_PLATFORM == 'java'
require 'java'
begin
require 'openssl'
false
rescue LoadError, NameError
true
end
else
false
end
end
module_function :jruby_fips?
end
end
end
|