puppet 8.6.0 → 8.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -2
  3. data/Gemfile.lock +63 -53
  4. data/Rakefile +45 -22
  5. data/examples/hiera/README.md +68 -57
  6. data/examples/hiera/data/common.yaml +12 -0
  7. data/examples/hiera/data/dc1.yaml +6 -0
  8. data/examples/hiera/hiera.yaml +15 -0
  9. data/examples/hiera/modules/ntp/data/common.yaml +4 -0
  10. data/examples/hiera/modules/ntp/hiera.yaml +9 -0
  11. data/examples/hiera/modules/ntp/manifests/config.pp +16 -4
  12. data/examples/hiera/modules/ntp/templates/ntp.conf.epp +3 -0
  13. data/examples/hiera/modules/users/manifests/common.pp +7 -2
  14. data/examples/hiera/modules/users/manifests/dc1.pp +7 -2
  15. data/examples/hiera/site.pp +1 -1
  16. data/ext/project_data.yaml +0 -45
  17. data/ext/windows/service/daemon.rb +9 -2
  18. data/lib/puppet/application/doc.rb +1 -5
  19. data/lib/puppet/application/lookup.rb +2 -0
  20. data/lib/puppet/defaults.rb +5 -19
  21. data/lib/puppet/file_serving/http_metadata.rb +2 -0
  22. data/lib/puppet/functions/regsubst.rb +11 -14
  23. data/lib/puppet/indirector/catalog/compiler.rb +2 -35
  24. data/lib/puppet/module_tool/tar/gnu.rb +10 -8
  25. data/lib/puppet/node/server_facts.rb +43 -0
  26. data/lib/puppet/parser/functions/generate.rb +2 -1
  27. data/lib/puppet/pops/evaluator/deferred_resolver.rb +41 -6
  28. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +2 -1
  29. data/lib/puppet/pops/evaluator/runtime3_support.rb +0 -6
  30. data/lib/puppet/pops/loader/static_loader.rb +2 -2
  31. data/lib/puppet/pops/lookup/module_data_provider.rb +9 -9
  32. data/lib/puppet/provider/aix_object.rb +1 -1
  33. data/lib/puppet/provider/file/posix.rb +16 -2
  34. data/lib/puppet/provider/group/groupadd.rb +30 -9
  35. data/lib/puppet/provider/package/gem.rb +1 -0
  36. data/lib/puppet/provider/package/pkgutil.rb +6 -5
  37. data/lib/puppet/provider/package/puppet_gem.rb +4 -15
  38. data/lib/puppet/provider/package/xbps.rb +127 -0
  39. data/lib/puppet/type/exec.rb +8 -0
  40. data/lib/puppet/type/file/selcontext.rb +7 -6
  41. data/lib/puppet/type/file/target.rb +9 -11
  42. data/lib/puppet/util/command_line/trollop.rb +20 -2
  43. data/lib/puppet/util/execution.rb +1 -1
  44. data/lib/puppet/util/reference.rb +1 -30
  45. data/lib/puppet/util/rpm_compare.rb +1 -1
  46. data/lib/puppet/util/run_mode.rb +40 -0
  47. data/lib/puppet/util/selinux.rb +14 -4
  48. data/lib/puppet/util/windows/com.rb +2 -2
  49. data/lib/puppet/util/windows/daemon.rb +15 -32
  50. data/lib/puppet/version.rb +1 -1
  51. data/locales/puppet.pot +648 -648
  52. data/man/man5/puppet.conf.5 +2 -2
  53. data/man/man8/puppet-agent.8 +1 -1
  54. data/man/man8/puppet-apply.8 +1 -1
  55. data/man/man8/puppet-catalog.8 +1 -1
  56. data/man/man8/puppet-config.8 +1 -1
  57. data/man/man8/puppet-describe.8 +1 -1
  58. data/man/man8/puppet-device.8 +1 -1
  59. data/man/man8/puppet-doc.8 +1 -1
  60. data/man/man8/puppet-epp.8 +1 -1
  61. data/man/man8/puppet-facts.8 +1 -1
  62. data/man/man8/puppet-filebucket.8 +1 -1
  63. data/man/man8/puppet-generate.8 +1 -1
  64. data/man/man8/puppet-help.8 +1 -1
  65. data/man/man8/puppet-lookup.8 +1 -1
  66. data/man/man8/puppet-module.8 +1 -1
  67. data/man/man8/puppet-node.8 +1 -1
  68. data/man/man8/puppet-parser.8 +1 -1
  69. data/man/man8/puppet-plugin.8 +1 -1
  70. data/man/man8/puppet-report.8 +1 -1
  71. data/man/man8/puppet-resource.8 +1 -1
  72. data/man/man8/puppet-script.8 +1 -1
  73. data/man/man8/puppet-ssl.8 +1 -1
  74. data/man/man8/puppet.8 +2 -2
  75. metadata +56 -51
  76. data/examples/hiera/etc/hiera.yaml +0 -15
  77. data/examples/hiera/etc/hieradb/common.yaml +0 -3
  78. data/examples/hiera/etc/hieradb/dc1.yaml +0 -6
  79. data/examples/hiera/etc/hieradb/development.yaml +0 -2
  80. data/examples/hiera/etc/puppet.conf +0 -3
  81. data/examples/hiera/modules/data/manifests/common.pp +0 -4
  82. data/examples/hiera/modules/ntp/manifests/data.pp +0 -4
  83. data/examples/hiera/modules/ntp/templates/ntp.conf.erb +0 -3
  84. data/examples/hiera/modules/users/manifests/development.pp +0 -4
  85. data/tasks/benchmark.rake +0 -180
  86. data/tasks/cfpropertylist.rake +0 -15
  87. data/tasks/ci.rake +0 -24
  88. data/tasks/generate_ast_model.rake +0 -90
  89. data/tasks/generate_cert_fixtures.rake +0 -199
  90. data/tasks/manpages.rake +0 -67
  91. data/tasks/memwalk.rake +0 -195
  92. data/tasks/parallel.rake +0 -410
  93. data/tasks/parser.rake +0 -22
  94. data/tasks/yard.rake +0 -59
@@ -8,20 +8,7 @@ Puppet::Type.type(:package).provide :puppet_gem, :parent => :gem do
8
8
 
9
9
  confine :true => Puppet.runtime[:facter].value(:aio_agent_version)
10
10
 
11
- def self.windows_gemcmd
12
- puppet_dir = ENV.fetch('PUPPET_DIR', nil)
13
- if puppet_dir
14
- File.join(puppet_dir.to_s, 'bin', 'gem.bat')
15
- else
16
- File.join(Gem.default_bindir, 'gem.bat')
17
- end
18
- end
19
-
20
- if Puppet::Util::Platform.windows?
21
- commands :gemcmd => windows_gemcmd
22
- else
23
- commands :gemcmd => "/opt/puppetlabs/puppet/bin/gem"
24
- end
11
+ commands :gemcmd => Puppet.run_mode.gem_cmd
25
12
 
26
13
  def uninstall
27
14
  super
@@ -30,7 +17,9 @@ Puppet::Type.type(:package).provide :puppet_gem, :parent => :gem do
30
17
  end
31
18
 
32
19
  def self.execute_gem_command(command, command_options, custom_environment = {})
33
- custom_environment['PKG_CONFIG_PATH'] = '/opt/puppetlabs/puppet/lib/pkgconfig' unless Puppet::Util::Platform.windows?
20
+ if (pkg_config_path = Puppet.run_mode.pkg_config_path)
21
+ custom_environment['PKG_CONFIG_PATH'] = pkg_config_path
22
+ end
34
23
  super(command, command_options, custom_environment)
35
24
  end
36
25
  end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../../../puppet/provider/package"
4
+
5
+ Puppet::Type.type(:package).provide :xbps, :parent => Puppet::Provider::Package do
6
+ desc "Support for the Package Manager Utility (xbps) used in VoidLinux.
7
+
8
+ This provider supports the `install_options` attribute, which allows command-line flags to be passed to xbps-install.
9
+ These options should be specified as an array where each element is either a string or a hash."
10
+
11
+ commands :xbps_install => "/usr/bin/xbps-install"
12
+ commands :xbps_remove => "/usr/bin/xbps-remove"
13
+ commands :xbps_query => "/usr/bin/xbps-query"
14
+ commands :xbps_pkgdb => "/usr/bin/xbps-pkgdb"
15
+
16
+ confine 'os.name' => :void
17
+ defaultfor 'os.name' => :void
18
+ has_feature :install_options, :uninstall_options, :upgradeable, :holdable, :virtual_packages
19
+
20
+ def self.defaultto_allow_virtual
21
+ false
22
+ end
23
+
24
+ # Fetch the list of packages that are currently installed on the system.
25
+ def self.instances
26
+ packages = []
27
+ execpipe([command(:xbps_query), "-l"]) do |pipe|
28
+ # xbps-query -l output is 'ii package-name-version desc'
29
+ regex = /^\S+\s(\S+)-(\S+)\s+\S+/
30
+ pipe.each_line do |line|
31
+ match = regex.match(line.chomp)
32
+ if match
33
+ packages << new({ name: match.captures[0], ensure: match.captures[1], provider: name })
34
+ else
35
+ warning(_("Failed to match line '%{line}'") % { line: line })
36
+ end
37
+ end
38
+ end
39
+
40
+ packages
41
+ rescue Puppet::ExecutionFailure
42
+ fail(_("Error getting installed packages"))
43
+ end
44
+
45
+ # Install a package quietly (without confirmation or progress bar) using 'xbps-install'.
46
+ def install
47
+ resource_name = @resource[:name]
48
+ resource_source = @resource[:source]
49
+
50
+ cmd = %w[-S -y]
51
+ cmd += install_options if @resource[:install_options]
52
+ cmd << "--repository=#{resource_source}" if resource_source
53
+ cmd << resource_name
54
+
55
+ unhold if properties[:mark] == :hold
56
+ begin
57
+ xbps_install(*cmd)
58
+ ensure
59
+ hold if @resource[:mark] == :hold
60
+ end
61
+ end
62
+
63
+ # Because Voidlinux is a rolling release based distro, installing a package
64
+ # should always result in the newest release.
65
+ def update
66
+ install
67
+ end
68
+
69
+ # Removes a package from the system.
70
+ def uninstall
71
+ resource_name = @resource[:name]
72
+
73
+ cmd = %w[-R -y]
74
+ cmd += uninstall_options if @resource[:uninstall_options]
75
+ cmd << resource_name
76
+
77
+ xbps_remove(*cmd)
78
+ end
79
+
80
+ # The latest version of a given package
81
+ def latest
82
+ query&.[] :ensure
83
+ end
84
+
85
+ # Queries information for a package
86
+ def query
87
+ resource_name = @resource[:name]
88
+ installed_packages = self.class.instances
89
+
90
+ installed_packages.each do |pkg|
91
+ return pkg.properties if @resource[:name].casecmp(pkg.name).zero?
92
+ end
93
+
94
+ return nil unless @resource.allow_virtual?
95
+
96
+ # Search for virtual package
97
+ output = xbps_query("-Rs", resource_name).chomp
98
+
99
+ # xbps-query -Rs output is '[*] package-name-version description'
100
+ regex = /^\[\*\]+\s(\S+)-(\S+)\s+\S+/
101
+ match = regex.match(output)
102
+
103
+ return nil unless match
104
+
105
+ { name: match.captures[0], ensure: match.captures[1], provider: self.class.name }
106
+ end
107
+
108
+ # Puts a package on hold, so it doesn't update by itself on system update
109
+ def hold
110
+ xbps_pkgdb("-m", "hold", @resource[:name])
111
+ end
112
+
113
+ # Puts a package out of hold
114
+ def unhold
115
+ xbps_pkgdb("-m", "unhold", @resource[:name])
116
+ end
117
+
118
+ private
119
+
120
+ def install_options
121
+ join_options(@resource[:install_options])
122
+ end
123
+
124
+ def uninstall_options
125
+ join_options(@resource[:uninstall_options])
126
+ end
127
+ end
@@ -436,6 +436,14 @@ module Puppet
436
436
  back by re-extracting the tarball. If `important.tar` does **not**
437
437
  actually contain `myfile`, the exec will keep running every time
438
438
  Puppet runs.
439
+
440
+ This parameter can also take an array of files and the command will
441
+ not run if **any** of these files exist. For example:
442
+
443
+ creates => ['/tmp/file1', '/tmp/file2'],
444
+
445
+ will only run the command if both files don't exist.
446
+
439
447
  EOT
440
448
 
441
449
  accept_arrays
@@ -40,11 +40,12 @@ module Puppet
40
40
  end
41
41
 
42
42
  def retrieve_default_context(property)
43
+ return nil if Puppet::Util::Platform.windows?
43
44
  if @resource[:selinux_ignore_defaults] == :true
44
45
  return nil
45
46
  end
46
47
 
47
- context = get_selinux_default_context(@resource[:path], @resource[:ensure])
48
+ context = get_selinux_default_context_with_handle(@resource[:path], provider.class.selinux_handle)
48
49
  unless context
49
50
  return nil
50
51
  end
@@ -85,7 +86,7 @@ module Puppet
85
86
  end
86
87
 
87
88
  Puppet::Type.type(:file).newparam(:selinux_ignore_defaults) do
88
- desc "If this is set then Puppet will not ask SELinux (via matchpathcon) to
89
+ desc "If this is set then Puppet will not ask SELinux (via selabel_lookup) to
89
90
  supply defaults for the SELinux attributes (seluser, selrole,
90
91
  seltype, and selrange). In general, you should leave this set at its
91
92
  default and only set it to true when you need Puppet to not try to fix
@@ -98,7 +99,7 @@ module Puppet
98
99
  Puppet::Type.type(:file).newproperty(:seluser, :parent => Puppet::SELFileContext) do
99
100
  desc "What the SELinux user component of the context of the file should be.
100
101
  Any valid SELinux user component is accepted. For example `user_u`.
101
- If not specified it defaults to the value returned by matchpathcon for
102
+ If not specified it defaults to the value returned by selabel_lookup for
102
103
  the file, if any exists. Only valid on systems with SELinux support
103
104
  enabled."
104
105
 
@@ -109,7 +110,7 @@ module Puppet
109
110
  Puppet::Type.type(:file).newproperty(:selrole, :parent => Puppet::SELFileContext) do
110
111
  desc "What the SELinux role component of the context of the file should be.
111
112
  Any valid SELinux role component is accepted. For example `role_r`.
112
- If not specified it defaults to the value returned by matchpathcon for
113
+ If not specified it defaults to the value returned by selabel_lookup for
113
114
  the file, if any exists. Only valid on systems with SELinux support
114
115
  enabled."
115
116
 
@@ -120,7 +121,7 @@ module Puppet
120
121
  Puppet::Type.type(:file).newproperty(:seltype, :parent => Puppet::SELFileContext) do
121
122
  desc "What the SELinux type component of the context of the file should be.
122
123
  Any valid SELinux type component is accepted. For example `tmp_t`.
123
- If not specified it defaults to the value returned by matchpathcon for
124
+ If not specified it defaults to the value returned by selabel_lookup for
124
125
  the file, if any exists. Only valid on systems with SELinux support
125
126
  enabled."
126
127
 
@@ -132,7 +133,7 @@ module Puppet
132
133
  desc "What the SELinux range component of the context of the file should be.
133
134
  Any valid SELinux range component is accepted. For example `s0` or
134
135
  `SystemHigh`. If not specified it defaults to the value returned by
135
- matchpathcon for the file, if any exists. Only valid on systems with
136
+ selabel_lookup for the file, if any exists. Only valid on systems with
136
137
  SELinux support enabled and that have support for MCS (Multi-Category
137
138
  Security)."
138
139
 
@@ -44,22 +44,20 @@ module Puppet
44
44
 
45
45
  raise Puppet::Error, "Could not remove existing file" if Puppet::FileSystem.exist?(@resource[:path])
46
46
 
47
- Dir.chdir(File.dirname(@resource[:path])) do
48
- Puppet::Util::SUIDManager.asuser(@resource.asuser) do
49
- mode = @resource.should(:mode)
50
- if mode
51
- Puppet::Util.withumask(0o00) do
52
- Puppet::FileSystem.symlink(target, @resource[:path])
53
- end
54
- else
47
+ Puppet::Util::SUIDManager.asuser(@resource.asuser) do
48
+ mode = @resource.should(:mode)
49
+ if mode
50
+ Puppet::Util.withumask(0o00) do
55
51
  Puppet::FileSystem.symlink(target, @resource[:path])
56
52
  end
53
+ else
54
+ Puppet::FileSystem.symlink(target, @resource[:path])
57
55
  end
56
+ end
58
57
 
59
- @resource.send(:property_fix)
58
+ @resource.send(:property_fix)
60
59
 
61
- :link_created
62
- end
60
+ :link_created
63
61
  end
64
62
 
65
63
  def insync?(currentvalue)
@@ -335,9 +335,27 @@ class CommandLine
335
335
  when /^-([^-])$/
336
336
  @short[::Regexp.last_match(1)]
337
337
  when /^--no-([^-]\S*)$/
338
- @long["[no-]#{::Regexp.last_match(1)}"]
338
+ possible_match = @long["[no-]#{::Regexp.last_match(1)}"]
339
+ if !possible_match
340
+ partial_match = @long["[no-]#{::Regexp.last_match(1).tr('-', '_')}"] || @long["[no-]#{::Regexp.last_match(1).tr('_', '-')}"]
341
+ if partial_match
342
+ Puppet.deprecation_warning _("Partial argument match detected: correct argument is %{partial_match}, got %{arg}. Partial argument matching is deprecated and will be removed in a future release.") % { arg: arg, partial_match: partial_match }
343
+ end
344
+ partial_match
345
+ else
346
+ possible_match
347
+ end
339
348
  when /^--([^-]\S*)$/
340
- @long[::Regexp.last_match(1)] || @long["[no-]#{::Regexp.last_match(1)}"]
349
+ possible_match = @long[::Regexp.last_match(1)] || @long["[no-]#{::Regexp.last_match(1)}"]
350
+ if !possible_match
351
+ partial_match = @long[::Regexp.last_match(1).tr('-', '_')] || @long[::Regexp.last_match(1).tr('_', '-')] || @long["[no-]#{::Regexp.last_match(1).tr('-', '_')}"] || @long["[no-]#{::Regexp.last_match(1).tr('_', '-')}"]
352
+ if partial_match
353
+ Puppet.deprecation_warning _("Partial argument match detected: correct argument is %{partial_match}, got %{arg}. Partial argument matching is deprecated and will be removed in a future release.") % { arg: arg, partial_match: partial_match }
354
+ end
355
+ partial_match
356
+ else
357
+ possible_match
358
+ end
341
359
  else
342
360
  raise CommandlineError, _("invalid argument syntax: '%{arg}'") % { arg: arg }
343
361
  end
@@ -323,7 +323,7 @@ module Puppet::Util::Execution
323
323
  unless options[:squelch]
324
324
  # if we opened a pipe, we need to clean it up.
325
325
  reader.close if reader
326
- stdout.close! if Puppet::Util::Platform.windows?
326
+ stdout.close! if stdout && Puppet::Util::Platform.windows?
327
327
  end
328
328
  end
329
329
 
@@ -13,7 +13,7 @@ class Puppet::Util::Reference
13
13
  instance_load(:reference, 'puppet/reference')
14
14
 
15
15
  def self.modes
16
- %w[pdf text]
16
+ %w[text]
17
17
  end
18
18
 
19
19
  def self.newreference(name, options = {}, &block)
@@ -32,35 +32,6 @@ class Puppet::Util::Reference
32
32
  end
33
33
  end
34
34
 
35
- def self.pdf(text)
36
- puts _("creating pdf")
37
- rst2latex = which('rst2latex') || which('rst2latex.py') ||
38
- raise(_("Could not find rst2latex"))
39
-
40
- cmd = %(#{rst2latex} /tmp/puppetdoc.txt > /tmp/puppetdoc.tex)
41
- Puppet::Util.replace_file("/tmp/puppetdoc.txt") { |f| f.puts text }
42
- # There used to be an attempt to use secure_open / replace_file to secure
43
- # the target, too, but that did nothing: the race was still here. We can
44
- # get exactly the same benefit from running this effort:
45
- begin
46
- Puppet::FileSystem.unlink('/tmp/puppetdoc.tex')
47
- rescue
48
- nil
49
- end
50
- output = %x(#{cmd})
51
- unless $CHILD_STATUS == 0
52
- $stderr.puts _("rst2latex failed")
53
- $stderr.puts output
54
- exit(1)
55
- end
56
- $stderr.puts output
57
-
58
- # Now convert to pdf
59
- Dir.chdir("/tmp") do
60
- %x(texi2pdf puppetdoc.tex >/dev/null 2>/dev/null)
61
- end
62
- end
63
-
64
35
  def self.references(environment)
65
36
  instance_loader(:reference).loadall(environment)
66
37
  loaded_instances(:reference).sort_by(&:to_s)
@@ -7,7 +7,7 @@ module Puppet::Util::RpmCompare
7
7
  armv5tejl armv6l armv7l m68kmint s390 s390x ia64 x86_64 sh3 sh4
8
8
  ].freeze
9
9
 
10
- ARCH_REGEX = Regexp.new(ARCH_LIST.join('|\.'))
10
+ ARCH_REGEX = Regexp.new(ARCH_LIST.map { |arch| "\\.#{arch}" }.join('|'))
11
11
 
12
12
  # This is an attempt at implementing RPM's
13
13
  # lib/rpmvercmp.c rpmvercmp(a, b) in Ruby.
@@ -87,6 +87,22 @@ module Puppet
87
87
  def log_dir
88
88
  which_dir("/var/log/puppetlabs/puppet", "~/.puppetlabs/var/log")
89
89
  end
90
+
91
+ def pkg_config_path
92
+ '/opt/puppetlabs/puppet/lib/pkgconfig'
93
+ end
94
+
95
+ def gem_cmd
96
+ '/opt/puppetlabs/puppet/bin/gem'
97
+ end
98
+
99
+ def common_module_dir
100
+ '/opt/puppetlabs/puppet/modules'
101
+ end
102
+
103
+ def vendor_module_dir
104
+ '/opt/puppetlabs/puppet/vendor_modules'
105
+ end
90
106
  end
91
107
 
92
108
  class WindowsRunMode < RunMode
@@ -114,8 +130,32 @@ module Puppet
114
130
  which_dir(File.join(windows_common_base("puppet/var/log")), "~/.puppetlabs/var/log")
115
131
  end
116
132
 
133
+ def pkg_config_path
134
+ nil
135
+ end
136
+
137
+ def gem_cmd
138
+ if (puppet_dir = ENV.fetch('PUPPET_DIR', nil))
139
+ File.join(puppet_dir.to_s, 'bin', 'gem.bat')
140
+ else
141
+ File.join(Gem.default_bindir, 'gem.bat')
142
+ end
143
+ end
144
+
145
+ def common_module_dir
146
+ "#{installdir}/puppet/modules" if installdir
147
+ end
148
+
149
+ def vendor_module_dir
150
+ "#{installdir}\\puppet\\vendor_modules" if installdir
151
+ end
152
+
117
153
  private
118
154
 
155
+ def installdir
156
+ ENV.fetch('FACTER_env_windows_installdir', nil)
157
+ end
158
+
119
159
  def windows_common_base(*extra)
120
160
  [ENV.fetch('ALLUSERSPROFILE', nil), "PuppetLabs"] + extra
121
161
  end
@@ -46,6 +46,7 @@ module Puppet::Util::SELinux
46
46
 
47
47
  # Retrieve and return the default context of the file. If we don't have
48
48
  # SELinux support or if the SELinux call fails to file a default then return nil.
49
+ # @deprecated matchpathcon is a deprecated method, selabel_lookup is preferred
49
50
  def get_selinux_default_context(file, resource_ensure = nil)
50
51
  return nil unless selinux_support?
51
52
  # If the filesystem has no support for SELinux labels, return a default of nil
@@ -68,11 +69,20 @@ module Puppet::Util::SELinux
68
69
  end
69
70
 
70
71
  retval = Selinux.matchpathcon(file, mode)
71
- if retval == -1
72
- return nil
73
- end
72
+ retval == -1 ? nil : retval[1]
73
+ end
74
74
 
75
- retval[1]
75
+ def get_selinux_default_context_with_handle(file, handle)
76
+ return nil unless selinux_support?
77
+ # If the filesystem has no support for SELinux labels, return a default of nil
78
+ # instead of what selabel_lookup would return
79
+ return nil unless selinux_label_support?(file)
80
+
81
+ # Handle is needed for selabel_lookup
82
+ raise ArgumentError, _("Cannot get default context with nil handle") unless handle
83
+
84
+ retval = Selinux.selabel_lookup(handle, file, 0)
85
+ retval == -1 ? nil : retval[1]
76
86
  end
77
87
 
78
88
  # Take the full SELinux context returned from the tools and parse it
@@ -141,7 +141,7 @@ module Puppet::Util::Windows::COM
141
141
 
142
142
  self::VTBL.members.each do |name|
143
143
  define_method(name) do |*args|
144
- if Puppet::Util::Windows::COM.FAILED(result = @vtbl[name].call(self, *args))
144
+ if Puppet::Util::Windows::COM.FAILED((result = @vtbl[name].call(self, *args)))
145
145
  raise Puppet::Util::Windows::Error.new(_("Failed to call %{klass}::%{name} with HRESULT: %{result}.") % { klass: self, name: name, result: result }, result)
146
146
  end
147
147
 
@@ -183,7 +183,7 @@ module Puppet::Util::Windows::COM
183
183
 
184
184
  self::VTBL.members.each do |name|
185
185
  define_method(name) do |*args|
186
- if Puppet::Util::Windows::COM.FAILED(result = @vtbl[name].call(self, *args))
186
+ if Puppet::Util::Windows::COM.FAILED((result = @vtbl[name].call(self, *args)))
187
187
  raise Puppet::Util::Windows::Error.new(_("Failed to call %{klass}::%{name} with HRESULT: %{result}.") % { klass: self, name: name, result: result }, result)
188
188
  end
189
189
 
@@ -187,25 +187,6 @@ module Puppet::Util::Windows
187
187
  SetTheServiceStatus.call(SERVICE_STOPPED, NO_ERROR, 0, 0)
188
188
  end
189
189
 
190
- ThreadProc = FFI::Function.new(:ulong, [:pointer]) do |lpParameter|
191
- ste = FFI::MemoryPointer.new(SERVICE_TABLE_ENTRYW, 2)
192
-
193
- s = SERVICE_TABLE_ENTRYW.new(ste[0])
194
- s[:lpServiceName] = FFI::MemoryPointer.from_string('')
195
- s[:lpServiceProc] = lpParameter
196
-
197
- s = SERVICE_TABLE_ENTRYW.new(ste[1])
198
- s[:lpServiceName] = nil
199
- s[:lpServiceProc] = nil
200
-
201
- # No service to step, no service handle, no ruby exceptions, just terminate the thread..
202
- unless StartServiceCtrlDispatcherW(ste)
203
- return 1
204
- end
205
-
206
- return 0
207
- end
208
-
209
190
  # This is a shortcut for Daemon.new + Daemon#mainloop.
210
191
  #
211
192
  def self.mainloop
@@ -255,26 +236,28 @@ module Puppet::Util::Windows
255
236
  raise SystemCallError.new('CreateEvent', FFI.errno)
256
237
  end
257
238
 
258
- hThread = CreateThread(nil, 0, ThreadProc, Service_Main, 0, nil)
239
+ hThread = Thread.new do
240
+ ste = FFI::MemoryPointer.new(SERVICE_TABLE_ENTRYW, 2)
259
241
 
260
- if hThread == 0
261
- raise SystemCallError.new('CreateThread', FFI.errno)
262
- end
242
+ s = SERVICE_TABLE_ENTRYW.new(ste[0])
243
+ s[:lpServiceName] = FFI::MemoryPointer.from_string("")
244
+ s[:lpServiceProc] = Service_Main
263
245
 
264
- events = FFI::MemoryPointer.new(:pointer, 2)
265
- events.put_pointer(0, FFI::Pointer.new(hThread))
266
- events.put_pointer(FFI::Pointer.size, FFI::Pointer.new(@@hStartEvent))
246
+ s = SERVICE_TABLE_ENTRYW.new(ste[1])
247
+ s[:lpServiceName] = nil
248
+ s[:lpServiceProc] = nil
267
249
 
268
- while (index = WaitForMultipleObjects(2, events, 0, 1000)) == WAIT_TIMEOUT
250
+ # No service to step, no service handle, no ruby exceptions, just terminate the thread..
251
+ StartServiceCtrlDispatcherW(ste)
269
252
  end
270
253
 
271
- if index == WAIT_FAILED
272
- raise SystemCallError.new('WaitForMultipleObjects', FFI.errno)
254
+ while (index = WaitForSingleObject(@@hStartEvent, 1000)) == WAIT_TIMEOUT
255
+ # The thread exited, so the show is off.
256
+ raise "Service_Main thread exited abnormally" unless hThread.alive?
273
257
  end
274
258
 
275
- # The thread exited, so the show is off.
276
- if index == WAIT_OBJECT_0
277
- raise "Service_Main thread exited abnormally"
259
+ if index == WAIT_FAILED
260
+ raise SystemCallError.new("WaitForSingleObject", FFI.errno)
278
261
  end
279
262
 
280
263
  thr = Thread.new do
@@ -8,7 +8,7 @@
8
8
  # Raketasks and such to set the version based on the output of `git describe`
9
9
 
10
10
  module Puppet
11
- PUPPETVERSION = '8.6.0'
11
+ PUPPETVERSION = '8.8.1'
12
12
 
13
13
  ##
14
14
  # version is a public API method intended to always provide a fast and