puppet 5.3.3-x86-mingw32 → 5.3.4-x86-mingw32

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 (291) hide show
  1. data/CONTRIBUTING.md +1 -1
  2. data/Gemfile +3 -0
  3. data/ext/puppet-test +3 -2
  4. data/lib/hiera/puppet_function.rb +5 -2
  5. data/lib/hiera_puppet.rb +3 -3
  6. data/lib/puppet.rb +2 -5
  7. data/lib/puppet/agent.rb +22 -2
  8. data/lib/puppet/agent/locker.rb +6 -5
  9. data/lib/puppet/application.rb +18 -1
  10. data/lib/puppet/application/agent.rb +9 -2
  11. data/lib/puppet/application/apply.rb +1 -1
  12. data/lib/puppet/application/config.rb +1 -0
  13. data/lib/puppet/application/device.rb +1 -2
  14. data/lib/puppet/application/filebucket.rb +22 -5
  15. data/lib/puppet/application/help.rb +1 -0
  16. data/lib/puppet/application/lookup.rb +1 -3
  17. data/lib/puppet/application_support.rb +6 -1
  18. data/lib/puppet/bindings.rb +2 -1
  19. data/lib/puppet/configurer.rb +9 -4
  20. data/lib/puppet/configurer/downloader_factory.rb +10 -0
  21. data/lib/puppet/configurer/plugin_handler.rb +11 -4
  22. data/lib/puppet/daemon.rb +2 -2
  23. data/lib/puppet/defaults.rb +99 -27
  24. data/lib/puppet/environments.rb +2 -0
  25. data/lib/puppet/error.rb +5 -15
  26. data/lib/puppet/external/pson/common.rb +2 -2
  27. data/lib/puppet/face/catalog.rb +1 -1
  28. data/lib/puppet/face/config.rb +14 -1
  29. data/lib/puppet/face/epp.rb +4 -2
  30. data/lib/puppet/face/help.rb +12 -14
  31. data/lib/puppet/face/man.rb +1 -0
  32. data/lib/puppet/face/module/build.rb +1 -1
  33. data/lib/puppet/face/module/list.rb +6 -17
  34. data/lib/puppet/face/module/uninstall.rb +14 -3
  35. data/lib/puppet/face/node.rb +1 -0
  36. data/lib/puppet/face/status.rb +1 -0
  37. data/lib/puppet/file_serving/base.rb +2 -1
  38. data/lib/puppet/file_serving/configuration.rb +3 -0
  39. data/lib/puppet/file_serving/configuration/parser.rb +23 -9
  40. data/lib/puppet/file_serving/mount/locales.rb +35 -0
  41. data/lib/puppet/forge.rb +2 -1
  42. data/lib/puppet/forge/errors.rb +24 -22
  43. data/lib/puppet/functions/binary_file.rb +1 -0
  44. data/lib/puppet/functions/each.rb +10 -4
  45. data/lib/puppet/functions/eyaml_lookup_key.rb +4 -2
  46. data/lib/puppet/functions/lookup.rb +2 -2
  47. data/lib/puppet/functions/map.rb +12 -2
  48. data/lib/puppet/functions/slice.rb +2 -3
  49. data/lib/puppet/functions/unique.rb +1 -1
  50. data/lib/puppet/functions/yaml_data.rb +1 -1
  51. data/lib/puppet/gettext/config.rb +144 -41
  52. data/lib/puppet/gettext/module_translations.rb +42 -0
  53. data/lib/puppet/graph/relationship_graph.rb +1 -1
  54. data/lib/puppet/graph/simple_graph.rb +3 -3
  55. data/lib/puppet/indirector/catalog/compiler.rb +40 -25
  56. data/lib/puppet/indirector/exec.rb +1 -1
  57. data/lib/puppet/indirector/facts/facter.rb +3 -3
  58. data/lib/puppet/indirector/facts/network_device.rb +2 -2
  59. data/lib/puppet/indirector/file_bucket_file/file.rb +4 -1
  60. data/lib/puppet/indirector/indirection.rb +17 -9
  61. data/lib/puppet/indirector/ldap.rb +2 -2
  62. data/lib/puppet/indirector/node/write_only_yaml.rb +3 -1
  63. data/lib/puppet/indirector/rest.rb +8 -5
  64. data/lib/puppet/indirector/ssl_file.rb +2 -2
  65. data/lib/puppet/indirector/terminus.rb +3 -3
  66. data/lib/puppet/interface.rb +2 -1
  67. data/lib/puppet/interface/action.rb +41 -24
  68. data/lib/puppet/interface/action_builder.rb +14 -5
  69. data/lib/puppet/interface/action_manager.rb +1 -1
  70. data/lib/puppet/interface/documentation.rb +21 -10
  71. data/lib/puppet/interface/face_collection.rb +4 -2
  72. data/lib/puppet/interface/option.rb +36 -15
  73. data/lib/puppet/interface/option_builder.rb +23 -9
  74. data/lib/puppet/interface/option_manager.rb +8 -3
  75. data/lib/puppet/metatype/manager.rb +7 -3
  76. data/lib/puppet/module.rb +18 -21
  77. data/lib/puppet/module_tool/errors/installer.rb +18 -20
  78. data/lib/puppet/module_tool/errors/shared.rb +20 -15
  79. data/lib/puppet/module_tool/errors/uninstaller.rb +1 -0
  80. data/lib/puppet/module_tool/errors/upgrader.rb +1 -1
  81. data/lib/puppet/module_tool/tar/mini.rb +57 -4
  82. data/lib/puppet/network/auth_config_parser.rb +18 -13
  83. data/lib/puppet/network/authstore.rb +2 -2
  84. data/lib/puppet/network/client_request.rb +1 -1
  85. data/lib/puppet/network/format.rb +3 -3
  86. data/lib/puppet/network/http/api/indirection_type.rb +1 -1
  87. data/lib/puppet/network/http/api/master/v3/environment.rb +5 -2
  88. data/lib/puppet/network/http/error.rb +7 -7
  89. data/lib/puppet/network/http/factory.rb +9 -0
  90. data/lib/puppet/network/http/rack.rb +2 -2
  91. data/lib/puppet/network/http/webrick.rb +2 -4
  92. data/lib/puppet/node.rb +25 -6
  93. data/lib/puppet/node/environment.rb +14 -0
  94. data/lib/puppet/node/facts.rb +9 -0
  95. data/lib/puppet/parameter.rb +3 -3
  96. data/lib/puppet/parameter/value_collection.rb +9 -9
  97. data/lib/puppet/parser/ast/leaf.rb +1 -1
  98. data/lib/puppet/parser/ast/node.rb +2 -2
  99. data/lib/puppet/parser/ast/pops_bridge.rb +1 -1
  100. data/lib/puppet/parser/compiler.rb +6 -5
  101. data/lib/puppet/parser/functions.rb +1 -1
  102. data/lib/puppet/parser/functions/generate.rb +2 -4
  103. data/lib/puppet/parser/functions/inline_template.rb +1 -2
  104. data/lib/puppet/parser/functions/sprintf.rb +17 -3
  105. data/lib/puppet/parser/functions/template.rb +6 -2
  106. data/lib/puppet/parser/resource.rb +30 -31
  107. data/lib/puppet/parser/scope.rb +20 -11
  108. data/lib/puppet/parser/templatewrapper.rb +4 -3
  109. data/lib/puppet/pops/evaluator/collector_transformer.rb +2 -1
  110. data/lib/puppet/pops/evaluator/collectors/abstract_collector.rb +1 -1
  111. data/lib/puppet/pops/evaluator/epp_evaluator.rb +21 -8
  112. data/lib/puppet/pops/evaluator/evaluator_impl.rb +2 -1
  113. data/lib/puppet/pops/evaluator/external_syntax_support.rb +1 -1
  114. data/lib/puppet/pops/evaluator/runtime3_converter.rb +3 -1
  115. data/lib/puppet/pops/evaluator/runtime3_resource_support.rb +1 -1
  116. data/lib/puppet/pops/evaluator/runtime3_support.rb +4 -4
  117. data/lib/puppet/pops/functions/dispatch.rb +1 -1
  118. data/lib/puppet/pops/functions/function.rb +8 -2
  119. data/lib/puppet/pops/issue_reporter.rb +7 -2
  120. data/lib/puppet/pops/issues.rb +10 -4
  121. data/lib/puppet/pops/label_provider.rb +1 -1
  122. data/lib/puppet/pops/loader/module_loaders.rb +5 -2
  123. data/lib/puppet/pops/loader/static_loader.rb +1 -1
  124. data/lib/puppet/pops/loaders.rb +7 -3
  125. data/lib/puppet/pops/lookup/explainer.rb +2 -1
  126. data/lib/puppet/pops/lookup/hiera_config.rb +2 -2
  127. data/lib/puppet/pops/lookup/lookup_adapter.rb +4 -4
  128. data/lib/puppet/pops/merge_strategy.rb +6 -3
  129. data/lib/puppet/pops/migration/migration_checker.rb +8 -8
  130. data/lib/puppet/pops/model/ast_transformer.rb +1 -1
  131. data/lib/puppet/pops/model/factory.rb +4 -2
  132. data/lib/puppet/pops/resource/resource_type_impl.rb +1 -1
  133. data/lib/puppet/pops/serialization/abstract_writer.rb +2 -1
  134. data/lib/puppet/pops/types/iterable.rb +2 -0
  135. data/lib/puppet/pops/types/p_object_type.rb +36 -15
  136. data/lib/puppet/pops/types/type_calculator.rb +2 -1
  137. data/lib/puppet/pops/types/type_factory.rb +3 -1
  138. data/lib/puppet/pops/types/type_mismatch_describer.rb +19 -6
  139. data/lib/puppet/pops/types/type_parser.rb +7 -7
  140. data/lib/puppet/pops/types/types.rb +10 -4
  141. data/lib/puppet/pops/validation.rb +14 -12
  142. data/lib/puppet/property.rb +14 -6
  143. data/lib/puppet/property/ensure.rb +2 -2
  144. data/lib/puppet/provider.rb +4 -4
  145. data/lib/puppet/provider/group/aix.rb +4 -2
  146. data/lib/puppet/provider/ldap.rb +2 -2
  147. data/lib/puppet/provider/naginator.rb +1 -1
  148. data/lib/puppet/provider/nameservice.rb +7 -4
  149. data/lib/puppet/provider/nameservice/directoryservice.rb +4 -3
  150. data/lib/puppet/provider/package/aix.rb +1 -1
  151. data/lib/puppet/provider/package/nim.rb +7 -8
  152. data/lib/puppet/provider/package/opkg.rb +1 -1
  153. data/lib/puppet/provider/package/pkg.rb +9 -6
  154. data/lib/puppet/provider/package/pkgutil.rb +3 -3
  155. data/lib/puppet/provider/package/yum.rb +1 -1
  156. data/lib/puppet/provider/parsedfile.rb +4 -4
  157. data/lib/puppet/provider/selmodule/semodule.rb +5 -3
  158. data/lib/puppet/provider/service/base.rb +1 -1
  159. data/lib/puppet/provider/service/init.rb +1 -1
  160. data/lib/puppet/provider/service/launchd.rb +2 -2
  161. data/lib/puppet/provider/service/runit.rb +2 -1
  162. data/lib/puppet/provider/service/smf.rb +2 -0
  163. data/lib/puppet/provider/service/systemd.rb +1 -0
  164. data/lib/puppet/provider/service/upstart.rb +1 -1
  165. data/lib/puppet/provider/user/aix.rb +13 -6
  166. data/lib/puppet/provider/user/openbsd.rb +2 -1
  167. data/lib/puppet/provider/yumrepo/inifile.rb +2 -1
  168. data/lib/puppet/provider/zone/solaris.rb +2 -2
  169. data/lib/puppet/reference/configuration.rb +4 -2
  170. data/lib/puppet/relationship.rb +2 -1
  171. data/lib/puppet/reports/store.rb +1 -1
  172. data/lib/puppet/resource.rb +7 -5
  173. data/lib/puppet/resource/capability_finder.rb +14 -11
  174. data/lib/puppet/resource/catalog.rb +33 -18
  175. data/lib/puppet/resource/type.rb +5 -5
  176. data/lib/puppet/settings.rb +19 -13
  177. data/lib/puppet/settings/base_setting.rb +23 -8
  178. data/lib/puppet/settings/config_file.rb +14 -4
  179. data/lib/puppet/settings/environment_conf.rb +19 -9
  180. data/lib/puppet/ssl/base.rb +9 -4
  181. data/lib/puppet/ssl/oids.rb +8 -2
  182. data/lib/puppet/syntax_checkers/base64.rb +5 -6
  183. data/lib/puppet/transaction.rb +7 -3
  184. data/lib/puppet/transaction/persistence.rb +16 -1
  185. data/lib/puppet/transaction/report.rb +6 -0
  186. data/lib/puppet/type.rb +27 -35
  187. data/lib/puppet/type/file.rb +2 -1
  188. data/lib/puppet/type/file/data_sync.rb +2 -1
  189. data/lib/puppet/type/file/source.rb +1 -1
  190. data/lib/puppet/type/group.rb +1 -1
  191. data/lib/puppet/type/mount.rb +1 -1
  192. data/lib/puppet/type/resources.rb +1 -1
  193. data/lib/puppet/type/schedule.rb +26 -14
  194. data/lib/puppet/type/user.rb +9 -3
  195. data/lib/puppet/type/zone.rb +1 -1
  196. data/lib/puppet/util.rb +27 -21
  197. data/lib/puppet/util/at_fork/solaris.rb +6 -4
  198. data/lib/puppet/util/command_line.rb +5 -0
  199. data/lib/puppet/util/command_line/trollop.rb +6 -5
  200. data/lib/puppet/util/errors.rb +61 -8
  201. data/lib/puppet/util/fileparsing.rb +3 -5
  202. data/lib/puppet/util/http_proxy.rb +14 -6
  203. data/lib/puppet/util/instance_loader.rb +1 -3
  204. data/lib/puppet/util/ldap/manager.rb +6 -3
  205. data/lib/puppet/util/log.rb +19 -24
  206. data/lib/puppet/util/logging.rb +21 -28
  207. data/lib/puppet/util/methodhelper.rb +1 -1
  208. data/lib/puppet/util/nagios_maker.rb +1 -1
  209. data/lib/puppet/util/network_device/config.rb +21 -13
  210. data/lib/puppet/util/plist.rb +3 -1
  211. data/lib/puppet/util/posix.rb +1 -1
  212. data/lib/puppet/util/provider_features.rb +1 -1
  213. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +1 -1
  214. data/lib/puppet/util/reference.rb +2 -3
  215. data/lib/puppet/util/selinux.rb +1 -1
  216. data/lib/puppet/util/storage.rb +2 -2
  217. data/lib/puppet/util/windows/eventlog.rb +10 -5
  218. data/lib/puppet/util/windows/file.rb +61 -9
  219. data/lib/puppet/util/windows/process.rb +1 -1
  220. data/lib/puppet/util/windows/taskscheduler.rb +2 -2
  221. data/lib/puppet/vendor/semantic_puppet/lib/semantic_puppet.rb +5 -1
  222. data/lib/puppet/version.rb +1 -1
  223. data/locales/en/puppet.po +19 -0
  224. data/locales/ja/puppet.po +2739 -809
  225. data/locales/puppet.pot +2367 -734
  226. data/spec/fixtures/unit/application/environments/production/data/common.yaml +2 -0
  227. data/spec/integration/agent/logging_spec.rb +2 -0
  228. data/spec/integration/faces/plugin_spec.rb +1 -0
  229. data/spec/integration/network/authconfig_spec.rb +2 -2
  230. data/spec/integration/parser/collection_spec.rb +2 -2
  231. data/spec/integration/parser/scope_spec.rb +16 -3
  232. data/spec/integration/provider/cron/crontab_spec.rb +1 -0
  233. data/spec/integration/transaction/report_spec.rb +5 -0
  234. data/spec/lib/matchers/json.rb +14 -13
  235. data/spec/unit/agent_spec.rb +33 -0
  236. data/spec/unit/application/config_spec.rb +4 -0
  237. data/spec/unit/application/lookup_spec.rb +30 -0
  238. data/spec/unit/application_spec.rb +18 -0
  239. data/spec/unit/configurer/downloader_factory_spec.rb +33 -0
  240. data/spec/unit/configurer/plugin_handler_spec.rb +71 -16
  241. data/spec/unit/environments_spec.rb +15 -0
  242. data/spec/unit/face/config_spec.rb +8 -9
  243. data/spec/unit/face/epp_face_spec.rb +2 -2
  244. data/spec/unit/face/plugin_spec.rb +50 -4
  245. data/spec/unit/file_serving/configuration/parser_spec.rb +2 -2
  246. data/spec/unit/file_serving/mount/locales_spec.rb +73 -0
  247. data/spec/unit/functions/break_spec.rb +108 -50
  248. data/spec/unit/functions/defined_spec.rb +2 -2
  249. data/spec/unit/functions/hiera_spec.rb +0 -1
  250. data/spec/unit/functions/lookup_spec.rb +85 -19
  251. data/spec/unit/functions/next_spec.rb +1 -1
  252. data/spec/unit/functions/return_spec.rb +2 -2
  253. data/spec/unit/gettext/config_spec.rb +125 -0
  254. data/spec/unit/gettext/module_loading_spec.rb +53 -0
  255. data/spec/unit/indirector/json_spec.rb +0 -11
  256. data/spec/unit/indirector/node/exec_spec.rb +1 -1
  257. data/spec/unit/info_service_spec.rb +1 -1
  258. data/spec/unit/interface_spec.rb +12 -0
  259. data/spec/unit/module_spec.rb +0 -28
  260. data/spec/unit/module_tool/tar/mini_spec.rb +34 -5
  261. data/spec/unit/network/http/factory_spec.rb +22 -0
  262. data/spec/unit/network/http/webrick_spec.rb +30 -29
  263. data/spec/unit/node/environment_spec.rb +16 -0
  264. data/spec/unit/node_spec.rb +102 -16
  265. data/spec/unit/parser/environment_compiler_spec.rb +1 -1
  266. data/spec/unit/parser/functions/sprintf_spec.rb +26 -0
  267. data/spec/unit/parser/resource/param_spec.rb +1 -1
  268. data/spec/unit/pops/evaluator/evaluating_parser_spec.rb +9 -9
  269. data/spec/unit/pops/loaders/static_loader_spec.rb +1 -1
  270. data/spec/unit/pops/parser/parse_containers_spec.rb +1 -1
  271. data/spec/unit/pops/types/type_calculator_spec.rb +40 -0
  272. data/spec/unit/pops/types/type_mismatch_describer_spec.rb +9 -0
  273. data/spec/unit/provider/selmodule_spec.rb +6 -0
  274. data/spec/unit/provider/service/init_spec.rb +1 -1
  275. data/spec/unit/provider/service/smf_spec.rb +2 -0
  276. data/spec/unit/provider/service/systemd_spec.rb +14 -0
  277. data/spec/unit/resource/catalog_spec.rb +12 -2
  278. data/spec/unit/settings/config_file_spec.rb +1 -1
  279. data/spec/unit/transaction/persistence_spec.rb +42 -0
  280. data/spec/unit/transaction/report_spec.rb +19 -4
  281. data/spec/unit/transaction_spec.rb +27 -0
  282. data/spec/unit/type/schedule_spec.rb +14 -0
  283. data/spec/unit/type_spec.rb +3 -3
  284. data/spec/unit/util/errors_spec.rb +1 -1
  285. data/spec/unit/util/http_proxy_spec.rb +37 -0
  286. data/spec/unit/util/log_spec.rb +3 -3
  287. data/spec/unit/util/logging_spec.rb +7 -7
  288. data/spec/unit/util/monkey_patches_spec.rb +6 -2
  289. metadata +3445 -3416
  290. checksums.yaml +0 -7
  291. data/spec/unit/gettext_config_spec.rb +0 -57
@@ -42,6 +42,7 @@ module Puppet::ModuleTool::Errors
42
42
  message += @required_by.map do |mod|
43
43
  _(" '%{module_name}' (%{version}) requires '%{module_dep}' (%{dep_version})") % { module_name: mod['name'], version: v(mod['version']), module_dep: @module_name, dep_version: v(mod['version_requirement']) }
44
44
  end
45
+ #TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
45
46
  message << _(" Use `puppet module uninstall --force` to uninstall this module anyway")
46
47
  message.join("\n")
47
48
  end
@@ -36,6 +36,7 @@ module Puppet::ModuleTool::Errors
36
36
  end
37
37
  end
38
38
  end
39
+ #TRANSLATORS `puppet module upgrade --force` is a command line option that should not be translated
39
40
  message << _(" Use `puppet module upgrade --force` to upgrade only this module")
40
41
  message.join("\n")
41
42
  end
@@ -56,7 +57,6 @@ module Puppet::ModuleTool::Errors
56
57
  message = []
57
58
  message << _("Could not %{action} module '%{module_name}' (%{version})") % { action: @action, module_name: @module_name, version: vstring }
58
59
  message << _(" Downgrading is not allowed.")
59
-
60
60
  message.join("\n")
61
61
  end
62
62
  end
@@ -3,24 +3,77 @@ class Puppet::ModuleTool::Tar::Mini
3
3
  Zlib::GzipReader.open(sourcefile) do |reader|
4
4
  Archive::Tar::Minitar.unpack(reader, destdir, find_valid_files(reader)) do |action, name, stats|
5
5
  case action
6
- when :file_done
7
- File.chmod(0644, "#{destdir}/#{name}")
8
- when :dir, :file_start
6
+ when :dir
9
7
  validate_entry(destdir, name)
8
+ set_dir_mode!(stats)
9
+ Puppet.debug("Extracting: #{destdir}/#{name}")
10
+ when :file_start
11
+ # Octal string of the old file mode.
12
+ validate_entry(destdir, name)
13
+ set_file_mode!(stats)
10
14
  Puppet.debug("Extracting: #{destdir}/#{name}")
11
15
  end
16
+ set_default_user_and_group!(stats)
17
+ stats
12
18
  end
13
19
  end
14
20
  end
15
21
 
16
22
  def pack(sourcedir, destfile)
17
23
  Zlib::GzipWriter.open(destfile) do |writer|
18
- Archive::Tar::Minitar.pack(sourcedir, writer)
24
+ Archive::Tar::Minitar.pack(sourcedir, writer) do |step, name, stats|
25
+ # TODO smcclellan 2017-10-31 Set permissions here when this yield block
26
+ # executes before the header is written. As it stands, the `stats`
27
+ # argument isn't mutable in a way that will effect the desired mode for
28
+ # the file.
29
+ end
19
30
  end
20
31
  end
21
32
 
22
33
  private
23
34
 
35
+ EXECUTABLE = 0755
36
+ NOT_EXECUTABLE = 0644
37
+ USER_EXECUTE = 0100
38
+
39
+ def set_dir_mode!(stats)
40
+ if stats.key?(:mode)
41
+ # This is only the case for `pack`, so this code will not run.
42
+ stats[:mode] = EXECUTABLE
43
+ elsif stats.key?(:entry)
44
+ old_mode = stats[:entry].instance_variable_get(:@mode)
45
+ if old_mode.is_a?(Fixnum)
46
+ stats[:entry].instance_variable_set(:@mode, EXECUTABLE)
47
+ end
48
+ end
49
+ end
50
+
51
+ # Sets a file mode to 0755 if the file is executable by the user.
52
+ # Sets a file mode to 0644 if the file mode is set (non-Windows).
53
+ def sanitized_mode(old_mode)
54
+ old_mode & USER_EXECUTE != 0 ? EXECUTABLE : NOT_EXECUTABLE
55
+ end
56
+
57
+ def set_file_mode!(stats)
58
+ if stats.key?(:mode)
59
+ # This is only the case for `pack`, so this code will not run.
60
+ stats[:mode] = sanitized_mode(stats[:mode])
61
+ elsif stats.key?(:entry)
62
+ old_mode = stats[:entry].instance_variable_get(:@mode)
63
+ # If the user can execute the file, set 0755, otherwise 0644.
64
+ if old_mode.is_a?(Fixnum)
65
+ new_mode = sanitized_mode(old_mode)
66
+ stats[:entry].instance_variable_set(:@mode, new_mode)
67
+ end
68
+ end
69
+ end
70
+
71
+ # Sets UID and GID to 0 for standardization.
72
+ def set_default_user_and_group!(stats)
73
+ stats[:uid] = 0
74
+ stats[:gid] = 0
75
+ end
76
+
24
77
  # Find all the valid files in tarfile.
25
78
  #
26
79
  # This check was mainly added to ignore 'x' and 'g' flags from the PAX
@@ -29,11 +29,14 @@ class AuthConfigParser
29
29
  when /^\s*(allow(?:_ip)?|deny(?:_ip)?|method|environment|auth(?:enticated)?)\s+(.+?)(\s*#.*)?$/
30
30
  if right.nil?
31
31
  #TRANSLATORS "path" is a configuration file entry and should not be translated
32
- raise Puppet::ConfigurationError, _("Missing or invalid 'path' before right directive at line %{count} of %{file}") % { count: count, file: @file }
32
+ raise Puppet::ConfigurationError, _("Missing or invalid 'path' before right directive at %{error_location}") %
33
+ { error_location: Puppet::Util::Errors.error_location(@file, count) }
33
34
  end
34
35
  parse_right_directive(right, $1, $2, count)
35
36
  else
36
- raise Puppet::ConfigurationError, _("Invalid line %{count}: %{line}") % { count: count, line: line }
37
+ error_location_str = Puppet::Util::Errors.error_location(nil, count)
38
+ raise Puppet::ConfigurationError, _("Invalid entry at %{error_location}: %{file_text}") %
39
+ { error_location: error_location_str, file_text: line }
37
40
  end
38
41
  count += 1
39
42
  }
@@ -51,22 +54,23 @@ class AuthConfigParser
51
54
  value.strip!
52
55
  case var
53
56
  when "allow"
54
- modify_right(right, :allow, value, _("allowing %s access"), count)
57
+ modify_right(right, :allow, value, _("allowing %{value} access"), count)
55
58
  when "deny"
56
- modify_right(right, :deny, value, _("denying %s access"), count)
59
+ modify_right(right, :deny, value, _("denying %{value} access"), count)
57
60
  when "allow_ip"
58
- modify_right(right, :allow_ip, value, _("allowing IP %s access"), count)
61
+ modify_right(right, :allow_ip, value, _("allowing IP %{value} access"), count)
59
62
  when "deny_ip"
60
- modify_right(right, :deny_ip, value, _("denying IP %s access"), count)
63
+ modify_right(right, :deny_ip, value, _("denying IP %{value} access"), count)
61
64
  when "method"
62
- modify_right(right, :restrict_method, value, _("allowing 'method' %s"), count)
65
+ modify_right(right, :restrict_method, value, _("allowing 'method' %{value}"), count)
63
66
  when "environment"
64
- modify_right(right, :restrict_environment, value, _("adding environment %s"), count)
67
+ modify_right(right, :restrict_environment, value, _("adding environment %{value}"), count)
65
68
  when /auth(?:enticated)?/
66
- modify_right(right, :restrict_authenticated, value, _("adding authentication %s"), count)
69
+ modify_right(right, :restrict_authenticated, value, _("adding authentication %{value}"), count)
67
70
  else
68
- raise Puppet::ConfigurationError,
69
- _("Invalid argument '%{var}' at line %{count}") % { var: var, count: count }
71
+ error_location_str = Puppet::Util::Errors.error_location(nil, count)
72
+ raise Puppet::ConfigurationError, _("Invalid argument '%{var}' at %{error_location}") %
73
+ { var: var, error_location: error_location_str }
70
74
  end
71
75
  end
72
76
 
@@ -74,10 +78,11 @@ class AuthConfigParser
74
78
  value.split(/\s*,\s*/).each do |val|
75
79
  begin
76
80
  val.strip!
77
- right.info msg % val
81
+ right.info msg % { value: val }
78
82
  right.send(method, val)
79
83
  rescue Puppet::AuthStoreError => detail
80
- raise Puppet::ConfigurationError, _("%{detail} at line %{count} of %{file}") % { detail: detail, count: count, file: @file }, detail.backtrace
84
+ error_location_str = Puppet::Util::Errors.error_location(@file, count)
85
+ raise Puppet::ConfigurationError, "#{detail} #{error_location_str}", detail.backtrace
81
86
  end
82
87
  end
83
88
  end
@@ -19,7 +19,7 @@ module Puppet
19
19
  # This is probably unnecessary, and can cause some weirdnesses in
20
20
  # cases where we're operating over localhost but don't have a real
21
21
  # IP defined.
22
- raise Puppet::DevError, "Name and IP must be passed to 'allowed?'" unless name and ip
22
+ raise Puppet::DevError, _("Name and IP must be passed to 'allowed?'") unless name and ip
23
23
  # else, we're networked and such
24
24
  else
25
25
  # we're local
@@ -186,7 +186,7 @@ module Puppet
186
186
  # Set the declaration type. Either :allow or :deny.
187
187
  def type=(type)
188
188
  type = type.intern
189
- raise ArgumentError, "Invalid declaration type #{type}" unless VALID_TYPES.include?(type)
189
+ raise ArgumentError, _("Invalid declaration type %{type}") % { type: type } unless VALID_TYPES.include?(type)
190
190
  @type = type
191
191
  end
192
192
 
@@ -12,7 +12,7 @@ module Puppet::Network # :nodoc:
12
12
  # are responsible for setting the values correctly, but this common
13
13
  # format makes it possible to check rights.
14
14
  def call
15
- raise ArgumentError, "Request is not set up; cannot build call" unless handler and method
15
+ raise ArgumentError, _("Request is not set up; cannot build call") unless handler and method
16
16
 
17
17
  [handler, method].join(".")
18
18
  end
@@ -40,7 +40,7 @@ class Puppet::Network::Format
40
40
  init_attribute(method, value)
41
41
  end
42
42
 
43
- raise ArgumentError, "Unsupported option(s) #{@options.keys}" unless @options.empty?
43
+ raise ArgumentError, _("Unsupported option(s) %{options_list}") % { options_list: @options.keys } unless @options.empty?
44
44
 
45
45
  @options = nil
46
46
 
@@ -69,8 +69,8 @@ class Puppet::Network::Format
69
69
  def render_multiple(instances)
70
70
  # This method implicitly assumes that all instances are of the same type.
71
71
  return instances[0].class.send(render_multiple_method, instances) if instances[0].class.respond_to?(render_multiple_method)
72
- raise NotImplementedError, _("%{klass} does not respond to %{method}; can not render multiple instances to %{mime}") \
73
- % { klass: instances[0].class, method: render_multiple_method, mime: mime }
72
+ raise NotImplementedError, _("%{klass} does not respond to %{method}; can not render multiple instances to %{mime}") %
73
+ { klass: instances[0].class, method: render_multiple_method, mime: mime }
74
74
  end
75
75
 
76
76
  def required_methods_present?(klass)
@@ -26,7 +26,7 @@ class Puppet::Network::HTTP::API::IndirectionType
26
26
  when :master
27
27
  master_url_prefix
28
28
  else
29
- raise ArgumentError, "Not a valid indirection type"
29
+ raise ArgumentError, _("Not a valid indirection type")
30
30
  end
31
31
  end
32
32
  end
@@ -36,12 +36,15 @@ class Puppet::Network::HTTP::API::Master::V3::Environment
36
36
 
37
37
  nonexistent_components = mapped_components - required_components
38
38
  if nonexistent_components.any?
39
- raise Puppet::ParseError.new("Application #{app} assigns nodes to non-existent components: #{nonexistent_components.join(', ')}", file, line)
39
+ raise Puppet::ParseError.new(
40
+ _("Application %{application} assigns nodes to non-existent components: %{component_list}") %
41
+ { application: app, component_list: nonexistent_components.join(', ') }, file, line)
40
42
  end
41
43
 
42
44
  missing_components = required_components - mapped_components
43
45
  if missing_components.any?
44
- raise Puppet::ParseError.new("Application #{app} has components without assigned nodes: #{missing_components.join(', ')}", file, line)
46
+ raise Puppet::ParseError.new(_("Application %{application} has components without assigned nodes: %{component_list}") %
47
+ { application: app, component_list: missing_components.join(', ') }, file, line)
45
48
  end
46
49
 
47
50
  # Turn the 'nodes' hash into a map component ref => node name
@@ -20,42 +20,42 @@ module Puppet::Network::HTTP::Error
20
20
  class HTTPNotAcceptableError < HTTPError
21
21
  CODE = 406
22
22
  def initialize(message, issue_kind = Issues::RUNTIME_ERROR)
23
- super(_("Not Acceptable: ") + message, CODE, issue_kind)
23
+ super(_("Not Acceptable: %{message}") % { message: message }, CODE, issue_kind)
24
24
  end
25
25
  end
26
26
 
27
27
  class HTTPNotFoundError < HTTPError
28
28
  CODE = 404
29
29
  def initialize(message, issue_kind = Issues::RUNTIME_ERROR)
30
- super(_("Not Found: ") + message, CODE, issue_kind)
30
+ super(_("Not Found: %{message}") % { message: message }, CODE, issue_kind)
31
31
  end
32
32
  end
33
33
 
34
34
  class HTTPNotAuthorizedError < HTTPError
35
35
  CODE = 403
36
36
  def initialize(message, issue_kind = Issues::RUNTIME_ERROR)
37
- super(_("Not Authorized: ") + message, CODE, issue_kind)
37
+ super(_("Not Authorized: %{message}") % { message: message }, CODE, issue_kind)
38
38
  end
39
39
  end
40
40
 
41
41
  class HTTPBadRequestError < HTTPError
42
42
  CODE = 400
43
43
  def initialize(message, issue_kind = Issues::RUNTIME_ERROR)
44
- super(_("Bad Request: ") + message, CODE, issue_kind)
44
+ super(_("Bad Request: %{message}") % { message: message }, CODE, issue_kind)
45
45
  end
46
46
  end
47
47
 
48
48
  class HTTPMethodNotAllowedError < HTTPError
49
49
  CODE = 405
50
50
  def initialize(message, issue_kind = Issues::RUNTIME_ERROR)
51
- super(_("Method Not Allowed: ") + message, CODE, issue_kind)
51
+ super(_("Method Not Allowed: %{message}") % { message: message }, CODE, issue_kind)
52
52
  end
53
53
  end
54
54
 
55
55
  class HTTPUnsupportedMediaTypeError < HTTPError
56
56
  CODE = 415
57
57
  def initialize(message, issue_kind = Issues::RUNTIME_ERROR)
58
- super(_("Unsupported Media Type: ") + message, CODE, issue_kind)
58
+ super(_("Unsupported Media Type: %{message}") % { message: message }, CODE, issue_kind)
59
59
  end
60
60
  end
61
61
 
@@ -63,7 +63,7 @@ module Puppet::Network::HTTP::Error
63
63
  CODE = 500
64
64
 
65
65
  def initialize(original_error, issue_kind = Issues::RUNTIME_ERROR)
66
- super(_("Server Error: ") + original_error.message, CODE, issue_kind)
66
+ super(_("Server Error: %{message}") % { message: original_error.message }, CODE, issue_kind)
67
67
  end
68
68
 
69
69
  def to_json
@@ -38,6 +38,15 @@ class Puppet::Network::HTTP::Factory
38
38
  http.read_timeout = Puppet[:http_read_timeout]
39
39
  http.open_timeout = Puppet[:http_connect_timeout]
40
40
 
41
+ if Puppet[:sourceaddress]
42
+ if http.respond_to?(:local_host)
43
+ Puppet.debug("Using source IP #{Puppet[:sourceaddress]}")
44
+ http.local_host = Puppet[:sourceaddress]
45
+ else
46
+ raise ArgumentError, "Setting 'sourceaddress' is unsupported by this version of Net::HTTP."
47
+ end
48
+ end
49
+
41
50
  if Puppet[:http_debug]
42
51
  http.set_debug_output($stderr)
43
52
  end
@@ -23,9 +23,9 @@ class Puppet::Network::HTTP::Rack
23
23
  # Send a Status 500 Error on unhandled exceptions.
24
24
  response.status = 500
25
25
  response['Content-Type'] = 'text/plain'
26
- response.write _('Internal Server Error: "%s"') % detail.message
26
+ response.write _("Internal Server Error: \"%{message}\"") % { message: detail.message }
27
27
  # log what happened
28
- Puppet.log_exception(detail, _("Puppet Server (Rack): Internal Server Error: Unhandled Exception: \"%s\"") % detail.message)
28
+ Puppet.log_exception(detail, _("Puppet Server (Rack): Internal Server Error: Unhandled Exception: \"%{message}\"") % { message: detail.message })
29
29
  end
30
30
  response.finish
31
31
  end
@@ -17,8 +17,6 @@ class Puppet::Network::HTTP::WEBrick
17
17
  def listen(address, port)
18
18
  @server = create_server(address, port)
19
19
 
20
- @server.listeners.each { |l| l.start_immediately = false }
21
-
22
20
  @server.mount('/', Puppet::Network::HTTP::WEBrickREST)
23
21
 
24
22
  raise _("WEBrick server is already listening") if @listening
@@ -27,7 +25,7 @@ class Puppet::Network::HTTP::WEBrick
27
25
  @server.start do |sock|
28
26
  timeout = 10.0
29
27
  if ! IO.select([sock],nil,nil,timeout)
30
- raise _("Client did not send data within %.1f seconds of connecting") % timeout
28
+ raise _("Client did not send data within %{timeout} seconds of connecting") % { timeout: ("%.1f") % timeout }
31
29
  end
32
30
  sock.accept
33
31
  @server.run(sock)
@@ -101,7 +99,7 @@ class Puppet::Network::HTTP::WEBrick
101
99
 
102
100
  results[:SSLPrivateKey] = host.key.content
103
101
  results[:SSLCertificate] = host.certificate.content
104
- results[:SSLStartImmediately] = true
102
+ results[:SSLStartImmediately] = false
105
103
  results[:SSLEnable] = true
106
104
  results[:SSLOptions] = OpenSSL::SSL::OP_NO_SSLv2 | OpenSSL::SSL::OP_NO_SSLv3
107
105
 
data/lib/puppet/node.rb CHANGED
@@ -27,10 +27,10 @@ class Puppet::Node
27
27
  @name = data['name'] || (raise ArgumentError, _("No name provided in serialized data"))
28
28
  @classes = data['classes'] || []
29
29
  @parameters = data['parameters'] || {}
30
- env_name = data['environment']
30
+ env_name = data['environment'] || @parameters[ENVIRONMENT]
31
31
  env_name = env_name.intern unless env_name.nil?
32
32
  @environment_name = env_name
33
- environment = env_name
33
+ self.environment = env_name
34
34
  end
35
35
 
36
36
  def self.from_data_hash(data)
@@ -45,10 +45,17 @@ class Puppet::Node
45
45
  'environment' => environment.name.to_s,
46
46
  }
47
47
  result['classes'] = classes unless classes.empty?
48
- result['parameters'] = parameters unless parameters.empty?
48
+ serialized_params = self.serializable_parameters
49
+ result['parameters'] = serialized_params unless serialized_params.empty?
49
50
  result
50
51
  end
51
52
 
53
+ def serializable_parameters
54
+ new_params = parameters.dup
55
+ new_params.delete(ENVIRONMENT)
56
+ new_params
57
+ end
58
+
52
59
  def environment
53
60
  if @environment
54
61
  @environment
@@ -60,7 +67,7 @@ class Puppet::Node
60
67
  else
61
68
  # This should not be :current_environment, this is the default
62
69
  # for a node when it has not specified its environment
63
- # Tt will be used to establish what the current environment is.
70
+ # it will be used to establish what the current environment is.
64
71
  #
65
72
  self.environment = Puppet.lookup(:environments).get!(Puppet[:environment])
66
73
  end
@@ -78,7 +85,8 @@ class Puppet::Node
78
85
 
79
86
  # Keep environment_name attribute and parameter in sync if they have been set
80
87
  unless @environment.nil?
81
- @parameters[ENVIRONMENT] = @environment.name.to_s if @parameters.include?(ENVIRONMENT)
88
+ # always set the environment parameter. It becomes top scope $environment for a manifest during catalog compilation.
89
+ @parameters[ENVIRONMENT] = @environment.name.to_s
82
90
  self.environment_name = @environment.name if instance_variable_defined?(:@environment_name)
83
91
  end
84
92
  @environment
@@ -132,7 +140,10 @@ class Puppet::Node
132
140
 
133
141
  if !@facts.nil?
134
142
  @facts.sanitize
143
+ # facts should never modify the environment parameter
144
+ orig_param_env = @parameters[ENVIRONMENT]
135
145
  merge(@facts.values)
146
+ @parameters[ENVIRONMENT] = orig_param_env
136
147
  end
137
148
  end
138
149
 
@@ -145,8 +156,16 @@ class Puppet::Node
145
156
  @parameters[name] = value
146
157
  end
147
158
  end
159
+ end
148
160
 
149
- @parameters[ENVIRONMENT] ||= self.environment.name.to_s
161
+ # Add extra facts, such as facts given to lookup on the command line The
162
+ # extra facts will override existing ones.
163
+ # @param extra_facts [Hash{String=>Object}] the facts to tadd
164
+ # @api private
165
+ def add_extra_facts(extra_facts)
166
+ @facts.add_extra_values(extra_facts)
167
+ @parameters.merge!(extra_facts)
168
+ nil
150
169
  end
151
170
 
152
171
  def add_server_facts(facts)
@@ -433,6 +433,20 @@ class Puppet::Node::Environment
433
433
  deps
434
434
  end
435
435
 
436
+ # Loads module translations for the current environment once for
437
+ # the lifetime of the environment.
438
+ def use_text_domain
439
+ return if Puppet[:disable_i18n]
440
+
441
+ if @text_domain.nil?
442
+ @text_domain = @name
443
+ Puppet::GettextConfig.reset_text_domain(@text_domain)
444
+ Puppet::ModuleTranslations.load_from_modulepath(modules)
445
+ else
446
+ Puppet::GettextConfig.use_text_domain(@text_domain)
447
+ end
448
+ end
449
+
436
450
  # Checks if a reparse is required (cache of files is stale).
437
451
  #
438
452
  def check_for_reparse