puppet 2.7.19 → 2.7.20.rc1

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 (324) hide show
  1. data/CONTRIBUTING.md +61 -238
  2. data/Gemfile +32 -0
  3. data/Gemfile.lock +44 -0
  4. data/LICENSE +1 -1
  5. data/README_DEVELOPER.md +300 -5
  6. data/Rakefile +41 -37
  7. data/ext/build_defaults.yaml +20 -0
  8. data/ext/debian/README.Debian +8 -0
  9. data/ext/debian/README.source +2 -0
  10. data/ext/debian/TODO.Debian +1 -0
  11. data/ext/debian/changelog.erb +1104 -0
  12. data/ext/debian/compat +1 -0
  13. data/ext/debian/control +142 -0
  14. data/ext/debian/copyright +361 -0
  15. data/ext/debian/docs +1 -0
  16. data/ext/debian/fileserver.conf +17 -0
  17. data/ext/debian/puppet-common.dirs +8 -0
  18. data/ext/debian/puppet-common.install +3 -0
  19. data/ext/debian/puppet-common.lintian-overrides +7 -0
  20. data/ext/debian/puppet-common.manpages +2 -0
  21. data/ext/debian/puppet-common.postinst +35 -0
  22. data/ext/debian/puppet-common.postrm +32 -0
  23. data/ext/debian/puppet-el.dirs +1 -0
  24. data/ext/debian/puppet-el.emacsen-install +25 -0
  25. data/ext/debian/puppet-el.emacsen-remove +11 -0
  26. data/ext/debian/puppet-el.emacsen-startup +9 -0
  27. data/ext/debian/puppet-el.install +1 -0
  28. data/ext/debian/puppet-testsuite.install +3 -0
  29. data/ext/debian/puppet-testsuite.lintian-overrides +4 -0
  30. data/ext/debian/puppet.NEWS +86 -0
  31. data/ext/debian/puppet.conf +14 -0
  32. data/ext/debian/puppet.default +7 -0
  33. data/ext/debian/puppet.dirs +1 -0
  34. data/ext/debian/puppet.init +118 -0
  35. data/ext/debian/puppet.install +4 -0
  36. data/ext/debian/puppet.lintian-overrides +3 -0
  37. data/ext/debian/puppet.logrotate +11 -0
  38. data/ext/debian/puppet.manpages +36 -0
  39. data/ext/debian/puppet.postinst +20 -0
  40. data/ext/debian/puppet.postrm +20 -0
  41. data/ext/debian/puppet.preinst +20 -0
  42. data/ext/debian/puppetmaster-common.install +5 -0
  43. data/ext/debian/puppetmaster-common.manpages +5 -0
  44. data/ext/debian/puppetmaster-common.puppetqd.default +27 -0
  45. data/ext/debian/puppetmaster-common.puppetqd.init +84 -0
  46. data/ext/debian/puppetmaster-passenger.dirs +4 -0
  47. data/ext/debian/puppetmaster-passenger.postinst +66 -0
  48. data/ext/debian/puppetmaster-passenger.postrm +33 -0
  49. data/ext/debian/puppetmaster.NEWS +13 -0
  50. data/ext/debian/puppetmaster.README.debian +16 -0
  51. data/ext/debian/puppetmaster.default +38 -0
  52. data/ext/debian/puppetmaster.dirs +1 -0
  53. data/ext/debian/puppetmaster.init +158 -0
  54. data/ext/debian/puppetmaster.install +1 -0
  55. data/ext/debian/puppetmaster.lintian-overrides +3 -0
  56. data/ext/debian/puppetmaster.manpages +1 -0
  57. data/ext/debian/puppetmaster.postinst +20 -0
  58. data/ext/debian/puppetmaster.postrm +5 -0
  59. data/ext/debian/puppetmaster.preinst +22 -0
  60. data/ext/debian/rules +127 -0
  61. data/ext/debian/source/format +1 -0
  62. data/ext/debian/source/options +1 -0
  63. data/ext/debian/vim-puppet.README.Debian +13 -0
  64. data/ext/debian/vim-puppet.dirs +3 -0
  65. data/ext/debian/vim-puppet.yaml +5 -0
  66. data/ext/debian/watch +2 -0
  67. data/ext/emacs/puppet-mode.el +1 -0
  68. data/{conf → ext}/osx/PackageInfo.plist +0 -0
  69. data/{conf → ext}/osx/createpackage.sh +0 -0
  70. data/ext/osx/file_mapping.yaml +38 -0
  71. data/ext/osx/preflight.erb +37 -0
  72. data/{tasks/rake/templates → ext/osx}/prototype.plist.erb +0 -0
  73. data/ext/packaging/README-Solaris.md +117 -0
  74. data/ext/packaging/README.md +255 -0
  75. data/ext/packaging/spec/spec_helper.rb +12 -0
  76. data/ext/packaging/spec/tasks/00_utils_spec.rb +66 -0
  77. data/ext/packaging/tasks/00_utils.rake +382 -0
  78. data/ext/packaging/tasks/10_setupvars.rake +71 -0
  79. data/ext/packaging/tasks/20_setupextravars.rake +25 -0
  80. data/ext/packaging/tasks/apple.rake +201 -0
  81. data/ext/packaging/tasks/clean.rake +5 -0
  82. data/ext/packaging/tasks/deb.rake +108 -0
  83. data/ext/packaging/tasks/doc.rake +20 -0
  84. data/ext/packaging/tasks/fetch.rake +18 -0
  85. data/ext/packaging/tasks/gem.rake +68 -0
  86. data/ext/packaging/tasks/ips.rake +80 -0
  87. data/ext/packaging/tasks/mock.rake +126 -0
  88. data/ext/packaging/tasks/pe_deb.rake +9 -0
  89. data/ext/packaging/tasks/pe_remote.rake +45 -0
  90. data/ext/packaging/tasks/pe_rpm.rake +21 -0
  91. data/ext/packaging/tasks/pe_ship.rake +30 -0
  92. data/ext/packaging/tasks/pe_sign.rake +27 -0
  93. data/ext/packaging/tasks/pe_sles.rake +96 -0
  94. data/ext/packaging/tasks/release.rake +73 -0
  95. data/ext/packaging/tasks/remote_build.rake +78 -0
  96. data/ext/packaging/tasks/rpm.rake +52 -0
  97. data/ext/packaging/tasks/ship.rake +78 -0
  98. data/ext/packaging/tasks/sign.rake +82 -0
  99. data/ext/packaging/tasks/tag.rake +8 -0
  100. data/ext/packaging/tasks/tar.rake +68 -0
  101. data/ext/packaging/tasks/template.rake +13 -0
  102. data/ext/packaging/tasks/update.rake +16 -0
  103. data/ext/packaging/tasks/version.rake +21 -0
  104. data/ext/project_data.yaml +24 -0
  105. data/{conf/redhat/puppet.spec → ext/redhat/puppet.spec.erb} +18 -10
  106. data/install.rb +8 -8
  107. data/lib/puppet.rb +2 -6
  108. data/lib/puppet/agent/locker.rb +2 -0
  109. data/lib/puppet/application.rb +1 -1
  110. data/lib/puppet/application/agent.rb +1 -1
  111. data/lib/puppet/application/apply.rb +1 -1
  112. data/lib/puppet/application/cert.rb +5 -6
  113. data/lib/puppet/application/describe.rb +1 -1
  114. data/lib/puppet/application/device.rb +1 -1
  115. data/lib/puppet/application/doc.rb +1 -1
  116. data/lib/puppet/application/filebucket.rb +1 -1
  117. data/lib/puppet/application/inspect.rb +1 -1
  118. data/lib/puppet/application/kick.rb +1 -1
  119. data/lib/puppet/application/master.rb +1 -1
  120. data/lib/puppet/application/resource.rb +1 -1
  121. data/lib/puppet/defaults.rb +21 -3
  122. data/lib/puppet/external/dot.rb +1 -1
  123. data/lib/puppet/face/help/global.erb +1 -1
  124. data/lib/puppet/face/module/install.rb +1 -1
  125. data/lib/puppet/face/module/list.rb +1 -1
  126. data/lib/puppet/face/module/uninstall.rb +1 -1
  127. data/lib/puppet/face/node/clean.rb +23 -18
  128. data/lib/puppet/face/parser.rb +11 -2
  129. data/lib/puppet/file_collection.rb +16 -27
  130. data/lib/puppet/file_collection/lookup.rb +6 -16
  131. data/lib/puppet/file_serving/base.rb +4 -4
  132. data/lib/puppet/indirector/catalog/static_compiler.rb +3 -4
  133. data/lib/puppet/indirector/certificate/disabled_ca.rb +22 -0
  134. data/lib/puppet/indirector/certificate_request/disabled_ca.rb +22 -0
  135. data/lib/puppet/indirector/certificate_revocation_list/disabled_ca.rb +22 -0
  136. data/lib/puppet/indirector/face.rb +2 -2
  137. data/lib/puppet/indirector/key/disabled_ca.rb +22 -0
  138. data/lib/puppet/indirector/node/exec.rb +13 -1
  139. data/lib/puppet/indirector/request.rb +4 -0
  140. data/lib/puppet/metatype/manager.rb +17 -10
  141. data/lib/puppet/network/authstore.rb +1 -1
  142. data/lib/puppet/network/rights.rb +1 -2
  143. data/lib/puppet/node/environment.rb +1 -0
  144. data/lib/puppet/parameter/value.rb +9 -3
  145. data/lib/puppet/parser/ast.rb +1 -4
  146. data/lib/puppet/parser/files.rb +1 -1
  147. data/lib/puppet/parser/functions.rb +68 -22
  148. data/lib/puppet/parser/functions/create_resources.rb +2 -3
  149. data/lib/puppet/parser/functions/shellquote.rb +21 -25
  150. data/lib/puppet/parser/lexer.rb +40 -6
  151. data/lib/puppet/parser/relationship.rb +3 -1
  152. data/lib/puppet/parser/resource.rb +2 -3
  153. data/lib/puppet/parser/resource/param.rb +3 -5
  154. data/lib/puppet/parser/scope.rb +7 -4
  155. data/lib/puppet/property.rb +5 -3
  156. data/lib/puppet/provider.rb +5 -5
  157. data/lib/puppet/provider/aixobject.rb +1 -1
  158. data/lib/puppet/provider/augeas/augeas.rb +1 -1
  159. data/lib/puppet/provider/exec/windows.rb +1 -1
  160. data/lib/puppet/provider/file/windows.rb +10 -29
  161. data/lib/puppet/provider/group/groupadd.rb +2 -3
  162. data/lib/puppet/provider/group/ldap.rb +1 -1
  163. data/lib/puppet/provider/group/windows_adsi.rb +1 -1
  164. data/lib/puppet/provider/ldap.rb +5 -1
  165. data/lib/puppet/provider/nameservice.rb +3 -3
  166. data/lib/puppet/provider/nameservice/directoryservice.rb +2 -2
  167. data/lib/puppet/provider/package/gem.rb +6 -2
  168. data/lib/puppet/provider/package/portage.rb +4 -2
  169. data/lib/puppet/provider/parsedfile.rb +1 -1
  170. data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +2 -2
  171. data/lib/puppet/provider/service/base.rb +2 -41
  172. data/lib/puppet/provider/service/daemontools.rb +1 -1
  173. data/lib/puppet/provider/service/launchd.rb +1 -1
  174. data/lib/puppet/provider/service/redhat.rb +6 -5
  175. data/lib/puppet/provider/service/runit.rb +1 -1
  176. data/lib/puppet/provider/service/service.rb +43 -0
  177. data/lib/puppet/provider/service/windows.rb +1 -8
  178. data/lib/puppet/provider/user/user_role_add.rb +2 -1
  179. data/lib/puppet/provider/user/useradd.rb +8 -3
  180. data/lib/puppet/provider/user/windows_adsi.rb +12 -1
  181. data/lib/puppet/provider/zone/solaris.rb +1 -1
  182. data/lib/puppet/rails/inventory_node.rb +26 -13
  183. data/lib/puppet/reports.rb +1 -1
  184. data/lib/puppet/resource.rb +20 -5
  185. data/lib/puppet/resource/status.rb +1 -1
  186. data/lib/puppet/ssl/certificate_authority.rb +2 -0
  187. data/lib/puppet/ssl/host.rb +31 -6
  188. data/lib/puppet/test/test_helper.rb +3 -1
  189. data/lib/puppet/transaction/event.rb +1 -1
  190. data/lib/puppet/transaction/report.rb +2 -2
  191. data/lib/puppet/type.rb +30 -25
  192. data/lib/puppet/type/augeas.rb +1 -1
  193. data/lib/puppet/type/cron.rb +2 -2
  194. data/lib/puppet/type/exec.rb +6 -6
  195. data/lib/puppet/type/file.rb +5 -15
  196. data/lib/puppet/type/file/content.rb +1 -1
  197. data/lib/puppet/type/file/ensure.rb +1 -1
  198. data/lib/puppet/type/file/mode.rb +1 -1
  199. data/lib/puppet/type/file/selcontext.rb +6 -2
  200. data/lib/puppet/type/file/source.rb +1 -1
  201. data/lib/puppet/type/mount.rb +1 -1
  202. data/lib/puppet/type/package.rb +1 -1
  203. data/lib/puppet/type/schedule.rb +1 -1
  204. data/lib/puppet/type/scheduled_task.rb +1 -1
  205. data/lib/puppet/type/tidy.rb +1 -1
  206. data/lib/puppet/type/whit.rb +16 -9
  207. data/lib/puppet/util.rb +27 -11
  208. data/lib/puppet/util/adsi.rb +25 -23
  209. data/lib/puppet/util/autoload.rb +1 -1
  210. data/lib/puppet/util/classgen.rb +1 -1
  211. data/lib/puppet/util/feature.rb +3 -1
  212. data/lib/puppet/util/fileparsing.rb +9 -9
  213. data/lib/puppet/util/filetype.rb +55 -40
  214. data/lib/puppet/util/instance_loader.rb +5 -5
  215. data/lib/puppet/util/instrumentation.rb +3 -5
  216. data/lib/puppet/util/log_paths.rb +1 -3
  217. data/lib/puppet/util/monkey_patches.rb +34 -8
  218. data/lib/puppet/util/platform.rb +7 -0
  219. data/lib/puppet/util/posix.rb +3 -3
  220. data/lib/puppet/util/provider_features.rb +2 -3
  221. data/lib/puppet/util/rdoc.rb +4 -3
  222. data/lib/puppet/util/reference.rb +1 -1
  223. data/lib/puppet/util/selinux.rb +31 -36
  224. data/lib/puppet/util/tagging.rb +28 -6
  225. data/lib/puppet/util/windows.rb +1 -0
  226. data/lib/puppet/util/windows/error.rb +1 -1
  227. data/lib/puppet/util/windows/process.rb +3 -3
  228. data/lib/puppet/util/windows/security.rb +9 -46
  229. data/lib/puppet/util/windows/sid.rb +96 -0
  230. data/lib/puppet/util/windows/user.rb +65 -2
  231. data/lib/puppet/util/zaml.rb +109 -59
  232. data/lib/puppet/version.rb +18 -0
  233. data/spec/fixtures/unit/util/filetype/aixtab_output +44 -0
  234. data/spec/fixtures/unit/util/filetype/suntab_output +9 -0
  235. data/spec/integration/defaults_spec.rb +26 -7
  236. data/spec/integration/parser/functions_spec.rb +0 -4
  237. data/spec/integration/util/file_locking_spec.rb +1 -1
  238. data/spec/integration/util/windows/security_spec.rb +3 -23
  239. data/spec/lib/puppet_spec/files.rb +3 -3
  240. data/spec/shared_contexts/platform.rb +8 -0
  241. data/spec/spec_helper.rb +6 -1
  242. data/spec/unit/application/queue_spec.rb +2 -1
  243. data/spec/unit/configurer_spec.rb +1 -1
  244. data/spec/unit/face/{instrumentation_data.rb → instrumentation_data_spec.rb} +0 -0
  245. data/spec/unit/face/{instrumentation_listener.rb → instrumentation_listener_spec.rb} +0 -0
  246. data/spec/unit/face/{instrumentation_probe.rb → instrumentation_probe_spec.rb} +0 -0
  247. data/spec/unit/indirector/catalog/static_compiler_spec.rb +194 -0
  248. data/spec/unit/indirector/certificate/disabled_ca_spec.rb +33 -0
  249. data/spec/unit/indirector/certificate_request/disabled_ca_spec.rb +33 -0
  250. data/spec/unit/indirector/certificate_revocation_list/disabled_ca_spec.rb +33 -0
  251. data/spec/unit/indirector/key/disabled_ca_spec.rb +33 -0
  252. data/spec/unit/indirector/request_spec.rb +22 -0
  253. data/spec/unit/network/http/webrick_spec.rb +0 -7
  254. data/spec/unit/node/environment_spec.rb +8 -8
  255. data/spec/unit/parser/ast_spec.rb +0 -5
  256. data/spec/unit/parser/collector_spec.rb +1 -0
  257. data/spec/unit/parser/files_spec.rb +2 -2
  258. data/spec/unit/parser/functions/create_resources_spec.rb +3 -4
  259. data/spec/unit/parser/functions/require_spec.rb +0 -6
  260. data/spec/unit/parser/functions/shellquote_spec.rb +0 -5
  261. data/spec/unit/parser/functions/template_spec.rb +6 -1
  262. data/spec/unit/parser/functions_spec.rb +73 -23
  263. data/spec/unit/parser/lexer_spec.rb +133 -8
  264. data/spec/unit/parser/relationship_spec.rb +24 -0
  265. data/spec/unit/parser/resource_spec.rb +0 -4
  266. data/spec/unit/parser/scope_spec.rb +2 -2
  267. data/spec/unit/property_spec.rb +21 -1
  268. data/spec/unit/provider/exec/posix_spec.rb +7 -6
  269. data/spec/unit/provider/file/windows_spec.rb +29 -29
  270. data/spec/unit/provider/group/groupadd_spec.rb +36 -30
  271. data/spec/unit/provider/group/windows_adsi_spec.rb +2 -2
  272. data/spec/unit/provider/package/gem_spec.rb +12 -0
  273. data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +14 -11
  274. data/spec/unit/provider/service/redhat_spec.rb +11 -1
  275. data/spec/unit/provider/service/windows_spec.rb +19 -0
  276. data/spec/unit/provider/user/ldap_spec.rb +22 -8
  277. data/spec/unit/provider/user/user_role_add_spec.rb +12 -0
  278. data/spec/unit/provider/user/useradd_spec.rb +146 -118
  279. data/spec/unit/provider/user/windows_adsi_spec.rb +24 -2
  280. data/spec/unit/puppet_spec.rb +10 -0
  281. data/spec/unit/resource/status_spec.rb +1 -1
  282. data/spec/unit/resource_spec.rb +73 -0
  283. data/spec/unit/ssl/certificate_authority_spec.rb +25 -1
  284. data/spec/unit/ssl/host_spec.rb +73 -27
  285. data/spec/unit/ssl/key_spec.rb +0 -4
  286. data/spec/unit/transaction/event_spec.rb +1 -1
  287. data/spec/unit/type/exec_spec.rb +1 -1
  288. data/spec/unit/type/file/content_spec.rb +6 -4
  289. data/spec/unit/type/file/{ctime.rb → ctime_spec.rb} +0 -0
  290. data/spec/unit/type/file/{mtime.rb → mtime_spec.rb} +0 -0
  291. data/spec/unit/type/file/{type.rb → type_spec.rb} +0 -0
  292. data/spec/unit/type/file_spec.rb +2 -12
  293. data/spec/unit/type/host_spec.rb +14 -5
  294. data/spec/unit/type/mount_spec.rb +8 -0
  295. data/spec/unit/type/scheduled_task_spec.rb +2 -2
  296. data/spec/unit/util/adsi_spec.rb +23 -8
  297. data/spec/unit/util/command_line_spec.rb +11 -2
  298. data/spec/unit/util/feature_spec.rb +12 -1
  299. data/spec/unit/util/filetype_spec.rb +161 -55
  300. data/spec/unit/util/log_spec.rb +1 -1
  301. data/spec/unit/util/monkey_patches_spec.rb +7 -0
  302. data/spec/unit/util/rdoc_spec.rb +8 -2
  303. data/spec/unit/util/selinux_spec.rb +24 -32
  304. data/spec/unit/util/windows/sid_spec.rb +100 -0
  305. data/spec/unit/util/zaml_spec.rb +165 -25
  306. data/spec/unit/util_spec.rb +3 -9
  307. data/spec/watchr.rb +2 -6
  308. data/tasks/rake/gem.rake +4 -2
  309. data/tasks/rake/sign.rake +1 -1
  310. data/test/language/parser.rb +1 -0
  311. data/test/language/scope.rb +0 -5
  312. data/test/language/snippets.rb +1 -2
  313. data/test/lib/puppettest.rb +16 -27
  314. data/test/lib/puppettest/parsertesting.rb +0 -1
  315. data/test/network/authstore.rb +2 -4
  316. data/test/puppet/defaults.rb +0 -4
  317. data/test/util/fileparsing.rb +2 -6
  318. metadata +1706 -1617
  319. data/conf/osx/preflight +0 -24
  320. data/spec/spec.opts +0 -4
  321. data/spec/unit/file_collection/lookup_spec.rb +0 -45
  322. data/spec/unit/file_collection_spec.rb +0 -52
  323. data/tasks/rake/apple.rake +0 -176
  324. data/test/puppet/errortest.rb +0 -19
@@ -20,7 +20,7 @@ Puppet::Type.newtype(:augeas) do
20
20
  feature :need_to_run?, "If the command should run"
21
21
  feature :execute_changes, "Actually make the changes"
22
22
 
23
- @doc = <<-EOT
23
+ @doc = <<-'EOT'
24
24
  Apply a change or an array of changes to the filesystem
25
25
  using the augeas tool.
26
26
 
@@ -3,7 +3,7 @@ require 'facter'
3
3
  require 'puppet/util/filetype'
4
4
 
5
5
  Puppet::Type.newtype(:cron) do
6
- @doc = <<-EOT
6
+ @doc = <<-'EOT'
7
7
  Installs and manages cron jobs. Every cron resource requires a command
8
8
  and user attribute, as well as at least one periodic attribute (hour,
9
9
  minute, month, monthday, weekday, or special). While the name of the cron
@@ -389,7 +389,7 @@ Puppet::Type.newtype(:cron) do
389
389
  attr_accessor :uid
390
390
 
391
391
  def value(name)
392
- name = symbolize(name)
392
+ name = name.intern
393
393
  ret = nil
394
394
  if obj = @parameters[name]
395
395
  ret = obj.should
@@ -218,8 +218,8 @@ module Puppet
218
218
  newparam(:timeout) do
219
219
  desc "The maximum time the command should take. If the command takes
220
220
  longer than the timeout, the command is considered to have failed
221
- and will be stopped. Use 0 to disable the timeout.
222
- The time is specified in seconds."
221
+ and will be stopped. The timeout is specified in seconds. The default
222
+ timeout is 300 seconds and you can set it to 0 to disable the timeout."
223
223
 
224
224
  munge do |value|
225
225
  value = value.shift if value.is_a?(Array)
@@ -274,7 +274,7 @@ module Puppet
274
274
 
275
275
 
276
276
  newcheck(:refreshonly) do
277
- desc <<-EOT
277
+ desc <<-'EOT'
278
278
  The command should only be run as a
279
279
  refresh mechanism for when a dependent object is changed. It only
280
280
  makes sense to use this option when this command depends on some
@@ -311,7 +311,7 @@ module Puppet
311
311
  end
312
312
 
313
313
  newcheck(:creates, :parent => Puppet::Parameter::Path) do
314
- desc <<-EOT
314
+ desc <<-'EOT'
315
315
  A file that this command creates. If this
316
316
  parameter is provided, then the command will only be run
317
317
  if the specified file does not exist.
@@ -336,7 +336,7 @@ module Puppet
336
336
  end
337
337
 
338
338
  newcheck(:unless) do
339
- desc <<-EOT
339
+ desc <<-'EOT'
340
340
  If this parameter is set, then this `exec` will run unless
341
341
  the command returns 0. For example:
342
342
 
@@ -378,7 +378,7 @@ module Puppet
378
378
  end
379
379
 
380
380
  newcheck(:onlyif) do
381
- desc <<-EOT
381
+ desc <<-'EOT'
382
382
  If this parameter is set, then this `exec` will only run if
383
383
  the command returns 0. For example:
384
384
 
@@ -35,11 +35,11 @@ Puppet::Type.newtype(:file) do
35
35
  parent directories of a file, the file resource will autorequire them."
36
36
 
37
37
  def self.title_patterns
38
- [ [ /^(.*?)\/*\Z/m, [ [ :path, lambda{|x| x} ] ] ] ]
38
+ [ [ /^(.*?)\/*\Z/m, [ [ :path ] ] ] ]
39
39
  end
40
40
 
41
41
  newparam(:path) do
42
- desc <<-EOT
42
+ desc <<-'EOT'
43
43
  The path to the file to manage. Must be fully qualified.
44
44
 
45
45
  On Windows, the path should include the drive letter and should use `/` as
@@ -53,20 +53,8 @@ Puppet::Type.newtype(:file) do
53
53
  end
54
54
  end
55
55
 
56
- # convert the current path in an index into the collection and the last
57
- # path name. The aim is to use less storage for all common paths in a hierarchy
58
56
  munge do |value|
59
- # We know the value is absolute, so expanding it will just standardize it.
60
- path, name = ::File.split(::File.expand_path(value))
61
-
62
- { :index => Puppet::FileCollection.collection.index(path), :name => name }
63
- end
64
-
65
- # and the reverse
66
- unmunge do |value|
67
- basedir = Puppet::FileCollection.collection.path(value[:index])
68
-
69
- ::File.join( basedir, value[:name] )
57
+ ::File.expand_path(value)
70
58
  end
71
59
  end
72
60
 
@@ -521,6 +509,7 @@ Puppet::Type.newtype(:file) do
521
509
  # remote system.
522
510
  mark_children_for_purging(children) if self.purge?
523
511
 
512
+ # REVISIT: sort_by is more efficient?
524
513
  result = children.values.sort { |a, b| a[:path] <=> b[:path] }
525
514
  remove_less_specific_files(result)
526
515
  end
@@ -530,6 +519,7 @@ Puppet::Type.newtype(:file) do
530
519
  # not likely to have many actual conflicts, which is good, because
531
520
  # this is a pretty inefficient implementation.
532
521
  def remove_less_specific_files(files)
522
+ # REVISIT: is this Windows safe? AltSeparator?
533
523
  mypath = self[:path].split(::File::Separator)
534
524
  other_paths = catalog.vertices.
535
525
  select { |r| r.is_a?(self.class) and r[:path] != self[:path] }.
@@ -15,7 +15,7 @@ module Puppet
15
15
 
16
16
  attr_reader :actual_content
17
17
 
18
- desc <<-EOT
18
+ desc <<-'EOT'
19
19
  The desired contents of a file, as a string. This attribute is mutually
20
20
  exclusive with `source` and `target`.
21
21
 
@@ -5,7 +5,7 @@ module Puppet
5
5
  require 'puppet/util/symbolic_file_mode'
6
6
  include Puppet::Util::SymbolicFileMode
7
7
 
8
- desc <<-EOT
8
+ desc <<-'EOT'
9
9
  Whether to create files that don't currently exist.
10
10
  Possible values are *absent*, *present*, *file*, and *directory*.
11
11
  Specifying `present` will match any form of file existence, and
@@ -6,7 +6,7 @@ module Puppet
6
6
  require 'puppet/util/symbolic_file_mode'
7
7
  include Puppet::Util::SymbolicFileMode
8
8
 
9
- desc <<-EOT
9
+ desc <<-'EOT'
10
10
  The desired permissions mode for the file, in symbolic or numeric
11
11
  notation. Puppet uses traditional Unix permission schemes and translates
12
12
  them to equivalent permissions for systems which represent permissions
@@ -48,9 +48,13 @@ module Puppet
48
48
  def insync?(value)
49
49
  if not selinux_support?
50
50
  debug("SELinux bindings not found. Ignoring parameter.")
51
- return true
51
+ true
52
+ elsif not selinux_label_support?(@resource[:path])
53
+ debug("SELinux not available for this filesystem. Ignoring parameter.")
54
+ true
55
+ else
56
+ super
52
57
  end
53
- super
54
58
  end
55
59
 
56
60
  def sync
@@ -12,7 +12,7 @@ module Puppet
12
12
  include Puppet::Util::Diff
13
13
 
14
14
  attr_accessor :source, :local
15
- desc <<-EOT
15
+ desc <<-'EOT'
16
16
  A source file, which will be copied into place on the local system.
17
17
  Values can be URIs pointing to remote files, or fully qualified paths to
18
18
  files available on the local system (including files on NFS shares or
@@ -231,7 +231,7 @@ module Puppet
231
231
  end
232
232
 
233
233
  def value(name)
234
- name = symbolize(name)
234
+ name = name.intern
235
235
  ret = nil
236
236
  if property = @parameters[name]
237
237
  return property.value
@@ -306,7 +306,7 @@ module Puppet
306
306
  end
307
307
 
308
308
  newparam(:install_options, :required_features => :install_options) do
309
- desc <<-EOT
309
+ desc <<-'EOT'
310
310
  A hash of additional options to pass when installing a package. These
311
311
  options are package-specific, and should be documented by the software
312
312
  vendor. The most commonly implemented option is `INSTALLDIR`:
@@ -1,6 +1,6 @@
1
1
  module Puppet
2
2
  newtype(:schedule) do
3
- @doc = <<-EOT
3
+ @doc = <<-'EOT'
4
4
  Define schedules for Puppet. Resources can be limited to a schedule by using the
5
5
  [`schedule`](http://docs.puppetlabs.com/references/latest/metaparameter.html#schedule)
6
6
  metaparameter.
@@ -80,7 +80,7 @@ Puppet::Type.newtype(:scheduled_task) do
80
80
  end
81
81
 
82
82
  newproperty(:trigger, :array_matching => :all) do
83
- desc <<-EOT
83
+ desc <<-'EOT'
84
84
  One or more triggers defining when the task should run. A single trigger is
85
85
  represented as a hash, and multiple triggers can be specified with an array of
86
86
  hashes.
@@ -43,7 +43,7 @@ Puppet::Type.newtype(:tidy) do
43
43
  end
44
44
 
45
45
  newparam(:matches) do
46
- desc <<-EOT
46
+ desc <<-'EOT'
47
47
  One or more (shell type) file glob patterns, which restrict
48
48
  the list of files to be tidied to those whose basenames match
49
49
  at least one of the patterns specified. Multiple patterns can
@@ -10,18 +10,25 @@ Puppet::Type.newtype(:whit) do
10
10
  end
11
11
 
12
12
 
13
- # Hide the fact that we're a whit from logs
13
+ # Hide the fact that we're a whit from logs.
14
+ #
15
+ # I hate you, milkman whit. You are so painful, so often.
16
+ #
17
+ # In this case the memoized version means we generate a new string about 1.9
18
+ # percent of the time, and we allocate about 1.6MB less memory, and generate
19
+ # a whole lot less GC churn.
20
+ #
21
+ # That number probably goes up at least O(n) with the complexity of your
22
+ # catalog, and I suspect beyond that, because that is, like, 10,000 calls
23
+ # for 200 distinct objects. Even with just linear, that is a constant
24
+ # factor of, like, 50n. --daniel 2012-07-17
14
25
  def to_s
15
- name.sub(/^completed_|^admissible_/, "")
16
- end
17
-
18
- def path
19
- to_s
26
+ @to_s ||= name.sub(/^completed_|^admissible_/, "")
20
27
  end
28
+ alias path to_s
21
29
 
22
30
  def refresh
23
- # We don't do anything with them, but we need this to
24
- # show that we are "refresh aware" and not break the
25
- # chain of propagation.
31
+ # We don't do anything with them, but we need this to show that we are
32
+ # "refresh aware" and not break the chain of propagation.
26
33
  end
27
34
  end
@@ -195,17 +195,23 @@ module Util
195
195
 
196
196
  # Determine in a platform-specific way whether a path is absolute. This
197
197
  # defaults to the local platform if none is specified.
198
+ #
199
+ # Escape once for the string literal, and once for the regex.
200
+ slash = '[\\\\/]'
201
+ label = '[^\\\\/]+'
202
+ AbsolutePathWindows = %r!^(?:(?:[A-Z]:#{slash})|(?:#{slash}#{slash}#{label}#{slash}#{label})|(?:#{slash}#{slash}\?#{slash}#{label}))!io
203
+ AbsolutePathPosix = %r!^/!
198
204
  def absolute_path?(path, platform=nil)
199
- # Escape once for the string literal, and once for the regex.
200
- slash = '[\\\\/]'
201
- name = '[^\\\\/]+'
202
- regexes = {
203
- :windows => %r!^(([A-Z]:#{slash})|(#{slash}#{slash}#{name}#{slash}#{name})|(#{slash}#{slash}\?#{slash}#{name}))!i,
204
- :posix => %r!^/!,
205
- }
206
-
207
- # Due to weird load order issues, I was unable to remove this require.
208
- # This is fixed in Telly so it can be removed there.
205
+ # When running an internal subcommand (Application), the app requires puppet
206
+ # which loads features, which creates an autoloader, which calls this method.
207
+ # In that case, it isn't necessary to require puppet. When running an external
208
+ # subcommand or if none was specified, then the CommandLine will call the
209
+ # `which` method to resolve the external executable, and that requires features.
210
+ # Rather then moving this require to handle the external subcommand case, or
211
+ # no subcommand case, I'm undoing the performance change from 20efe94. This
212
+ # code has been eliminated in 3.x since puppet can be required before loading
213
+ # the application (since the default vardir/confdir locations are solely
214
+ # based on user vs. system user, and not the application's run_mode).
209
215
  require 'puppet'
210
216
 
211
217
  # Ruby only sets File::ALT_SEPARATOR on Windows and the Ruby standard
@@ -214,8 +220,16 @@ module Util
214
220
  # be called during the initialization of features so it can't depend on
215
221
  # that.
216
222
  platform ||= Puppet::Util::Platform.windows? ? :windows : :posix
223
+ regex = case platform
224
+ when :windows
225
+ AbsolutePathWindows
226
+ when :posix
227
+ AbsolutePathPosix
228
+ else
229
+ raise Puppet::DevError, "unknown platform #{platform} in absolute_path"
230
+ end
217
231
 
218
- !! (path =~ regexes[platform])
232
+ !! (path =~ regex)
219
233
  end
220
234
  module_function :absolute_path?
221
235
 
@@ -457,6 +471,7 @@ module Util
457
471
  end
458
472
 
459
473
  def symbolize(value)
474
+ Puppet.deprecation_warning "symbolize is deprecated. Call the intern method on the object instead."
460
475
  if value.respond_to? :intern
461
476
  value.intern
462
477
  else
@@ -477,6 +492,7 @@ module Util
477
492
  end
478
493
 
479
494
  def symbolizehash!(hash)
495
+ Puppet.deprecation_warning "symbolizehash! is deprecated. Use the non-destructive symbolizehash method instead."
480
496
  # this is not the most memory-friendly way to accomplish this, but the
481
497
  # code re-use and clarity seems worthwhile.
482
498
  newhash = symbolizehash(hash)
@@ -45,20 +45,18 @@ module Puppet::Util::ADSI
45
45
  "#{computer_uri}/#{resource_name},#{resource_type}"
46
46
  end
47
47
 
48
+ def wmi_connection
49
+ connect(wmi_resource_uri)
50
+ end
51
+
48
52
  def execquery(query)
49
- connect(wmi_resource_uri).execquery(query)
53
+ wmi_connection.execquery(query)
50
54
  end
51
55
 
52
56
  def sid_for_account(name)
53
- sid = nil
54
- if name =~ /\\/
55
- domain, name = name.split('\\', 2)
56
- query = "SELECT Sid from Win32_Account WHERE Name = '#{name}' AND Domain = '#{domain}' AND LocalAccount = true"
57
- else
58
- query = "SELECT Sid from Win32_Account WHERE Name = '#{name}' AND LocalAccount = true"
59
- end
60
- execquery(query).each { |u| sid ||= u.Sid }
61
- sid
57
+ Puppet.deprecation_warning "Puppet::Util::ADSI.sid_for_account is deprecated and will be removed in 3.0, use Puppet::Util::Windows::SID.name_to_account instead."
58
+
59
+ Puppet::Util::Windows::Security.name_to_sid(name)
62
60
  end
63
61
  end
64
62
 
@@ -85,19 +83,7 @@ module Puppet::Util::ADSI
85
83
  end
86
84
 
87
85
  def self.logon(name, password)
88
- fLOGON32_LOGON_NETWORK = 3
89
- fLOGON32_PROVIDER_DEFAULT = 0
90
-
91
- logon_user = Win32API.new("advapi32", "LogonUser", ['P', 'P', 'P', 'L', 'L', 'P'], 'L')
92
- close_handle = Win32API.new("kernel32", "CloseHandle", ['P'], 'V')
93
-
94
- token = ' ' * 4
95
- if logon_user.call(name, "", password, fLOGON32_LOGON_NETWORK, fLOGON32_PROVIDER_DEFAULT, token) != 0
96
- close_handle.call(token.unpack('L')[0])
97
- true
98
- else
99
- false
100
- end
86
+ Puppet::Util::Windows::User.password_is?(name, password)
101
87
  end
102
88
 
103
89
  def [](attribute)
@@ -200,6 +186,22 @@ module Puppet::Util::ADSI
200
186
  end
201
187
  end
202
188
 
189
+ class UserProfile
190
+ def self.delete(sid)
191
+ begin
192
+ Puppet::Util::ADSI.wmi_connection.Delete("Win32_UserProfile.SID='#{sid}'")
193
+ rescue => e
194
+ # http://social.technet.microsoft.com/Forums/en/ITCG/thread/0f190051-ac96-4bf1-a47f-6b864bfacee5
195
+ # Prior to Vista SP1, there's no builtin way to programmatically
196
+ # delete user profiles (except for delprof.exe). So try to delete
197
+ # but warn if we fail
198
+ raise e unless e.message.include?('80041010')
199
+
200
+ Puppet.warning "Cannot delete user profile for '#{sid}' prior to Vista SP1"
201
+ end
202
+ end
203
+ end
204
+
203
205
  class Group
204
206
  extend Enumerable
205
207
 
@@ -75,7 +75,7 @@ class Puppet::Util::Autoload
75
75
  next unless file_exist?(file)
76
76
  begin
77
77
  Kernel.load file, @wrap
78
- name = symbolize(name)
78
+ name = name.intern
79
79
  loaded name, file
80
80
  return true
81
81
  rescue SystemExit,NoMemoryError
@@ -83,7 +83,7 @@ module Puppet::Util::ClassGen
83
83
  def genthing(name, type, options, block)
84
84
  options = symbolize_options(options)
85
85
 
86
- name = symbolize(name.to_s.downcase)
86
+ name = name.to_s.downcase.intern
87
87
 
88
88
  if type == Module
89
89
  #evalmethod = :module_eval
@@ -23,7 +23,9 @@ class Puppet::Util::Feature
23
23
  end
24
24
 
25
25
  meta_def(method) do
26
- @results[name] = test(name, options) unless @results.include?(name)
26
+ # Positive cache only, except blocks which are executed just once above
27
+ final = @results[name] || block_given?
28
+ @results[name] = test(name, options) unless final
27
29
  @results[name]
28
30
  end
29
31
  end
@@ -42,14 +42,14 @@ module Puppet::Util::FileParsing
42
42
  # Customize this so we can do a bit of validation.
43
43
  def fields=(fields)
44
44
  @fields = fields.collect do |field|
45
- r = symbolize(field)
45
+ r = field.intern
46
46
  raise ArgumentError.new("Cannot have fields named #{r}") if INVALID_FIELDS.include?(r)
47
47
  r
48
48
  end
49
49
  end
50
50
 
51
51
  def initialize(type, options = {}, &block)
52
- @type = symbolize(type)
52
+ @type = type.intern
53
53
  raise ArgumentError, "Invalid record type #{@type}" unless [:record, :text].include?(@type)
54
54
 
55
55
  set_options(options)
@@ -97,7 +97,7 @@ module Puppet::Util::FileParsing
97
97
  # Customize this so we can do a bit of validation.
98
98
  def optional=(optional)
99
99
  @optional = optional.collect do |field|
100
- symbolize(field)
100
+ field.intern
101
101
  end
102
102
  end
103
103
 
@@ -269,7 +269,7 @@ module Puppet::Util::FileParsing
269
269
  raise ArgumentError, "Must include a list of fields" unless options.include?(:fields)
270
270
 
271
271
  record = FileRecord.new(:record, options, &block)
272
- record.name = symbolize(name)
272
+ record.name = name.intern
273
273
 
274
274
  new_line_type(record)
275
275
  end
@@ -284,7 +284,7 @@ module Puppet::Util::FileParsing
284
284
  raise ArgumentError, "You must provide a :match regex for text lines" unless options.include?(:match)
285
285
 
286
286
  record = FileRecord.new(:text, options, &block)
287
- record.name = symbolize(name)
287
+ record.name = name.intern
288
288
 
289
289
  new_line_type(record)
290
290
  end
@@ -338,11 +338,11 @@ module Puppet::Util::FileParsing
338
338
  end
339
339
 
340
340
  def valid_attr?(type, attr)
341
- type = symbolize(type)
342
- if record = record_type(type) and record.fields.include?(symbolize(attr))
341
+ type = type.intern
342
+ if record = record_type(type) and record.fields.include?(attr.intern)
343
343
  return true
344
344
  else
345
- if symbolize(attr) == :ensure
345
+ if attr.intern == :ensure
346
346
  return true
347
347
  else
348
348
  false
@@ -367,7 +367,7 @@ module Puppet::Util::FileParsing
367
367
 
368
368
  # Retrieve the record object.
369
369
  def record_type(type)
370
- @record_types[symbolize(type)]
370
+ @record_types[type.intern]
371
371
  end
372
372
  end
373
373