facter 2.4.6-x64-mingw32 → 2.5.0-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8a582eadbf72fbfd448266ee70c085d02155acc8
4
+ data.tar.gz: f67bb99de150115bb3da4779fe0457da6dd078c9
5
+ SHA512:
6
+ metadata.gz: e4bce66978749c07dc2b01174a4aeb5e12443f0b66c28b3da17d696b56fd4315568d353ae5107b816d6f954518dd8b689675e8c21aea4dc6e461ad6a2decacb6
7
+ data.tar.gz: 7200dbd84c89536b1ac0f169b243b38b0d2e75367ca9e01c50cdf12f6e42798f2f5b05e285a2308986dbd3344154fbdb0b2b139035185becedd4bd3f9a8b157e
data/Gemfile CHANGED
@@ -14,7 +14,7 @@ group :development, :test do
14
14
  gem 'rspec', "~> 2.11.0"
15
15
  gem 'mocha', "~> 0.10.5"
16
16
  gem 'json', "~> 1.7", :platforms => :ruby
17
- gem 'json-schema', :platforms => :ruby
17
+ gem 'json-schema', "~> 2.6.2", :platforms => :ruby
18
18
  gem 'puppetlabs_spec_helper'
19
19
  end
20
20
 
@@ -33,17 +33,17 @@ data['gem_platform_dependencies'].each_pair do |gem_platform, info|
33
33
  end
34
34
  end
35
35
 
36
- platform(:mingw_19) do
37
- gem 'win32console', '~> 1.3.2', :require => false
38
- end
39
-
40
36
  mingw = [:mingw]
41
37
  mingw << :x64_mingw if Bundler::Dsl::VALID_PLATFORMS.include?(:x64_mingw)
42
38
 
43
39
  platform(*mingw) do
44
- gem 'ffi', '~> 1.9.5', :require => false
45
- gem 'win32-dir', '~> 0.4.8', :require => false
46
- gem 'win32-security', '~> 0.2.5', :require => false
40
+ # FFI dropped 1.9.3 support in 1.9.16, and 1.9.15 was an incomplete release.
41
+ # 1.9.18 is required to support Ruby 2.4
42
+ if RUBY_VERSION < '2.0.0'
43
+ gem 'ffi', '<= 1.9.14', :require => false
44
+ else
45
+ gem 'ffi', '~> 1.9.18', :require => false
46
+ end
47
47
  end
48
48
 
49
49
  gem 'facter', ">= 1.0.0", :path => File.expand_path("..", __FILE__)
@@ -6,7 +6,7 @@ cows: 'base-precise-i386.cow base-precise-amd64.cow base-squeeze-i386.cow base-s
6
6
  pbuild_conf: '/etc/pbuilderrc'
7
7
  packager: 'puppetlabs'
8
8
  gpg_name: 'info@puppetlabs.com'
9
- gpg_key: '4BD6EC30'
9
+ gpg_key: '7F438280EF8D349F'
10
10
  sign_tar: FALSE
11
11
  # a space separated list of mock configs
12
12
  final_mocks: 'pl-el-5-i386 pl-el-5-x86_64 pl-el-6-i386 pl-el-6-x86_64 pl-el-7-x86_64 pl-fedora-20-i386 pl-fedora-20-x86_64'
@@ -16,18 +16,13 @@ gem_default_executables: 'facter'
16
16
  gem_platform_dependencies:
17
17
  universal-darwin:
18
18
  gem_runtime_dependencies:
19
- CFPropertyList: '~> 2.2.6'
19
+ CFPropertyList: '~> 2.2'
20
20
  x86-mingw32:
21
21
  gem_runtime_dependencies:
22
22
  ffi: '~> 1.9.5'
23
- win32-dir: '~> 0.4.8'
24
- win32-security: '~> 0.2.5'
25
- win32console: '~> 1.3.2'
26
23
  x64-mingw32:
27
24
  gem_runtime_dependencies:
28
25
  ffi: '~> 1.9.5'
29
- win32-dir: '~> 0.4.8'
30
- win32-security: '~> 0.2.5'
31
26
  bundle_platforms:
32
27
  universal-darwin: ruby
33
28
  x86-mingw32: mingw
@@ -46,7 +46,14 @@ Facter.define_fact(:ec2_userdata) do
46
46
  end
47
47
 
48
48
  setcode do
49
- @querier.fetch
49
+ userdata = @querier.fetch
50
+ begin
51
+ Facter::Util::Normalization.normalize_string(userdata)
52
+ rescue Facter::Util::Normalization::NormalizationError => e
53
+ Facter.debug("Failed to read ec2 userdata: #{e.message}")
54
+ userdata = nil
55
+ end
56
+ userdata
50
57
  end
51
58
  end
52
59
  end
@@ -20,14 +20,12 @@ module Facter
20
20
 
21
21
  class Base
22
22
  def reachable?(retry_limit = 3)
23
- timeout = 0.2
23
+ timeout = 0.5
24
24
  able_to_connect = false
25
25
  attempts = 0
26
26
 
27
27
  begin
28
- Timeout.timeout(timeout) do
29
- open(@baseurl, :proxy => nil).read
30
- end
28
+ open(@baseurl, :proxy => nil, :read_timeout => timeout).read
31
29
  able_to_connect = true
32
30
  rescue OpenURI::HTTPError => e
33
31
  if e.message.match /404 Not Found/i
@@ -125,7 +123,7 @@ module Facter
125
123
  end
126
124
 
127
125
  def fetch
128
- open(@baseurl).read
126
+ open(@baseurl, :proxy => nil).read
129
127
  rescue OpenURI::HTTPError => e
130
128
  if e.message.match /404 Not Found/i
131
129
  return nil
@@ -45,7 +45,7 @@ module Facter
45
45
 
46
46
  begin
47
47
  Timeout.timeout(timeout) do
48
- body = open(@url).read
48
+ body = open(@url, :proxy => nil).read
49
49
  end
50
50
  rescue *CONNECTION_ERRORS => e
51
51
  attempts = attempts + 1
@@ -11,6 +11,7 @@
11
11
  # Caveats:
12
12
  #
13
13
  require 'facter/util/posix'
14
+ require 'facter/util/windows'
14
15
 
15
16
  Facter.add(:kernelrelease) do
16
17
  setcode 'uname -r'
@@ -39,12 +40,6 @@ end
39
40
  Facter.add(:kernelrelease) do
40
41
  confine :kernel => "windows"
41
42
  setcode do
42
- require 'facter/util/wmi'
43
- version = ""
44
- Facter::Util::WMI.execquery("SELECT Version from Win32_OperatingSystem").each do |ole|
45
- version = "#{ole.Version}"
46
- break
47
- end
48
- version
43
+ Facter::Util::Windows::Process.os_version_string
49
44
  end
50
45
  end
@@ -23,7 +23,9 @@ module Facter
23
23
 
24
24
  def get_osfamily
25
25
  case get_operatingsystem
26
- when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon", "XenServer"
26
+ when "RedHat", "Fedora", "CentOS", "Scientific", "SLC", "Ascendos",
27
+ "CloudLinux", "PSBM", "OracleLinux", "OVS", "OEL", "Amazon",
28
+ "XenServer", "VirtuozzoLinux"
27
29
  "RedHat"
28
30
  when "LinuxMint", "Ubuntu", "Debian"
29
31
  "Debian"
@@ -51,7 +53,8 @@ module Facter
51
53
  when "BlueWhite64"
52
54
  get_bluewhite_release_with_release_file
53
55
  when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM",
54
- "XenServer", "Fedora", "MeeGo", "OracleLinux", "OEL", "oel", "OVS", "ovs"
56
+ "XenServer", "Fedora", "MeeGo", "OracleLinux", "OEL", "oel", "OVS", "ovs",
57
+ "VirtuozzoLinux"
55
58
  get_redhatish_release_with_release_file
56
59
  when "Debian"
57
60
  get_debian_release_with_release_file
@@ -291,13 +294,14 @@ module Facter
291
294
  def get_redhat_operatingsystem_name
292
295
  txt = File.read("/etc/redhat-release")
293
296
  matches = {
294
- "CentOS" => "centos",
295
- "Scientific" => "Scientific",
296
- "CloudLinux" => "^cloudlinux",
297
- "PSBM" => "^Parallels Server Bare Metal",
298
- "Ascendos" => "Ascendos",
299
- "XenServer" => "^XenServer",
300
- "XCP" => "XCP"
297
+ "CentOS" => "centos",
298
+ "Scientific" => "Scientific",
299
+ "CloudLinux" => "^cloudlinux",
300
+ "PSBM" => "^Parallels Server Bare Metal",
301
+ "Ascendos" => "Ascendos",
302
+ "XenServer" => "^XenServer",
303
+ "XCP" => "XCP",
304
+ "VirtuozzoLinux" => "^VirtuozzoLinux"
301
305
  }
302
306
 
303
307
  if txt =~ /CERN/
@@ -381,7 +385,8 @@ module Facter
381
385
 
382
386
  def get_redhatish_release_with_release_file
383
387
  case get_operatingsystem
384
- when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux", "PSBM", "XenServer"
388
+ when "CentOS", "RedHat", "Scientific", "SLC", "Ascendos", "CloudLinux",
389
+ "PSBM", "XenServer", "VirtuozzoLinux"
385
390
  releasefile = "/etc/redhat-release"
386
391
  when "Fedora"
387
392
  releasefile = "/etc/fedora-release"
@@ -4,33 +4,32 @@ module Facter
4
4
  module Operatingsystem
5
5
  class Windows < Base
6
6
  def get_operatingsystemrelease
7
- require 'facter/util/wmi'
7
+ require 'facter/util/windows'
8
8
  result = nil
9
- Facter::Util::WMI.execquery("SELECT version, producttype FROM Win32_OperatingSystem").each do |os|
9
+ Facter::Util::Windows::Process.os_version do |os|
10
10
  result =
11
- case os.version
12
- when /^6\.4/
13
- # As of October 2014, there are no Win server releases with kernel 6.4.x.
14
- # This case prevents future releases from resolving to nil before we
15
- # can update the fact regexes.
16
- os.producttype == 1 ? "10" : Facter[:kernelrelease].value
17
- when /^6\.3/
18
- os.producttype == 1 ? "8.1" : "2012 R2"
19
- when /^6\.2/
20
- os.producttype == 1 ? "8" : "2012"
21
- when /^6\.1/
22
- os.producttype == 1 ? "7" : "2008 R2"
23
- when /^6\.0/
24
- os.producttype == 1 ? "Vista" : "2008"
25
- when /^5\.2/
26
- if os.producttype == 1
11
+ case "#{os[:dwMajorVersion]}.#{os[:dwMinorVersion]}"
12
+ when '10.0'
13
+ if os[:dwBuildNumber] == 14300
14
+ 'Nano'
15
+ else
16
+ os[:wProductType] == 1 ? '10' : Facter[:kernelrelease].value
17
+ end
18
+ when '6.3'
19
+ os[:wProductType] == 1 ? "8.1" : "2012 R2"
20
+ when '6.2'
21
+ os[:wProductType] == 1 ? "8" : "2012"
22
+ when '6.1'
23
+ os[:wProductType] == 1 ? "7" : "2008 R2"
24
+ when '6.0'
25
+ os[:wProductType] == 1 ? "Vista" : "2008"
26
+ when '5.2'
27
+ if os[:wProductType] == 1
27
28
  "XP"
29
+ elsif Facter::Util::Windows::Process.is_2003_r2?
30
+ "2003 R2"
28
31
  else
29
- begin
30
- os.othertypedescription == "R2" ? "2003 R2" : "2003"
31
- rescue NoMethodError
32
- "2003"
33
- end
32
+ "2003"
34
33
  end
35
34
  else
36
35
  Facter[:kernelrelease].value
@@ -22,8 +22,8 @@ module Facter::Util::Config
22
22
  end
23
23
 
24
24
  def self.windows_data_dir
25
- if Dir.const_defined? 'COMMON_APPDATA' then
26
- Dir::COMMON_APPDATA
25
+ if Facter::Util::Config.is_windows?
26
+ Facter::Util::Windows::Dir.get_common_appdata()
27
27
  else
28
28
  nil
29
29
  end
@@ -60,7 +60,7 @@ module Facter::Util::Config
60
60
  end
61
61
 
62
62
  if Facter::Util::Config.is_windows?
63
- require 'win32/dir'
63
+ require 'facter/util/windows/dir'
64
64
  require 'facter/util/windows_root'
65
65
  else
66
66
  require 'facter/util/unix_root'
@@ -13,7 +13,7 @@ module Facter::Util::EC2
13
13
  def can_connect?(wait_sec=2)
14
14
  Facter.warnonce("#{self}.#{__method__} is deprecated; see the Facter::EC2 classes instead")
15
15
  url = "http://169.254.169.254:80/"
16
- Timeout::timeout(wait_sec) {open(url)}
16
+ Timeout::timeout(wait_sec) {open(url, :proxy => nil)}
17
17
  return true
18
18
  rescue Timeout::Error
19
19
  return false
@@ -100,7 +100,7 @@ module Facter::Util::EC2
100
100
  #
101
101
  # @return [String] containing the body of the response
102
102
  def self.read_uri(uri)
103
- open(uri).read
103
+ open(uri, :proxy => nil).read
104
104
  end
105
105
  private_class_method :read_uri
106
106
  end
@@ -6,7 +6,7 @@ module Facter::Util::IP
6
6
  REGEX_MAP = {
7
7
  :linux => {
8
8
  :ipaddress => /inet (?:addr:)?([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
9
- :ipaddress6 => /inet6 (?:addr: )?((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
9
+ :ipaddress6 => /inet6 (?:addr: )?((?!(?:fe80|::1))(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
10
10
  :macaddress => /(?:ether|HWaddr)\s+((\w{1,2}:){5,}\w{1,2})/,
11
11
  :netmask => /(?:Mask:|netmask )([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
12
12
  :mtu => /MTU:?\s*(\d+)/i
@@ -14,14 +14,14 @@ module Facter::Util::IP
14
14
  :bsd => {
15
15
  :aliases => [:openbsd, :netbsd, :freebsd, :darwin, :"gnu/kfreebsd", :dragonfly],
16
16
  :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
17
- :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
17
+ :ipaddress6 => /inet6 ((?!(?:fe80|::1))(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
18
18
  :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/,
19
19
  :netmask => /netmask\s+0x(\w{8})/,
20
20
  :mtu => /mtu\s+(\d+)/
21
21
  },
22
22
  :sunos => {
23
23
  :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
24
- :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
24
+ :ipaddress6 => /inet6 ((?!(?:fe80|::1))(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
25
25
  :macaddress => /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/,
26
26
  :netmask => /netmask\s+(\w{8})/,
27
27
  :mtu => /mtu\s+(\d+)/
@@ -33,7 +33,7 @@ module Facter::Util::IP
33
33
  },
34
34
  :aix => {
35
35
  :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
36
- :ipaddress6 => /inet6 ((?![fe80|::1])(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
36
+ :ipaddress6 => /inet6 ((?!(?:fe80|::1))(?>[0-9,a-f,A-F]*\:{1,2})+[0-9,a-f,A-F]{0,4})/,
37
37
  :netmask => /netmask\s+0x(\w{8})/,
38
38
  :mtu => /mtu\s+(\d+)/,
39
39
  :macaddress => /^Hardware\sAddress:\s(\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2}:\w{1,2})/
@@ -150,7 +150,7 @@ module Facter::Memory
150
150
  when /AIX/i
151
151
  (Facter.value(:id) == "root") ? Facter::Core::Execution.exec('swap -l 2>/dev/null') : nil
152
152
  when /OpenBSD/i
153
- Facter::Core::Execution.exec('swapctl -s')
153
+ Facter::Core::Execution.exec('swapctl -s 2>/dev/null')
154
154
  when /FreeBSD/i
155
155
  Facter::Core::Execution.exec('swapinfo -k')
156
156
  when /Darwin/i
@@ -0,0 +1,10 @@
1
+ module Facter::Util::Windows
2
+ module Process; end
3
+
4
+ if Facter::Util::Config.is_windows?
5
+ require 'facter/util/windows/api_types'
6
+ require 'facter/util/windows/error'
7
+ require 'facter/util/windows/user'
8
+ require 'facter/util/windows/process'
9
+ end
10
+ end
@@ -0,0 +1,143 @@
1
+ require 'ffi'
2
+
3
+ module Facter::Util::Windows::ApiTypes
4
+ module ::FFI
5
+ WIN32_FALSE = 0
6
+
7
+ # standard Win32 error codes
8
+ ERROR_SUCCESS = 0
9
+ end
10
+
11
+ module ::FFI::Library
12
+ # Wrapper method for attach_function + private
13
+ def attach_function_private(*args)
14
+ attach_function(*args)
15
+ private args[0]
16
+ end
17
+ end
18
+
19
+ class ::FFI::Pointer
20
+ NULL_HANDLE = 0
21
+
22
+ def read_win32_bool
23
+ # BOOL is always a 32-bit integer in Win32
24
+ # some Win32 APIs return 1 for true, while others are non-0
25
+ read_int32 != FFI::WIN32_FALSE
26
+ end
27
+ #
28
+ alias_method :read_dword, :read_uint32
29
+
30
+ def read_handle
31
+ type_size == 4 ? read_uint32 : read_uint64
32
+ end
33
+
34
+ def read_wide_string(char_length, dst_encoding = Encoding::UTF_8)
35
+ # char_length is number of wide chars (typically excluding NULLs), *not* bytes
36
+ str = get_bytes(0, char_length * 2).force_encoding('UTF-16LE')
37
+ str.encode(dst_encoding)
38
+ end
39
+
40
+ # @param max_char_length [Integer] Maximum number of wide chars to return (typically excluding NULLs), *not* bytes
41
+ # @param null_terminator [Symbol] Number of number of null wchar characters, *not* bytes, that determine the end of the string
42
+ # null_terminator = :single_null, then the terminating sequence is two bytes of zero. This is UNIT16 = 0
43
+ # null_terminator = :double_null, then the terminating sequence is four bytes of zero. This is UNIT32 = 0
44
+ def read_arbitrary_wide_string_up_to(max_char_length = 512, null_terminator = :single_null)
45
+ if null_terminator != :single_null && null_terminator != :double_null
46
+ raise _("Unable to read wide strings with %{null_terminator} terminal nulls") % { null_terminator: null_terminator }
47
+ end
48
+
49
+ terminator_width = null_terminator == :single_null ? 1 : 2
50
+ reader_method = null_terminator == :single_null ? :get_uint16 : :get_uint32
51
+
52
+ # Look for a null terminating characters; if found, read up to that null (exclusive)
53
+ (0...max_char_length - terminator_width).each do |i|
54
+ return read_wide_string(i) if send(reader_method, (i * 2)) == 0
55
+ end
56
+
57
+ # String is longer than the max; read just to the max
58
+ read_wide_string(max_char_length)
59
+ end
60
+
61
+ def read_win32_local_pointer(&block)
62
+ ptr = nil
63
+ begin
64
+ ptr = read_pointer
65
+ yield ptr
66
+ ensure
67
+ if ptr && ! ptr.null?
68
+ if FFI::WIN32::LocalFree(ptr.address) != FFI::Pointer::NULL_HANDLE
69
+ Puppet.debug "LocalFree memory leak"
70
+ end
71
+ end
72
+ end
73
+
74
+ # ptr has already had LocalFree called, so nothing to return
75
+ nil
76
+ end
77
+ end
78
+ # FFI Types
79
+ # https://github.com/ffi/ffi/wiki/Types
80
+
81
+ # Windows - Common Data Types
82
+ # https://msdn.microsoft.com/en-us/library/cc230309.aspx
83
+
84
+ # Windows Data Types
85
+ # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
86
+
87
+ FFI.typedef :uint32, :dword
88
+ FFI.typedef :uintptr_t, :handle
89
+
90
+ # buffer_inout is similar to pointer (platform specific), but optimized for buffers
91
+ FFI.typedef :buffer_inout, :lpwstr
92
+
93
+ # pointer in FFI is platform specific
94
+ # NOTE: for API calls with reserved lpvoid parameters, pass a FFI::Pointer::NULL
95
+ FFI.typedef :pointer, :lpcvoid
96
+ FFI.typedef :pointer, :lpvoid
97
+ FFI.typedef :pointer, :lpdword
98
+ FFI.typedef :pointer, :pdword
99
+ FFI.typedef :pointer, :phandle
100
+ FFI.typedef :pointer, :pbool
101
+
102
+ # any time LONG / ULONG is in a win32 API definition DO NOT USE platform specific width
103
+ # which is what FFI uses by default
104
+ # instead create new aliases for these very special cases
105
+ # NOTE: not a good idea to redefine FFI :ulong since other typedefs may rely on it
106
+ FFI.typedef :uint32, :win32_ulong
107
+ FFI.typedef :int32, :win32_long
108
+ # FFI bool can be only 1 byte at times,
109
+ # Win32 BOOL is a signed int, and is always 4 bytes, even on x64
110
+ # https://blogs.msdn.com/b/oldnewthing/archive/2011/03/28/10146459.aspx
111
+ FFI.typedef :int32, :win32_bool
112
+
113
+ # Same as a LONG, a 32-bit signed integer
114
+ FFI.typedef :int32, :hresult
115
+
116
+ # NOTE: FFI already defines (u)short as a 16-bit (un)signed like this:
117
+ # FFI.typedef :uint16, :ushort
118
+ # FFI.typedef :int16, :short
119
+
120
+ # 8 bits per byte
121
+ FFI.typedef :uchar, :byte
122
+ FFI.typedef :uint16, :wchar
123
+
124
+ module ::FFI::WIN32
125
+ extend ::FFI::Library
126
+
127
+ ffi_convention :stdcall
128
+
129
+ # https://msdn.microsoft.com/en-us/library/windows/desktop/aa366730(v=vs.85).aspx
130
+ # HLOCAL WINAPI LocalFree(
131
+ # _In_ HLOCAL hMem
132
+ # );
133
+ ffi_lib :kernel32
134
+ attach_function :LocalFree, [:handle], :handle
135
+
136
+ # https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211(v=vs.85).aspx
137
+ # BOOL WINAPI CloseHandle(
138
+ # _In_ HANDLE hObject
139
+ # );
140
+ ffi_lib :kernel32
141
+ attach_function_private :CloseHandle, [:handle], :win32_bool
142
+ end
143
+ end