facter 4.2.8 → 4.2.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3abae20894fc4d31ecfa8190b26307c05f73dce8454b1caa5ae0753cf6f17928
4
- data.tar.gz: 7f5e4ed7f8eda7306ef86101e8a7d61c59b1dd1e56104875378bbd7113b19632
3
+ metadata.gz: b94d35e70448fb5efde799119e0bcfe508e4097133b44939c453fcbd0f39983a
4
+ data.tar.gz: 6f97201f2619f853c2a66ff15cb4538b67dc3d843ff48629ca65d7b0bfc626d3
5
5
  SHA512:
6
- metadata.gz: dcfeebbb72dd925224405095a1043bd6e99ef30afc4395f896172f1441b88a1c4c454ff812c4d23e71da823e20e54b30ae76e08602dd70fd5376c7f5a583f23a
7
- data.tar.gz: 3cccf97b96203afddc850670e73ddc96bfffa9dc5f7949d567f89f44be68a39ba642ec04d930154b874d1b02cc9c98a5a0ae0d78cd96f6a17089ee6b4c01e7c2
6
+ metadata.gz: 3ad5f88e1d7e8517c6cae2687fbf74a05ebcd2a92e54baef7276b08d6e0bee0e4af77e4f908951acf2e956d9e9ff9ced4773fff260639e2e1db3b230da75700a
7
+ data.tar.gz: 6a3e65102fd483807f3d67fa17eda71f7cdce61f59cc7e512c81990d9b02a29389c2c582ae3ccf187d3450918c28f9efc0a7a50c31314950f4109d3492e9c21d
@@ -12,6 +12,8 @@ module Facts
12
12
  'azure' unless Facter::Resolvers::Az.resolve(:metadata).empty?
13
13
  when 'kvm', 'xen'
14
14
  'aws' unless Facter::Resolvers::Ec2.resolve(:metadata).empty?
15
+ when 'gce'
16
+ 'gce' unless Facter::Resolvers::Gce.resolve(:metadata).empty?
15
17
  end
16
18
 
17
19
  Facter::ResolvedFact.new(FACT_NAME, provider)
@@ -13,6 +13,8 @@ module Facts
13
13
  'azure' unless Facter::Resolvers::Az.resolve(:metadata).empty?
14
14
  when 'kvm', 'xen'
15
15
  'aws' unless Facter::Resolvers::Ec2.resolve(:metadata).empty?
16
+ when 'gce'
17
+ 'gce' unless Facter::Resolvers::Gce.resolve(:metadata).empty?
16
18
  end
17
19
 
18
20
  Facter::ResolvedFact.new(FACT_NAME, provider)
@@ -227,7 +227,7 @@ cache_format_version is incorrect!")
227
227
 
228
228
  begin
229
229
  File.delete(cache_file_name) if File.readable?(cache_file_name)
230
- rescue Errno::EACCES => e
230
+ rescue Errno::EACCES, Errno::EROFS => e
231
231
  @log.warn("Could not delete cache: #{e.message}")
232
232
  end
233
233
  end
@@ -34,11 +34,13 @@ module Facter
34
34
  end
35
35
 
36
36
  def determine_other(output)
37
- other_vm = output.split("\n").first
37
+ values = output.split("\n")
38
+ other_vm = values.first
38
39
  return unless other_vm
39
40
 
40
41
  return 'zlinux' if other_vm =~ /ibm_systemz/
41
42
  return retrieve_vserver if other_vm =~ /linux_vserver/
43
+ return (values - ['redhat']).first if values.include?('redhat')
42
44
 
43
45
  other_vm
44
46
  end
@@ -24,26 +24,33 @@ MAX_PATH = 32_767
24
24
 
25
25
  module FFI
26
26
  WIN32FALSE = 0
27
- END_OF_WCHAR_STRING = "\0\0".encode('UTF-16LE')
27
+ END_OF_WCHAR_STRING = (+"\0\0").force_encoding(Encoding::UTF_16LE).freeze
28
28
 
29
29
  class Pointer
30
30
  def read_wide_string_with_length(char_length)
31
31
  # char_length is number of wide chars (typically excluding NULLs), *not* bytes
32
- str = get_bytes(0, char_length * 2).force_encoding('UTF-16LE')
33
- str.encode('UTF-8', str.encoding)
32
+ str = get_bytes(0, char_length * 2).force_encoding(Encoding::UTF_16LE)
33
+ str.encode(Encoding::UTF_8, str.encoding)
34
34
  end
35
35
 
36
- def read_wide_string_without_length
36
+ def read_wide_string_without_length(replace_invalid_chars: false)
37
37
  wide_character = get_bytes(0, 2)
38
+ wide_character.force_encoding(Encoding::UTF_16LE)
38
39
  i = 2
39
40
  str = []
40
41
 
41
- while wide_character.encode('UTF-16LE') != END_OF_WCHAR_STRING
42
+ while wide_character != END_OF_WCHAR_STRING
42
43
  str << wide_character
43
44
  wide_character = get_bytes(i, 2)
45
+ wide_character.force_encoding(Encoding::UTF_16LE)
44
46
  i += 2
45
47
  end
46
- str.join.force_encoding('UTF-16LE').encode('UTF-8')
48
+
49
+ if replace_invalid_chars
50
+ str.join.force_encoding(Encoding::UTF_16LE).encode(Encoding::UTF_8, Encoding::UTF_16LE, invalid: :replace)
51
+ else
52
+ str.join.force_encoding(Encoding::UTF_16LE).encode(Encoding::UTF_8)
53
+ end
47
54
  end
48
55
 
49
56
  def read_win32_bool
@@ -71,12 +71,11 @@ module Facter
71
71
  adapter_address = IpAdapterAddressesLh.new(adapter_address[:Next])
72
72
  next
73
73
  end
74
-
75
74
  if !@fact_list[:domain] || @fact_list[:domain].empty?
76
- @fact_list[:domain] = adapter_address[:DnsSuffix].read_wide_string_without_length
75
+ @fact_list[:domain] = adapter_address[:DnsSuffix]
76
+ .read_wide_string_without_length(replace_invalid_chars: true)
77
77
  end
78
-
79
- name = adapter_address[:FriendlyName].read_wide_string_without_length
78
+ name = adapter_address[:FriendlyName].read_wide_string_without_length(replace_invalid_chars: true)
80
79
  net_interface[name] = build_interface_info(adapter_address, name)
81
80
  end
82
81
 
@@ -14,7 +14,7 @@ module Facter
14
14
  kernel_version = input[:kernel_version]
15
15
 
16
16
  if version =~ /10.0/
17
- check_version_10(consumerrel, kernel_version)
17
+ check_version_10_11(consumerrel, kernel_version)
18
18
  else
19
19
  check_version_6(version, consumerrel) || check_version_5(version, consumerrel, description) || version
20
20
  end
@@ -22,10 +22,12 @@ module Facter
22
22
 
23
23
  private
24
24
 
25
- def check_version_10(consumerrel, kernel_version)
25
+ def check_version_10_11(consumerrel, kernel_version)
26
+ build_number = kernel_version[/([^.]*)$/].to_i
27
+
28
+ return '11' if build_number >= 22_000
26
29
  return '10' if consumerrel
27
30
 
28
- build_number = kernel_version[/([^.]*)$/].to_i
29
31
  if build_number >= 20_348
30
32
  '2022'
31
33
  elsif build_number >= 17_623
@@ -9,14 +9,14 @@ module Facter
9
9
  DEBUG_MESSAGE = 'File at: %s is not accessible.'
10
10
 
11
11
  def safe_read(path, default_return = '')
12
- return File.read(path) if File.readable?(path)
12
+ return File.read(path, encoding: Encoding::UTF_8) if File.readable?(path)
13
13
 
14
14
  log_failed_to_read(path)
15
15
  default_return
16
16
  end
17
17
 
18
18
  def safe_readlines(path, default_return = [])
19
- return File.readlines(path) if File.readable?(path)
19
+ return File.readlines(path, encoding: Encoding::UTF_8) if File.readable?(path)
20
20
 
21
21
  log_failed_to_read(path)
22
22
  default_return
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Facter
4
- VERSION = '4.2.8' unless defined?(VERSION)
4
+ VERSION = '4.2.11' unless defined?(VERSION)
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: facter
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.8
4
+ version: 4.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-17 00:00:00.000000000 Z
11
+ date: 2022-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake