puppet 4.9.4-universal-darwin → 4.10.0-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of puppet might be problematic. Click here for more details.

Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +6 -0
  3. data/ext/project_data.yaml +2 -2
  4. data/lib/hiera/puppet_function.rb +1 -1
  5. data/lib/puppet.rb +1 -0
  6. data/lib/puppet/application.rb +14 -0
  7. data/lib/puppet/application/inspect.rb +3 -0
  8. data/lib/puppet/defaults.rb +12 -2
  9. data/lib/puppet/etc.rb +125 -0
  10. data/lib/puppet/face/help.rb +1 -1
  11. data/lib/puppet/functions.rb +49 -4
  12. data/lib/puppet/functions/eyaml_lookup_key.rb +12 -3
  13. data/lib/puppet/functions/hocon_data.rb +9 -0
  14. data/lib/puppet/functions/json_data.rb +9 -0
  15. data/lib/puppet/functions/yaml_data.rb +9 -0
  16. data/lib/puppet/indirector/file_bucket_file/file.rb +69 -22
  17. data/lib/puppet/indirector/key/file.rb +2 -1
  18. data/lib/puppet/indirector/ssl_file.rb +24 -3
  19. data/lib/puppet/module.rb +28 -22
  20. data/lib/puppet/network/http/compression.rb +2 -1
  21. data/lib/puppet/parser/compiler.rb +15 -38
  22. data/lib/puppet/parser/functions/hiera.rb +1 -1
  23. data/lib/puppet/parser/functions/hiera_array.rb +1 -1
  24. data/lib/puppet/parser/functions/hiera_hash.rb +1 -1
  25. data/lib/puppet/parser/functions/hiera_include.rb +1 -1
  26. data/lib/puppet/parser/scope.rb +59 -17
  27. data/lib/puppet/pops/evaluator/callable_signature.rb +7 -0
  28. data/lib/puppet/pops/functions/dispatch.rb +18 -5
  29. data/lib/puppet/pops/functions/dispatcher.rb +7 -13
  30. data/lib/puppet/pops/issue_reporter.rb +1 -1
  31. data/lib/puppet/pops/issues.rb +84 -0
  32. data/lib/puppet/pops/loader/base_loader.rb +13 -5
  33. data/lib/puppet/pops/lookup/configured_data_provider.rb +8 -2
  34. data/lib/puppet/pops/lookup/data_dig_function_provider.rb +109 -19
  35. data/lib/puppet/pops/lookup/data_hash_function_provider.rb +19 -4
  36. data/lib/puppet/pops/lookup/data_provider.rb +43 -29
  37. data/lib/puppet/pops/lookup/environment_data_provider.rb +1 -1
  38. data/lib/puppet/pops/lookup/explainer.rb +1 -0
  39. data/lib/puppet/pops/lookup/function_provider.rb +36 -11
  40. data/lib/puppet/pops/lookup/global_data_provider.rb +18 -5
  41. data/lib/puppet/pops/lookup/hiera_config.rb +203 -84
  42. data/lib/puppet/pops/lookup/interpolation.rb +21 -6
  43. data/lib/puppet/pops/lookup/invocation.rb +14 -9
  44. data/lib/puppet/pops/lookup/location_resolver.rb +27 -0
  45. data/lib/puppet/pops/lookup/lookup_adapter.rb +59 -6
  46. data/lib/puppet/pops/lookup/lookup_key_function_provider.rb +9 -77
  47. data/lib/puppet/pops/lookup/module_data_provider.rb +27 -4
  48. data/lib/puppet/pops/parser/lexer2.rb +1 -1
  49. data/lib/puppet/pops/pcore.rb +3 -3
  50. data/lib/puppet/pops/types/p_object_type.rb +4 -6
  51. data/lib/puppet/pops/types/ruby_generator.rb +2 -2
  52. data/lib/puppet/pops/types/type_asserter.rb +3 -3
  53. data/lib/puppet/pops/types/type_mismatch_describer.rb +25 -7
  54. data/lib/puppet/pops/types/types.rb +20 -29
  55. data/lib/puppet/provider/exec.rb +4 -2
  56. data/lib/puppet/provider/nameservice.rb +8 -8
  57. data/lib/puppet/provider/selmodule/semodule.rb +20 -16
  58. data/lib/puppet/provider/service/src.rb +39 -39
  59. data/lib/puppet/provider/service/systemd.rb +1 -1
  60. data/lib/puppet/provider/user/aix.rb +7 -2
  61. data/lib/puppet/settings.rb +30 -17
  62. data/lib/puppet/ssl/base.rb +14 -1
  63. data/lib/puppet/ssl/certificate_authority.rb +4 -2
  64. data/lib/puppet/ssl/configuration.rb +4 -1
  65. data/lib/puppet/ssl/inventory.rb +10 -3
  66. data/lib/puppet/ssl/key.rb +7 -3
  67. data/lib/puppet/test/test_helper.rb +3 -0
  68. data/lib/puppet/type.rb +13 -1
  69. data/lib/puppet/type/exec.rb +16 -1
  70. data/lib/puppet/type/group.rb +17 -11
  71. data/lib/puppet/type/user.rb +3 -1
  72. data/lib/puppet/util.rb +1 -0
  73. data/lib/puppet/util/character_encoding.rb +95 -0
  74. data/lib/puppet/util/execution.rb +9 -6
  75. data/lib/puppet/util/reference.rb +4 -2
  76. data/lib/puppet/util/windows/file.rb +5 -1
  77. data/lib/puppet/version.rb +6 -2
  78. data/locales/config.yaml +1 -1
  79. data/locales/puppet.pot +18 -4
  80. data/spec/integration/ssl/autosign_spec.rb +18 -3
  81. data/spec/integration/ssl/key_spec.rb +104 -0
  82. data/spec/integration/type/user_spec.rb +13 -6
  83. data/spec/spec_helper.rb +7 -0
  84. data/spec/unit/application/inspect_spec.rb +9 -2
  85. data/spec/unit/data_providers/function_data_provider_spec.rb +2 -2
  86. data/spec/unit/etc_spec.rb +234 -0
  87. data/spec/unit/face/certificate_spec.rb +10 -2
  88. data/spec/unit/functions/dig_spec.rb +1 -1
  89. data/spec/unit/functions/hiera_spec.rb +40 -1
  90. data/spec/unit/functions/lookup_fixture_spec.rb +10 -10
  91. data/spec/unit/functions/lookup_spec.rb +1217 -357
  92. data/spec/unit/functions4_spec.rb +37 -1
  93. data/spec/unit/indirector/file_bucket_file/file_spec.rb +33 -2
  94. data/spec/unit/indirector/key/file_spec.rb +1 -1
  95. data/spec/unit/indirector/ssl_file_spec.rb +3 -3
  96. data/spec/unit/module_spec.rb +52 -59
  97. data/spec/unit/network/http/compression_spec.rb +39 -8
  98. data/spec/unit/parser/compiler_spec.rb +14 -0
  99. data/spec/unit/pops/loaders/loaders_spec.rb +21 -3
  100. data/spec/unit/pops/loaders/module_loaders_spec.rb +61 -0
  101. data/spec/unit/pops/lookup/context_spec.rb +56 -8
  102. data/spec/unit/pops/lookup/lookup_spec.rb +32 -1
  103. data/spec/unit/pops/parser/lexer2_spec.rb +8 -0
  104. data/spec/unit/pops/types/ruby_generator_spec.rb +48 -0
  105. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +12 -3
  106. data/spec/unit/pops/types/types_spec.rb +6 -7
  107. data/spec/unit/provider/nameservice_spec.rb +12 -12
  108. data/spec/unit/provider/package/pkg_spec.rb +2 -0
  109. data/spec/unit/provider/service/src_spec.rb +5 -0
  110. data/spec/unit/ssl/base_spec.rb +9 -0
  111. data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
  112. data/spec/unit/ssl/certificate_request_attributes_spec.rb +6 -0
  113. data/spec/unit/ssl/certificate_request_spec.rb +1 -1
  114. data/spec/unit/ssl/certificate_spec.rb +1 -1
  115. data/spec/unit/ssl/configuration_spec.rb +11 -2
  116. data/spec/unit/ssl/inventory_spec.rb +27 -3
  117. data/spec/unit/ssl/key_spec.rb +7 -7
  118. data/spec/unit/type/exec_spec.rb +41 -4
  119. data/spec/unit/type/file_spec.rb +4 -1
  120. data/spec/unit/util/character_encoding_spec.rb +88 -0
  121. data/spec/unit/util/execution_spec.rb +12 -0
  122. data/spec/unit/version_spec.rb +4 -0
  123. metadata +3803 -3810
  124. data/tasks/i18n.rake +0 -20
@@ -211,12 +211,10 @@ class PObjectType < PMetaType
211
211
  # TODO: Assumes Ruby implementation for now
212
212
  if(callable_type.is_a?(PVariantType))
213
213
  callable_type.types.map do |ct|
214
- Functions::Dispatch.new(ct, name, [],
215
- ct.block_type.nil? ? nil : 'block', nil, nil, false)
214
+ Functions::Dispatch.new(ct, name, [], false, ct.block_type.nil? ? nil : 'block')
216
215
  end
217
216
  else
218
- [Functions::Dispatch.new(callable_type, name, [],
219
- callable_type.block_type.nil? ? nil : 'block', nil, nil, false)]
217
+ [Functions::Dispatch.new(callable_type, name, [], false, callable_type.block_type.nil? ? nil : 'block')]
220
218
  end
221
219
  end
222
220
 
@@ -436,7 +434,7 @@ class PObjectType < PMetaType
436
434
  # This method should accept a hash and assume that type assertion has been made already (it is made
437
435
  # by the dispatch added here).
438
436
  if impl_class.respond_to?(:from_asserted_hash)
439
- dispatcher.add_dispatch(from_hash_type, :from_hash, ['hash'], nil, EMPTY_ARRAY, EMPTY_ARRAY, false)
437
+ dispatcher.add(Functions::Dispatch.new(from_hash_type, :from_hash, ['hash']))
440
438
  def from_hash(hash)
441
439
  self.class.impl_class.from_asserted_hash(hash)
442
440
  end
@@ -444,7 +442,7 @@ class PObjectType < PMetaType
444
442
 
445
443
  # Add the dispatch that uses the standard #from_asserted_args or #new method on the class. It's assumed that the
446
444
  # method performs no assertions.
447
- dispatcher.add_dispatch(create_type, :create, param_names, nil, EMPTY_ARRAY, EMPTY_ARRAY, false)
445
+ dispatcher.add(Functions::Dispatch.new(create_type, :create, param_names))
448
446
  if impl_class.respond_to?(:from_asserted_args)
449
447
  def create(*args)
450
448
  self.class.impl_class.from_asserted_args(*args)
@@ -263,11 +263,11 @@ class RubyGenerator < TypeFormatter
263
263
  bld << " end\n"
264
264
 
265
265
  bld << "\n def eql?(o)\n"
266
- bld << " super.eql?(o) &&\n" unless obj.parent.nil?
266
+ bld << " super &&\n" unless obj.parent.nil?
267
267
  bld << " self.class.eql?(o.class) &&\n" if include_class
268
268
  eq_names.each { |eqn| bld << ' @' << eqn << '.eql?(o.' << eqn << ") &&\n" }
269
269
  bld.chomp!(" &&\n")
270
- bld << "\n end\n"
270
+ bld << "\n end\n alias == eql?\n"
271
271
  end
272
272
  end
273
273
  end
@@ -13,7 +13,7 @@ module TypeAsserter
13
13
  #
14
14
  # @api public
15
15
  def self.assert_assignable(subject, expected_type, type_to_check, &block)
16
- report_type_mismatch(subject, expected_type, type_to_check) unless expected_type.assignable?(type_to_check)
16
+ report_type_mismatch(subject, expected_type, type_to_check, 'is incorrect', &block) unless expected_type.assignable?(type_to_check)
17
17
  type_to_check
18
18
  end
19
19
 
@@ -35,11 +35,11 @@ module TypeAsserter
35
35
  value
36
36
  end
37
37
 
38
- def self.report_type_mismatch(subject, expected_type, actual_type)
38
+ def self.report_type_mismatch(subject, expected_type, actual_type, what = 'has wrong type')
39
39
  subject = yield(subject) if block_given?
40
40
  subject = subject[0] % subject[1..-1] if subject.is_a?(Array)
41
41
  raise TypeAssertionError.new(
42
- TypeMismatchDescriber.singleton.describe_mismatch("#{subject} has wrong type,", expected_type, actual_type), expected_type, actual_type)
42
+ TypeMismatchDescriber.singleton.describe_mismatch("#{subject} #{what},", expected_type, actual_type), expected_type, actual_type)
43
43
  end
44
44
  private_class_method :report_type_mismatch
45
45
  end
@@ -293,6 +293,11 @@ module Types
293
293
  super(path)
294
294
  @expected = (expected.is_a?(Array) ? PVariantType.maybe_create(expected) : expected).normalize
295
295
  @actual = actual.normalize
296
+ @optional = false
297
+ end
298
+
299
+ def set_optional
300
+ @optional = true
296
301
  end
297
302
 
298
303
  def ==(o)
@@ -323,8 +328,17 @@ module Types
323
328
  e = expected
324
329
  a = actual
325
330
  multi = false
326
- if e.is_a?(PVariantType)
331
+ if @optional
332
+ if e.is_a?(PVariantType)
333
+ e = [PUndefType::DEFAULT] + e.types
334
+ else
335
+ e = [PUndefType::DEFAULT, e]
336
+ end
337
+ elsif e.is_a?(PVariantType)
327
338
  e = e.types
339
+ end
340
+
341
+ if e.is_a?(Array)
328
342
  if report_detailed?(e, a)
329
343
  a = detailed_actual_to_s(e, a)
330
344
  e = e.map { |t| t.to_alias_expanded_s }
@@ -620,7 +634,7 @@ module Types
620
634
  if param_hash.include?(name)
621
635
  result << describe(value_type, TypeCalculator.singleton.infer_set(value), [ParameterPathElement.new(name)]) unless value_type.instance?(value)
622
636
  else
623
- result << MissingParameter.new(nil, name) unless elem.key_type.assignable?(PUndefType::DEFAULT) unless missing_ok
637
+ result << MissingParameter.new(nil, name) unless missing_ok || elem.key_type.is_a?(POptionalType)
624
638
  end
625
639
  end
626
640
  result
@@ -764,7 +778,10 @@ module Types
764
778
  end
765
779
 
766
780
  def describe_POptionalType(expected, actual, path)
767
- actual.is_a?(PUndefType) ? [] : describe(expected.optional_type, actual, path)
781
+ return EMPTY_ARRAY if actual.is_a?(PUndefType)
782
+ descriptions = describe(expected.optional_type, actual, path)
783
+ descriptions.each { |description| description.set_optional }
784
+ descriptions
768
785
  end
769
786
 
770
787
  def describe_PEnumType(expected, actual, path)
@@ -776,7 +793,7 @@ module Types
776
793
  end
777
794
 
778
795
  def describe_PTypeAliasType(expected, actual, path)
779
- resolved_type = expected.resolved_type.normalize
796
+ resolved_type = expected.resolved_type
780
797
  describe(resolved_type, actual, path).map do |description|
781
798
  if description.is_a?(ExpectedActualMismatch) && description.expected.equal?(resolved_type)
782
799
  description.swap_expected(expected)
@@ -804,7 +821,7 @@ module Types
804
821
  expected_size = expected.size_type
805
822
  actual_size = actual.size_type || PCollectionType::DEFAULT_SIZE
806
823
  if expected_size.nil? || expected_size.assignable?(actual_size)
807
- descriptions << TypeMismatch.new(path, expected, actual)
824
+ descriptions << TypeMismatch.new(path, expected, PArrayType.new(actual.element_type))
808
825
  else
809
826
  descriptions << SizeMismatch.new(path, expected_size, actual_size)
810
827
  end
@@ -834,7 +851,7 @@ module Types
834
851
  expected_size = expected.size_type
835
852
  actual_size = actual.size_type || PCollectionType::DEFAULT_SIZE
836
853
  if expected_size.nil? || expected_size.assignable?(actual_size)
837
- descriptions << TypeMismatch.new(path, expected, actual)
854
+ descriptions << TypeMismatch.new(path, expected, PHashType.new(actual.key_type, actual.value_type))
838
855
  else
839
856
  descriptions << SizeMismatch.new(path, expected_size, actual_size)
840
857
  end
@@ -864,7 +881,7 @@ module Types
864
881
  actual_size = actual.size_type || PCollectionType::DEFAULT_SIZE
865
882
  expected_size = PIntegerType.new(elements.count { |e| !e.key_type.assignable?(PUndefType::DEFAULT) }, elements.size)
866
883
  if expected_size.assignable?(actual_size)
867
- descriptions << TypeMismatch.new(path, expected, actual)
884
+ descriptions << TypeMismatch.new(path, expected, PHashType.new(actual.key_type, actual.value_type))
868
885
  else
869
886
  descriptions << SizeMismatch.new(path, expected_size, actual_size)
870
887
  end
@@ -990,6 +1007,7 @@ module Types
990
1007
  if unresolved
991
1008
  [UnresolvedTypeReference.new(path, unresolved)]
992
1009
  else
1010
+ expected = expected.normalize
993
1011
  case expected
994
1012
  when PVariantType
995
1013
  describe_PVariantType(expected, actual, path)
@@ -2522,7 +2522,7 @@ class PHashType < PCollectionType
2522
2522
  key_t = key_t.normalize(guard) unless key_t.nil?
2523
2523
  value_t = @value_type
2524
2524
  value_t = value_t.normalize(guard) unless value_t.nil?
2525
- @size_type.nil? && @key_type.equal?(key_t) && @value_type.equal?(value_t) ? self : PHashType.new(key_t, value_t, nil)
2525
+ @size_type.nil? && @key_type.equal?(key_t) && @value_type.equal?(value_t) ? self : PHashType.new(key_t, value_t, @size_type)
2526
2526
  end
2527
2527
  end
2528
2528
 
@@ -2668,7 +2668,7 @@ class PVariantType < PAnyType
2668
2668
  # @return [PAnyType] the resulting type
2669
2669
  # @api public
2670
2670
  def self.maybe_create(types)
2671
- types = types.uniq
2671
+ types = flatten_variants(types).uniq
2672
2672
  types.size == 1 ? types[0] : new(types)
2673
2673
  end
2674
2674
 
@@ -2713,24 +2713,15 @@ class PVariantType < PAnyType
2713
2713
 
2714
2714
  if types.size == 1
2715
2715
  types[0]
2716
- elsif types.any? { |t| t.is_a?(PUndefType) }
2717
- # Undef entry present. Use an OptionalType with a normalized Variant of all types that are not Undef
2718
- POptionalType.new(PVariantType.maybe_create(types.reject { |ot| ot.is_a?(PUndefType) }).normalize(guard)).normalize(guard)
2716
+ elsif types.any? { |t| t.is_a?(PUndefType) || t.is_a?(POptionalType) }
2717
+ # Undef entry present. Use an OptionalType with a normalized Variant without Undefs and Optional wrappers
2718
+ POptionalType.new(PVariantType.maybe_create(types.reject { |t| t.is_a?(PUndefType) }.map { |t| t.is_a?(POptionalType) ? t.type : t })).normalize
2719
2719
  else
2720
2720
  # Merge all variants into this one
2721
- types = types.map do |t|
2722
- if t.is_a?(PVariantType)
2723
- modified = true
2724
- t.types
2725
- else
2726
- t
2727
- end
2728
- end
2729
- types.flatten! if modified
2721
+ types = PVariantType.flatten_variants(types)
2730
2722
  size_before_merge = types.size
2731
2723
 
2732
2724
  types = swap_not_undefs(types)
2733
- types = swap_optionals(types)
2734
2725
  types = merge_enums(types)
2735
2726
  types = merge_patterns(types)
2736
2727
  types = merge_version_ranges(types)
@@ -2748,6 +2739,20 @@ class PVariantType < PAnyType
2748
2739
  end
2749
2740
  end
2750
2741
 
2742
+ def self.flatten_variants(types)
2743
+ modified = false
2744
+ types = types.map do |t|
2745
+ if t.is_a?(PVariantType)
2746
+ modified = true
2747
+ t.types
2748
+ else
2749
+ t
2750
+ end
2751
+ end
2752
+ types.flatten! if modified
2753
+ types
2754
+ end
2755
+
2751
2756
  def hash
2752
2757
  @types.hash
2753
2758
  end
@@ -2806,20 +2811,6 @@ class PVariantType < PAnyType
2806
2811
  end
2807
2812
  end
2808
2813
 
2809
- # @api private
2810
- def swap_optionals(array)
2811
- if array.size > 1
2812
- parts = array.partition {|t| t.is_a?(POptionalType) }
2813
- optionals = parts[0]
2814
- if optionals.size > 1
2815
- others = parts[1]
2816
- others << POptionalType.new(PVariantType.maybe_create(optionals.map { |optional| optional.type }).normalize)
2817
- array = others
2818
- end
2819
- end
2820
- array
2821
- end
2822
-
2823
2814
  # @api private
2824
2815
  def swap_not_undefs(array)
2825
2816
  if array.size > 1
@@ -8,6 +8,7 @@ class Puppet::Provider::Exec < Puppet::Provider
8
8
  output = nil
9
9
  status = nil
10
10
  dir = nil
11
+ sensitive = resource.parameters[:command].sensitive
11
12
 
12
13
  checkexe(command)
13
14
 
@@ -23,7 +24,7 @@ class Puppet::Provider::Exec < Puppet::Provider
23
24
 
24
25
  dir ||= Dir.pwd
25
26
 
26
- debug "Executing#{check ? " check": ""} '#{command}'"
27
+ debug "Executing#{check ? " check": ""} '#{sensitive ? '[redacted]' : command}'"
27
28
  begin
28
29
  # Do our chdir
29
30
  Dir.chdir(dir) do
@@ -59,7 +60,8 @@ class Puppet::Provider::Exec < Puppet::Provider
59
60
  output = Puppet::Util::Execution.execute(command, :failonfail => false, :combine => true,
60
61
  :uid => resource[:user], :gid => resource[:group],
61
62
  :override_locale => false,
62
- :custom_environment => environment)
63
+ :custom_environment => environment,
64
+ :sensitive => sensitive)
63
65
  end
64
66
  # The shell returns 127 if the command is missing.
65
67
  if output.exitstatus == 127
@@ -52,14 +52,14 @@ class Puppet::Provider::NameService < Puppet::Provider
52
52
  # for both users and groups.
53
53
  def listbyname
54
54
  names = []
55
- Etc.send("set#{section()}ent")
55
+ Puppet::Etc.send("set#{section()}ent")
56
56
  begin
57
- while ent = Etc.send("get#{section()}ent")
57
+ while ent = Puppet::Etc.send("get#{section()}ent")
58
58
  names << ent.name
59
59
  yield ent.name if block_given?
60
60
  end
61
61
  ensure
62
- Etc.send("end#{section()}ent")
62
+ Puppet::Etc.send("end#{section()}ent")
63
63
  end
64
64
 
65
65
  names
@@ -146,7 +146,7 @@ class Puppet::Provider::NameService < Puppet::Provider
146
146
  # other, more convenient enumerator for these, so we fake one with this
147
147
  # loop. Thanks, Ruby, for your awesome abstractions. --daniel 2012-03-23
148
148
  highest = []
149
- Etc.send(database) {|entry| highest << entry.send(method) }
149
+ Puppet::Etc.send(database) {|entry| highest << entry.send(method) }
150
150
  highest = highest.reject {|x| x > 65000 }.max
151
151
 
152
152
  @prevauto = highest || 1000
@@ -226,7 +226,7 @@ class Puppet::Provider::NameService < Puppet::Provider
226
226
  if @objectinfo.nil? or refresh == true
227
227
  @etcmethod ||= ("get" + self.class.section.to_s + "nam").intern
228
228
  begin
229
- @objectinfo = Etc.send(@etcmethod, @resource[:name])
229
+ @objectinfo = Puppet::Etc.send(@etcmethod, @resource[:name])
230
230
  rescue ArgumentError
231
231
  @objectinfo = nil
232
232
  end
@@ -242,13 +242,13 @@ class Puppet::Provider::NameService < Puppet::Provider
242
242
  groups = []
243
243
 
244
244
  # Reset our group list
245
- Etc.setgrent
245
+ Puppet::Etc.setgrent
246
246
 
247
247
  user = @resource[:name]
248
248
 
249
249
  # Now iterate across all of the groups, adding each one our
250
250
  # user is a member of
251
- while group = Etc.getgrent
251
+ while group = Puppet::Etc.getgrent
252
252
  members = group.mem
253
253
 
254
254
  groups << group.name if members.include? user
@@ -256,7 +256,7 @@ class Puppet::Provider::NameService < Puppet::Provider
256
256
 
257
257
  # We have to close the file, so each listing is a separate
258
258
  # reading of the file.
259
- Etc.endgrent
259
+ Puppet::Etc.endgrent
260
260
 
261
261
  groups.join(",")
262
262
  end
@@ -79,35 +79,39 @@ Puppet::Type.type(:selmodule).provide(:semodule) do
79
79
 
80
80
  def selmodversion_file
81
81
  magic = 0xF97CFF8F
82
+ v = nil
82
83
 
83
84
  filename = selmod_name_to_filename
84
- mod = File.new(filename, "r")
85
+ # Open a file handle and parse the bytes until version is found
86
+ Puppet::FileSystem.open(filename, nil, 'rb') do |mod|
85
87
 
86
- (hdr, ver, numsec) = mod.read(12).unpack('VVV')
88
+ (hdr, ver, numsec) = mod.read(12).unpack('VVV')
87
89
 
88
- raise Puppet::Error, "Found #{hdr} instead of magic #{magic} in #{filename}" if hdr != magic
90
+ raise Puppet::Error, "Found #{hdr} instead of magic #{magic} in #{filename}" if hdr != magic
89
91
 
90
- raise Puppet::Error, "Unknown policy file version #{ver} in #{filename}" if ver != 1
92
+ raise Puppet::Error, "Unknown policy file version #{ver} in #{filename}" if ver != 1
91
93
 
92
- # Read through (and throw away) the file section offsets, and also
93
- # the magic header for the first section.
94
+ # Read through (and throw away) the file section offsets, and also
95
+ # the magic header for the first section.
94
96
 
95
- mod.read((numsec + 1) * 4)
97
+ mod.read((numsec + 1) * 4)
96
98
 
97
- ## Section 1 should be "SE Linux Module"
99
+ ## Section 1 should be "SE Linux Module"
98
100
 
99
- selmod_readnext(mod)
100
- selmod_readnext(mod)
101
+ selmod_readnext(mod)
102
+ selmod_readnext(mod)
101
103
 
102
- # Skip past the section headers
103
- mod.read(14)
104
+ # Skip past the section headers
105
+ mod.read(14)
104
106
 
105
- # Module name
106
- selmod_readnext(mod)
107
+ # Module name
108
+ selmod_readnext(mod)
107
109
 
108
- # At last! the version
110
+ # At last! the version
109
111
 
110
- v = selmod_readnext(mod)
112
+ v = selmod_readnext(mod)
113
+
114
+ end
111
115
 
112
116
  self.debug "file version #{v}"
113
117
  v
@@ -91,56 +91,56 @@ Puppet::Type.type(:service).provide :src, :parent => :base do
91
91
  end
92
92
 
93
93
  def restart
94
- execute([command(:lssrc), "-Ss", @resource[:name]]).each_line do |line|
95
- args = line.split(":")
96
-
97
- next unless args[0] == @resource[:name]
98
-
99
- # Subsystems with the -K flag can get refreshed (HUPed)
100
- # While subsystems with -S (signals) must be stopped/started
101
- method = args[11]
102
- do_refresh = case method
103
- when "-K" then :true
104
- when "-S" then :false
105
- else self.fail("Unknown service communication method #{method}")
106
- end
94
+ execute([command(:lssrc), "-Ss", @resource[:name]]).each_line do |line|
95
+ args = line.split(":")
96
+
97
+ next unless args[0] == @resource[:name]
98
+
99
+ # Subsystems with the -K flag can get refreshed (HUPed)
100
+ # While subsystems with -S (signals) must be stopped/started
101
+ method = args[11]
102
+ do_refresh = case method
103
+ when "-K" then :true
104
+ when "-S" then :false
105
+ else self.fail("Unknown service communication method #{method}")
106
+ end
107
107
 
108
- begin
109
- if do_refresh == :true
110
- execute([command(:refresh), "-s", @resource[:name]])
111
- else
112
- self.stop
113
- self.start
114
- end
115
- return :true
116
- rescue Puppet::ExecutionFailure => detail
117
- raise Puppet::Error.new("Unable to restart service #{@resource[:name]}, error was: #{detail}", detail )
108
+ begin
109
+ if do_refresh == :true
110
+ execute([command(:refresh), "-s", @resource[:name]])
111
+ else
112
+ self.stop
113
+ self.start
118
114
  end
115
+ return :true
116
+ rescue Puppet::ExecutionFailure => detail
117
+ raise Puppet::Error.new("Unable to restart service #{@resource[:name]}, error was: #{detail}", detail )
119
118
  end
120
- self.fail("No such service found")
119
+ end
120
+ self.fail("No such service found")
121
121
  rescue Puppet::ExecutionFailure => detail
122
- raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}", detail )
122
+ raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}", detail )
123
123
  end
124
124
 
125
125
  def status
126
- execute([command(:lssrc), "-s", @resource[:name]]).each_line do |line|
127
- args = line.split
126
+ execute([command(:lssrc), "-s", @resource[:name]]).each_line do |line|
127
+ args = line.split
128
128
 
129
- # This is the header line
130
- next unless args[0] == @resource[:name]
129
+ # This is the header line
130
+ next unless args[0] == @resource[:name]
131
131
 
132
- # PID is the 3rd field, but inoperative subsystems
133
- # skip this so split doesn't work right
134
- state = case args[-1]
135
- when "active" then :running
136
- when "inoperative" then :stopped
137
- end
138
- Puppet.debug("Service #{@resource[:name]} is #{args[-1]}")
139
- return state
132
+ # PID is the 3rd field, but inoperative subsystems
133
+ # skip this so split doesn't work right
134
+ state = case args[-1]
135
+ when "active" then :running
136
+ when "inoperative" then :stopped
140
137
  end
141
- self.fail("No such service found")
138
+ Puppet.debug("Service #{@resource[:name]} is #{args[-1]}")
139
+ return state
140
+ end
142
141
  rescue Puppet::ExecutionFailure => detail
143
- raise Puppet::Error.new("Cannot get status of #{@resource[:name]}, error was: #{detail}", detail )
142
+ self.debug(detail.message)
143
+ return :stopped
144
144
  end
145
145
 
146
146
  end