puppet 2.7.3 → 2.7.4

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 (337) hide show
  1. data/CHANGELOG +166 -0
  2. data/install.rb +27 -7
  3. data/lib/puppet/application/agent.rb +29 -29
  4. data/lib/puppet/application/doc.rb +1 -1
  5. data/lib/puppet/application/inspect.rb +9 -1
  6. data/lib/puppet/application/master.rb +2 -0
  7. data/lib/puppet/application/queue.rb +1 -1
  8. data/lib/puppet/application/resource.rb +3 -0
  9. data/lib/puppet/application.rb +4 -5
  10. data/lib/puppet/configurer.rb +1 -4
  11. data/lib/puppet/defaults.rb +45 -15
  12. data/lib/puppet/feature/base.rb +28 -17
  13. data/lib/puppet/feature/rails.rb +0 -3
  14. data/lib/puppet/feature/rubygems.rb +0 -3
  15. data/lib/puppet/file_bucket/dipper.rb +3 -2
  16. data/lib/puppet/file_bucket/file.rb +3 -3
  17. data/lib/puppet/file_serving/base.rb +4 -5
  18. data/lib/puppet/file_serving/configuration.rb +7 -13
  19. data/lib/puppet/file_serving/content.rb +0 -4
  20. data/lib/puppet/file_serving/fileset.rb +7 -6
  21. data/lib/puppet/file_serving/indirection_hooks.rb +1 -4
  22. data/lib/puppet/file_serving/metadata.rb +0 -4
  23. data/lib/puppet/file_serving/mount/file.rb +9 -12
  24. data/lib/puppet/file_serving/mount.rb +0 -5
  25. data/lib/puppet/file_serving/terminus_helper.rb +0 -4
  26. data/lib/puppet/file_serving.rb +0 -4
  27. data/lib/puppet/indirector/catalog/compiler.rb +0 -18
  28. data/lib/puppet/indirector/catalog/store_configs.rb +5 -0
  29. data/lib/puppet/indirector/direct_file_server.rb +0 -4
  30. data/lib/puppet/indirector/facts/facter.rb +2 -2
  31. data/lib/puppet/indirector/facts/store_configs.rb +5 -0
  32. data/lib/puppet/indirector/file_content/file.rb +0 -4
  33. data/lib/puppet/indirector/file_content/file_server.rb +0 -4
  34. data/lib/puppet/indirector/file_content/rest.rb +0 -4
  35. data/lib/puppet/indirector/file_metadata/file.rb +0 -4
  36. data/lib/puppet/indirector/file_metadata/file_server.rb +0 -4
  37. data/lib/puppet/indirector/file_metadata/rest.rb +0 -4
  38. data/lib/puppet/indirector/file_server.rb +1 -5
  39. data/lib/puppet/indirector/indirection.rb +3 -5
  40. data/lib/puppet/indirector/node/store_configs.rb +5 -0
  41. data/lib/puppet/indirector/request.rb +3 -1
  42. data/lib/puppet/indirector/resource/active_record.rb +97 -0
  43. data/lib/puppet/indirector/resource/store_configs.rb +3 -0
  44. data/lib/puppet/indirector/ssl_file.rb +5 -1
  45. data/lib/puppet/indirector/store_configs.rb +30 -0
  46. data/lib/puppet/indirector/yaml.rb +5 -0
  47. data/lib/puppet/indirector.rb +7 -0
  48. data/lib/puppet/network/client.rb +0 -5
  49. data/lib/puppet/network/http_pool.rb +0 -56
  50. data/lib/puppet/node/environment.rb +9 -11
  51. data/lib/puppet/parameter/path.rb +1 -5
  52. data/lib/puppet/parameter.rb +1 -7
  53. data/lib/puppet/parser/ast/collection.rb +2 -2
  54. data/lib/puppet/parser/ast/collexpr.rb +10 -39
  55. data/lib/puppet/parser/collector.rb +41 -90
  56. data/lib/puppet/parser/compiler.rb +0 -3
  57. data/lib/puppet/parser/functions/create_resources.rb +22 -10
  58. data/lib/puppet/parser/functions/versioncmp.rb +9 -6
  59. data/lib/puppet/parser/resource.rb +1 -1
  60. data/lib/puppet/parser/type_loader.rb +2 -1
  61. data/lib/puppet/provider/augeas/augeas.rb +5 -3
  62. data/lib/puppet/provider/cron/crontab.rb +2 -2
  63. data/lib/puppet/provider/exec/posix.rb +23 -96
  64. data/lib/puppet/provider/exec/shell.rb +11 -2
  65. data/lib/puppet/provider/exec/windows.rb +35 -0
  66. data/lib/puppet/provider/exec.rb +79 -0
  67. data/lib/puppet/provider/group/windows_adsi.rb +48 -0
  68. data/lib/puppet/provider/host/parsed.rb +3 -0
  69. data/lib/puppet/provider/macauthorization/macauthorization.rb +4 -4
  70. data/lib/puppet/provider/mount.rb +0 -3
  71. data/lib/puppet/provider/naginator.rb +0 -3
  72. data/lib/puppet/provider/package/appdmg.rb +0 -1
  73. data/lib/puppet/provider/package/apple.rb +3 -7
  74. data/lib/puppet/provider/package/apt.rb +0 -1
  75. data/lib/puppet/provider/package/aptitude.rb +0 -1
  76. data/lib/puppet/provider/package/aptrpm.rb +0 -1
  77. data/lib/puppet/provider/package/blastwave.rb +0 -1
  78. data/lib/puppet/provider/package/dpkg.rb +5 -6
  79. data/lib/puppet/provider/package/fink.rb +3 -4
  80. data/lib/puppet/provider/package/freebsd.rb +0 -1
  81. data/lib/puppet/provider/package/gem.rb +0 -1
  82. data/lib/puppet/provider/package/hpux.rb +3 -3
  83. data/lib/puppet/provider/package/macports.rb +0 -1
  84. data/lib/puppet/provider/package/msi.rb +82 -0
  85. data/lib/puppet/provider/package/openbsd.rb +18 -19
  86. data/lib/puppet/provider/package/pip.rb +0 -1
  87. data/lib/puppet/provider/package/pkg.rb +0 -1
  88. data/lib/puppet/provider/package/pkgdmg.rb +9 -7
  89. data/lib/puppet/provider/package/pkgutil.rb +0 -1
  90. data/lib/puppet/provider/package/ports.rb +0 -1
  91. data/lib/puppet/provider/package/portupgrade.rb +183 -193
  92. data/lib/puppet/provider/package/rpm.rb +1 -1
  93. data/lib/puppet/provider/package/sun.rb +0 -1
  94. data/lib/puppet/provider/package/sunfreeware.rb +0 -2
  95. data/lib/puppet/provider/package/up2date.rb +0 -1
  96. data/lib/puppet/provider/package/urpmi.rb +0 -1
  97. data/lib/puppet/provider/package/yum.rb +1 -1
  98. data/lib/puppet/provider/package.rb +4 -3
  99. data/lib/puppet/provider/service/systemd.rb +64 -0
  100. data/lib/puppet/provider/service/windows.rb +110 -0
  101. data/lib/puppet/provider/user/windows_adsi.rb +71 -0
  102. data/lib/puppet/rails/resource.rb +1 -1
  103. data/lib/puppet/relationship.rb +0 -3
  104. data/lib/puppet/reports/tagmail.rb +15 -11
  105. data/lib/puppet/resource/catalog.rb +17 -24
  106. data/lib/puppet/ssl/certificate_authority.rb +7 -5
  107. data/lib/puppet/ssl/host.rb +6 -10
  108. data/lib/puppet/type/augeas.rb +19 -13
  109. data/lib/puppet/type/cron.rb +13 -12
  110. data/lib/puppet/type/exec.rb +17 -17
  111. data/lib/puppet/type/file/content.rb +7 -3
  112. data/lib/puppet/type/file/source.rb +14 -9
  113. data/lib/puppet/type/file.rb +44 -23
  114. data/lib/puppet/type/filebucket.rb +13 -5
  115. data/lib/puppet/type/package.rb +14 -1
  116. data/lib/puppet/type/service.rb +11 -1
  117. data/lib/puppet/type/ssh_authorized_key.rb +3 -1
  118. data/lib/puppet/type.rb +8 -17
  119. data/lib/puppet/util/adsi.rb +278 -0
  120. data/lib/puppet/util/autoload.rb +0 -2
  121. data/lib/puppet/util/cacher.rb +15 -67
  122. data/lib/puppet/util/feature.rb +0 -3
  123. data/lib/puppet/util/graph.rb +0 -3
  124. data/lib/puppet/util/ldap/connection.rb +0 -3
  125. data/lib/puppet/util/ldap/generator.rb +0 -3
  126. data/lib/puppet/util/ldap.rb +0 -3
  127. data/lib/puppet/util/log_paths.rb +0 -3
  128. data/lib/puppet/util/network_device/cisco/device.rb +2 -1
  129. data/lib/puppet/util/network_device/cisco/facts.rb +1 -1
  130. data/lib/puppet/util/pidlock.rb +5 -1
  131. data/lib/puppet/util/rdoc/parser.rb +3 -1
  132. data/lib/puppet/util/run_mode.rb +2 -2
  133. data/lib/puppet/util/settings/file_setting.rb +3 -2
  134. data/lib/puppet/util/settings.rb +4 -6
  135. data/lib/puppet/util/suidmanager.rb +62 -15
  136. data/lib/puppet/util.rb +113 -131
  137. data/lib/puppet.rb +1 -1
  138. data/spec/integration/application/doc_spec.rb +1 -1
  139. data/spec/integration/defaults_spec.rb +22 -17
  140. data/spec/integration/file_serving/content_spec.rb +0 -6
  141. data/spec/integration/file_serving/metadata_spec.rb +0 -6
  142. data/spec/integration/file_serving/terminus_helper_spec.rb +1 -1
  143. data/spec/integration/indirector/direct_file_server_spec.rb +5 -7
  144. data/spec/integration/indirector/file_content/file_server_spec.rb +2 -6
  145. data/spec/integration/indirector/file_metadata/file_server_spec.rb +1 -5
  146. data/spec/integration/network/server/webrick_spec.rb +6 -9
  147. data/spec/integration/node/facts_spec.rb +0 -6
  148. data/spec/integration/node_spec.rb +3 -4
  149. data/spec/integration/parser/compiler_spec.rb +2 -1
  150. data/spec/integration/parser/parser_spec.rb +2 -4
  151. data/spec/integration/provider/mount_spec.rb +1 -1
  152. data/spec/integration/provider/package_spec.rb +13 -3
  153. data/spec/integration/provider/ssh_authorized_key_spec.rb +4 -4
  154. data/spec/integration/reports_spec.rb +0 -4
  155. data/spec/integration/resource/catalog_spec.rb +0 -5
  156. data/spec/integration/ssl/certificate_authority_spec.rb +6 -14
  157. data/spec/integration/ssl/certificate_request_spec.rb +10 -17
  158. data/spec/integration/ssl/certificate_revocation_list_spec.rb +8 -13
  159. data/spec/integration/ssl/host_spec.rb +8 -14
  160. data/spec/integration/transaction/report_spec.rb +0 -5
  161. data/spec/integration/transaction_spec.rb +11 -13
  162. data/spec/integration/type/file_spec.rb +16 -16
  163. data/spec/integration/type/tidy_spec.rb +1 -1
  164. data/spec/integration/util/settings_spec.rb +2 -2
  165. data/spec/integration/util_spec.rb +13 -0
  166. data/spec/lib/puppet_spec/files.rb +18 -10
  167. data/spec/shared_behaviours/file_server_terminus.rb +1 -5
  168. data/spec/shared_behaviours/file_serving.rb +0 -4
  169. data/spec/shared_behaviours/memory_terminus.rb +0 -4
  170. data/spec/shared_behaviours/path_parameters.rb +20 -18
  171. data/spec/shared_behaviours/store_configs_terminus.rb +21 -0
  172. data/spec/spec_helper.rb +31 -0
  173. data/spec/unit/agent_spec.rb +0 -4
  174. data/spec/unit/application/apply_spec.rb +8 -2
  175. data/spec/unit/application/certificate_spec.rb +2 -0
  176. data/spec/unit/application/device_spec.rb +8 -6
  177. data/spec/unit/application/inspect_spec.rb +2 -1
  178. data/spec/unit/application/master_spec.rb +7 -2
  179. data/spec/unit/application/queue_spec.rb +3 -4
  180. data/spec/unit/application/resource_spec.rb +26 -0
  181. data/spec/unit/application/secret_agent_spec.rb +3 -1
  182. data/spec/unit/application_spec.rb +4 -0
  183. data/spec/unit/configurer/downloader_spec.rb +4 -3
  184. data/spec/unit/configurer_spec.rb +11 -4
  185. data/spec/unit/daemon_spec.rb +3 -1
  186. data/spec/unit/face/ca_spec.rb +1 -1
  187. data/spec/unit/face/node_spec.rb +5 -1
  188. data/spec/unit/face/secret_agent_spec.rb +3 -1
  189. data/spec/unit/file_bucket/dipper_spec.rb +4 -4
  190. data/spec/unit/file_bucket/file_spec.rb +9 -3
  191. data/spec/unit/file_serving/configuration_spec.rb +26 -37
  192. data/spec/unit/file_serving/fileset_spec.rb +71 -55
  193. data/spec/unit/file_serving/indirection_hooks_spec.rb +0 -4
  194. data/spec/unit/file_serving/mount/file_spec.rb +163 -169
  195. data/spec/unit/file_serving/terminus_helper_spec.rb +0 -4
  196. data/spec/unit/indirector/catalog/compiler_spec.rb +0 -22
  197. data/spec/unit/indirector/catalog/store_configs_spec.rb +17 -0
  198. data/spec/unit/indirector/certificate/ca_spec.rb +0 -4
  199. data/spec/unit/indirector/certificate/file_spec.rb +0 -4
  200. data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -5
  201. data/spec/unit/indirector/certificate_request/file_spec.rb +0 -4
  202. data/spec/unit/indirector/certificate_revocation_list/ca_spec.rb +0 -4
  203. data/spec/unit/indirector/certificate_revocation_list/file_spec.rb +0 -4
  204. data/spec/unit/indirector/certificate_status/file_spec.rb +1 -1
  205. data/spec/unit/indirector/direct_file_server_spec.rb +0 -4
  206. data/spec/unit/indirector/facts/facter_spec.rb +0 -4
  207. data/spec/unit/indirector/facts/inventory_active_record_spec.rb +3 -0
  208. data/spec/unit/indirector/facts/store_configs_spec.rb +17 -0
  209. data/spec/unit/indirector/file_bucket_file/file_spec.rb +3 -3
  210. data/spec/unit/indirector/file_content/file_server_spec.rb +0 -4
  211. data/spec/unit/indirector/file_content/file_spec.rb +0 -4
  212. data/spec/unit/indirector/file_metadata/file_server_spec.rb +0 -4
  213. data/spec/unit/indirector/file_metadata/file_spec.rb +0 -4
  214. data/spec/unit/indirector/file_server_spec.rb +1 -5
  215. data/spec/unit/indirector/indirection_spec.rb +0 -4
  216. data/spec/unit/indirector/key/ca_spec.rb +0 -4
  217. data/spec/unit/indirector/key/file_spec.rb +0 -4
  218. data/spec/unit/indirector/node/store_configs_spec.rb +16 -0
  219. data/spec/unit/indirector/report/processor_spec.rb +0 -4
  220. data/spec/unit/indirector/resource/active_record_spec.rb +192 -0
  221. data/spec/unit/indirector/resource/ral_spec.rb +1 -1
  222. data/spec/unit/indirector/resource/store_configs_spec.rb +12 -0
  223. data/spec/unit/indirector/resource_type/parser_spec.rb +3 -3
  224. data/spec/unit/indirector/ssl_file_spec.rb +25 -6
  225. data/spec/unit/indirector/store_configs_spec.rb +8 -0
  226. data/spec/unit/indirector/yaml_spec.rb +14 -0
  227. data/spec/unit/module_spec.rb +2 -2
  228. data/spec/unit/network/handler/fileserver_spec.rb +5 -5
  229. data/spec/unit/network/http/mongrel_spec.rb +0 -4
  230. data/spec/unit/network/http/webrick_spec.rb +5 -9
  231. data/spec/unit/network/http_pool_spec.rb +4 -75
  232. data/spec/unit/network/http_spec.rb +0 -4
  233. data/spec/unit/network/server_spec.rb +0 -4
  234. data/spec/unit/node/environment_spec.rb +18 -31
  235. data/spec/unit/node/facts_spec.rb +0 -4
  236. data/spec/unit/node_spec.rb +1 -8
  237. data/spec/unit/other/selinux_spec.rb +3 -1
  238. data/spec/unit/parameter_spec.rb +0 -10
  239. data/spec/unit/parser/ast/collexpr_spec.rb +17 -13
  240. data/spec/unit/parser/collector_spec.rb +147 -263
  241. data/spec/unit/parser/compiler_spec.rb +3 -1
  242. data/spec/unit/parser/files_spec.rb +7 -4
  243. data/spec/unit/parser/functions/extlookup_spec.rb +6 -3
  244. data/spec/unit/parser/functions/sprintf_spec.rb +2 -1
  245. data/spec/unit/parser/type_loader_spec.rb +7 -7
  246. data/spec/unit/property_spec.rb +1 -1
  247. data/spec/unit/provider/augeas/augeas_spec.rb +14 -0
  248. data/spec/unit/provider/exec/posix_spec.rb +102 -106
  249. data/spec/unit/provider/exec/shell_spec.rb +1 -1
  250. data/spec/unit/provider/exec/windows_spec.rb +119 -0
  251. data/spec/unit/provider/group/ldap_spec.rb +0 -4
  252. data/spec/unit/provider/group/windows_adsi_spec.rb +79 -0
  253. data/spec/unit/provider/ldap_spec.rb +0 -4
  254. data/spec/unit/provider/macauthorization_spec.rb +5 -0
  255. data/spec/unit/provider/mount/parsed_spec.rb +1 -5
  256. data/spec/unit/provider/package/msi_spec.rb +170 -0
  257. data/spec/unit/provider/service/redhat_spec.rb +2 -0
  258. data/spec/unit/provider/service/smf_spec.rb +3 -0
  259. data/spec/unit/provider/service/systemd_spec.rb +25 -0
  260. data/spec/unit/provider/service/windows_spec.rb +166 -0
  261. data/spec/unit/provider/ssh_authorized_key/parsed_spec.rb +2 -2
  262. data/spec/unit/provider/user/ldap_spec.rb +0 -4
  263. data/spec/unit/provider/user/user_role_add_spec.rb +1 -1
  264. data/spec/unit/provider/user/useradd_spec.rb +1 -1
  265. data/spec/unit/provider/user/windows_adsi_spec.rb +110 -0
  266. data/spec/unit/relationship_spec.rb +0 -4
  267. data/spec/unit/resource/catalog_spec.rb +37 -25
  268. data/spec/unit/resource/status_spec.rb +4 -2
  269. data/spec/unit/resource_spec.rb +5 -5
  270. data/spec/unit/simple_graph_spec.rb +0 -4
  271. data/spec/unit/ssl/certificate_authority_spec.rb +2 -2
  272. data/spec/unit/ssl/host_spec.rb +12 -13
  273. data/spec/unit/ssl/inventory_spec.rb +2 -2
  274. data/spec/unit/sslcertificates/ca_spec.rb +6 -10
  275. data/spec/unit/transaction/event_manager_spec.rb +4 -2
  276. data/spec/unit/transaction/event_spec.rb +3 -1
  277. data/spec/unit/transaction/report_spec.rb +2 -6
  278. data/spec/unit/transaction/resource_harness_spec.rb +9 -5
  279. data/spec/unit/transaction_spec.rb +3 -1
  280. data/spec/unit/type/cron_spec.rb +1 -1
  281. data/spec/unit/type/exec_spec.rb +80 -47
  282. data/spec/unit/type/file/checksum_spec.rb +9 -8
  283. data/spec/unit/type/file/content_spec.rb +2 -1
  284. data/spec/unit/type/file/selinux_spec.rb +10 -8
  285. data/spec/unit/type/file/source_spec.rb +18 -36
  286. data/spec/unit/type/file_spec.rb +170 -217
  287. data/spec/unit/type/group_spec.rb +1 -1
  288. data/spec/unit/type/mount_spec.rb +5 -5
  289. data/spec/unit/type/noop_metaparam_spec.rb +3 -1
  290. data/spec/unit/type/package_spec.rb +15 -3
  291. data/spec/unit/type/resources_spec.rb +2 -2
  292. data/spec/unit/type/service_spec.rb +19 -4
  293. data/spec/unit/type/ssh_authorized_key_spec.rb +10 -4
  294. data/spec/unit/type/tidy_spec.rb +3 -1
  295. data/spec/unit/type/user_spec.rb +1 -1
  296. data/spec/unit/type_spec.rb +29 -34
  297. data/spec/unit/util/adsi_spec.rb +202 -0
  298. data/spec/unit/util/autoload_spec.rb +23 -19
  299. data/spec/unit/util/backups_spec.rb +16 -13
  300. data/spec/unit/util/cacher_spec.rb +64 -141
  301. data/spec/unit/util/checksums_spec.rb +0 -4
  302. data/spec/unit/util/constant_inflector_spec.rb +0 -4
  303. data/spec/unit/util/execution_stub_spec.rb +1 -1
  304. data/spec/unit/util/ldap/connection_spec.rb +0 -4
  305. data/spec/unit/util/ldap/generator_spec.rb +0 -4
  306. data/spec/unit/util/ldap/manager_spec.rb +0 -4
  307. data/spec/unit/util/log_spec.rb +4 -2
  308. data/spec/unit/util/logging_spec.rb +2 -2
  309. data/spec/unit/util/nagios_maker_spec.rb +0 -4
  310. data/spec/unit/util/network_device/cisco/device_spec.rb +2 -1
  311. data/spec/unit/util/network_device/cisco/facts_spec.rb +3 -1
  312. data/spec/unit/util/network_device/config_spec.rb +5 -3
  313. data/spec/unit/util/rdoc/parser_spec.rb +7 -1
  314. data/spec/unit/util/run_mode_spec.rb +6 -2
  315. data/spec/unit/util/settings/file_setting_spec.rb +29 -2
  316. data/spec/unit/util/settings_spec.rb +28 -15
  317. data/spec/unit/util/storage_spec.rb +1 -1
  318. data/spec/unit/util/suidmanager_spec.rb +310 -0
  319. data/spec/unit/util/tagging_spec.rb +0 -4
  320. data/spec/unit/util_spec.rb +335 -0
  321. data/test/language/ast/variable.rb +0 -4
  322. data/test/lib/puppettest/support/resources.rb +0 -4
  323. data/test/lib/puppettest/testcase.rb +0 -4
  324. data/test/lib/puppettest.rb +0 -1
  325. data/test/network/handler/master.rb +0 -5
  326. data/test/network/server/webrick.rb +5 -22
  327. data/test/ral/manager/attributes.rb +0 -4
  328. data/test/ral/manager/instances.rb +0 -4
  329. data/test/ral/manager/manager.rb +0 -4
  330. data/test/ral/providers/cron/crontab.rb +1 -0
  331. data/test/ral/providers/service/base.rb +0 -4
  332. data/test/ral/type/filesources.rb +0 -1
  333. data/test/ral/type/resources.rb +0 -4
  334. data/test/util/utiltest.rb +0 -13
  335. metadata +36 -9
  336. data/spec/unit/network/client_spec.rb +0 -45
  337. data/test/puppet/tc_suidmanager.rb +0 -120
@@ -1,25 +1,6 @@
1
1
  require 'monitor'
2
2
 
3
3
  module Puppet::Util::Cacher
4
- module Expirer
5
- attr_reader :timestamp
6
-
7
- # Cause all cached values to be considered expired.
8
- def expire
9
- @timestamp = Time.now
10
- end
11
-
12
- # Is the provided timestamp earlier than our expiration timestamp?
13
- # If it is, then the associated value is expired.
14
- def dependent_data_expired?(ts)
15
- return false unless timestamp
16
-
17
- timestamp > ts
18
- end
19
- end
20
-
21
- extend Expirer
22
-
23
4
  # Our module has been extended in a class; we can only add the Instance methods,
24
5
  # which become *class* methods in the class.
25
6
  def self.extended(other)
@@ -40,27 +21,26 @@ module Puppet::Util::Cacher
40
21
  module ClassMethods
41
22
  # Provide a means of defining an attribute whose value will be cached.
42
23
  # Must provide a block capable of defining the value if it's flushed..
43
- def cached_attr(name, options = {}, &block)
24
+ def cached_attr(name, ttl, &block)
44
25
  init_method = "init_#{name}"
45
26
  define_method(init_method, &block)
46
27
 
28
+ set_attr_ttl(name, ttl)
29
+
47
30
  define_method(name) do
48
31
  cached_value(name)
49
32
  end
50
33
 
51
34
  define_method(name.to_s + "=") do |value|
52
35
  # Make sure the cache timestamp is set
53
- cache_timestamp
54
- value_cache.synchronize { value_cache[name] = value }
55
- end
56
-
57
- if ttl = options[:ttl]
58
- set_attr_ttl(name, ttl)
36
+ value_cache.synchronize do
37
+ value_cache[name] = value
38
+ set_expiration(name)
39
+ end
59
40
  end
60
41
  end
61
42
 
62
43
  def attr_ttl(name)
63
- return nil unless @attr_ttls
64
44
  @attr_ttls[name]
65
45
  end
66
46
 
@@ -72,57 +52,25 @@ module Puppet::Util::Cacher
72
52
 
73
53
  # Methods that get added to instances.
74
54
  module InstanceMethods
75
-
76
- def expire
77
- # Only expire if we have an expirer. This is
78
- # mostly so that we can comfortably handle cases
79
- # like Puppet::Type instances, which use their
80
- # catalog as their expirer, and they often don't
81
- # have a catalog.
82
- if e = expirer
83
- e.expire
84
- end
85
- end
86
-
87
- def expirer
88
- Puppet::Util::Cacher
89
- end
90
-
91
55
  private
92
56
 
93
- def cache_timestamp
94
- @cache_timestamp ||= Time.now
95
- end
96
-
97
57
  def cached_value(name)
98
58
  value_cache.synchronize do
99
- # Allow a nil expirer, in which case we regenerate the value every time.
100
- if expired_by_expirer?(name)
101
- value_cache.clear
102
- @cache_timestamp = Time.now
103
- elsif expired_by_ttl?(name)
104
- value_cache.delete(name)
59
+ if value_cache[name].nil? or expired_by_ttl?(name)
60
+ value_cache[name] = send("init_#{name}")
61
+ set_expiration(name)
105
62
  end
106
- value_cache[name] = send("init_#{name}") unless value_cache.include?(name)
107
63
  value_cache[name]
108
64
  end
109
65
  end
110
66
 
111
- def expired_by_expirer?(name)
112
- if expirer.nil?
113
- return true unless self.class.attr_ttl(name)
114
- end
115
- expirer.dependent_data_expired?(cache_timestamp)
116
- end
117
-
118
67
  def expired_by_ttl?(name)
119
- return false unless self.class.respond_to?(:attr_ttl)
120
- return false unless ttl = self.class.attr_ttl(name)
121
-
122
- @ttl_timestamps ||= {}
123
- @ttl_timestamps[name] ||= Time.now
68
+ @attr_expirations[name] < Time.now
69
+ end
124
70
 
125
- (Time.now - @ttl_timestamps[name]) > ttl
71
+ def set_expiration(name)
72
+ @attr_expirations ||= {}
73
+ @attr_expirations[name] = Time.now + self.class.attr_ttl(name)
126
74
  end
127
75
 
128
76
  def value_cache
@@ -1,6 +1,3 @@
1
- # Created by Luke Kanies on 2006-11-07.
2
- # Copyright (c) 2006. All rights reserved.
3
-
4
1
  class Puppet::Util::Feature
5
2
  attr_reader :path
6
3
 
@@ -1,6 +1,3 @@
1
- # Created by Luke Kanies on 2006-11-16.
2
- # Copyright (c) 2006. All rights reserved.
3
-
4
1
  require 'puppet'
5
2
  require 'puppet/simple_graph'
6
3
 
@@ -1,6 +1,3 @@
1
- #
2
- # Created by Luke Kanies on 2008-3-23.
3
- # Copyright (c) 2008. All rights reserved.
4
1
  require 'puppet/util/ldap'
5
2
 
6
3
  class Puppet::Util::Ldap::Connection
@@ -1,6 +1,3 @@
1
- #
2
- # Created by Luke Kanies on 2008-3-28.
3
- # Copyright (c) 2008. All rights reserved.
4
1
  require 'puppet/util/ldap'
5
2
 
6
3
  class Puppet::Util::Ldap::Generator
@@ -1,5 +1,2 @@
1
- #
2
- # Created by Luke Kanies on 2008-3-23.
3
- # Copyright (c) 2008. All rights reserved.
4
1
  module Puppet::Util::Ldap
5
2
  end
@@ -1,6 +1,3 @@
1
- # Created by Luke Kanies on 2007-07-04.
2
- # Copyright (c) 2007. All rights reserved.
3
-
4
1
  module Puppet::Util::LogPaths
5
2
  # return the full path to us, for logging and rollback
6
3
  # some classes (e.g., FileTypeRecords) will have to override this
@@ -70,7 +70,8 @@ class Puppet::Util::NetworkDevice::Cisco::Device < Puppet::Util::NetworkDevice::
70
70
 
71
71
  IF={
72
72
  :FastEthernet => %w{FastEthernet FastEth Fast FE Fa F},
73
- :GigEthernet => %w{GigabitEthernet GigEthernet GigEth GE Gi G},
73
+ :GigabitEthernet => %w{GigabitEthernet GigEthernet GigEth GE Gi G},
74
+ :TenGigabitEthernet => %w{TenGigabitEthernet TE Te},
74
75
  :Ethernet => %w{Ethernet Eth E},
75
76
  :Serial => %w{Serial Se S},
76
77
  :PortChannel => %w{PortChannel Port-Channel Po},
@@ -63,7 +63,7 @@ class Puppet::Util::NetworkDevice::Cisco::Facts
63
63
  end
64
64
 
65
65
  def uptime_to_seconds(uptime)
66
- captures = (uptime.match /^(?:(?:(?:(?:(\d+) years?,)?\s*(\d+) weeks?,)?\s*(\d+) days?,)?\s*(\d+) hours?,)?\s*(\d+) minutes?$/).captures
66
+ captures = (uptime.match /^(?:(\d+) years?,)?\s*(?:(\d+) weeks?,)?\s*(?:(\d+) days?,)?\s*(?:(\d+) hours?,)?\s*(\d+) minutes?$/).captures
67
67
  seconds = captures.zip([31536000, 604800, 86400, 3600, 60]).inject(0) do |total, (x,y)|
68
68
  total + (x.nil? ? 0 : x.to_i * y)
69
69
  end
@@ -59,9 +59,13 @@ class Puppet::Util::Pidlock
59
59
  def clear_if_stale
60
60
  return if lock_pid.nil?
61
61
 
62
+ errors = [Errno::ESRCH]
63
+ # Process::Error can only happen, and is only defined, on Windows
64
+ errors << Process::Error if defined? Process::Error
65
+
62
66
  begin
63
67
  Process.kill(0, lock_pid)
64
- rescue Errno::ESRCH
68
+ rescue *errors
65
69
  File.unlink(@lockfile)
66
70
  end
67
71
  end
@@ -113,7 +113,9 @@ class Parser
113
113
  Puppet::Module.modulepath.each do |mp|
114
114
  # check that fullpath is a descendant of mp
115
115
  dirname = fullpath
116
- while (dirname = File.dirname(dirname)) != '/'
116
+ previous = dirname
117
+ while (dirname = File.dirname(previous)) != previous
118
+ previous = dirname
117
119
  return nil if File.identical?(dirname,mp)
118
120
  end
119
121
  end
@@ -27,14 +27,14 @@ module Puppet
27
27
 
28
28
  def conf_dir
29
29
  which_dir(
30
- (Puppet.features.microsoft_windows? ? File.join(Dir::WINDOWS, "puppet", "etc") : "/etc/puppet"),
30
+ (Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "etc") : "/etc/puppet"),
31
31
  "~/.puppet"
32
32
  )
33
33
  end
34
34
 
35
35
  def var_dir
36
36
  which_dir(
37
- (Puppet.features.microsoft_windows? ? File.join(Dir::WINDOWS, "puppet", "var") : "/var/lib/puppet"),
37
+ (Puppet.features.microsoft_windows? ? File.join(Dir::COMMON_APPDATA, "PuppetLabs", "puppet", "var") : "/var/lib/puppet"),
38
38
  "~/.puppet/var"
39
39
  )
40
40
  end
@@ -86,14 +86,15 @@ class Puppet::Util::Settings::FileSetting < Puppet::Util::Settings::Setting
86
86
  path = File.expand_path(path)
87
87
 
88
88
  return nil unless type == :directory or create_files? or File.exist?(path)
89
- return nil if path =~ /^\/dev/
89
+ return nil if path =~ /^\/dev/ or path =~ /^[A-Z]:\/dev/i
90
90
 
91
91
  resource = Puppet::Resource.new(:file, path)
92
92
 
93
93
  if Puppet[:manage_internal_file_permissions]
94
94
  resource[:mode] = self.mode if self.mode
95
95
 
96
- if Puppet.features.root?
96
+ # REMIND fails on Windows because chown/chgrp functionality not supported yet
97
+ if Puppet.features.root? and !Puppet.features.microsoft_windows?
97
98
  resource[:owner] = self.owner if self.owner
98
99
  resource[:group] = self.group if self.group
99
100
  end
@@ -2,13 +2,11 @@ require 'puppet'
2
2
  require 'sync'
3
3
  require 'getoptlong'
4
4
  require 'puppet/external/event-loop'
5
- require 'puppet/util/cacher'
6
5
  require 'puppet/util/loadedfile'
7
6
 
8
7
  # The class for handling configuration files.
9
8
  class Puppet::Util::Settings
10
9
  include Enumerable
11
- include Puppet::Util::Cacher
12
10
 
13
11
  require 'puppet/util/settings/setting'
14
12
  require 'puppet/util/settings/file_setting'
@@ -401,11 +399,10 @@ class Puppet::Util::Settings
401
399
  }
402
400
  end
403
401
 
404
- # Cache this in an easily clearable way, since we were
405
- # having trouble cleaning it up after tests.
406
- cached_attr(:file) do
402
+ def file
403
+ return @file if @file
407
404
  if path = self[:config] and FileTest.exist?(path)
408
- Puppet::Util::LoadedFile.new(path)
405
+ @file = Puppet::Util::LoadedFile.new(path)
409
406
  end
410
407
  end
411
408
 
@@ -783,6 +780,7 @@ if @config.include?(:run_mode)
783
780
  # Create the transportable objects for users and groups.
784
781
  def add_user_resources(catalog, sections)
785
782
  return unless Puppet.features.root?
783
+ return if Puppet.features.microsoft_windows?
786
784
  return unless self[:mkusers]
787
785
 
788
786
  @config.each do |name, setting|
@@ -36,37 +36,84 @@ module Puppet::Util::SUIDManager
36
36
  end
37
37
  module_function :groups=
38
38
 
39
- if Facter['kernel'].value == 'Darwin'
40
- # Cannot change real UID on Darwin so we set euid
41
- alias :uid :euid
42
- alias :gid :egid
43
- end
44
-
45
39
  def self.root?
46
- Process.uid == 0
40
+ return Process.uid == 0 unless Puppet.features.microsoft_windows?
41
+
42
+ require 'sys/admin'
43
+ require 'win32/security'
44
+ require 'facter'
45
+
46
+ majversion = Facter.value(:kernelmajversion)
47
+ return false unless majversion
48
+
49
+ # if Vista or later, check for unrestricted process token
50
+ return Win32::Security.elevated_security? unless majversion.to_f < 6.0
51
+
52
+ group = Sys::Admin.get_group("Administrators", :sid => Win32::Security::SID::BuiltinAdministrators)
53
+ group and group.members.index(Sys::Admin.get_login) != nil
47
54
  end
48
55
 
49
56
  # Runs block setting uid and gid if provided then restoring original ids
50
57
  def asuser(new_uid=nil, new_gid=nil)
51
58
  return yield if Puppet.features.microsoft_windows? or !root?
52
59
 
53
- # We set both because some programs like to drop privs, i.e. bash.
54
- old_uid, old_gid = self.uid, self.gid
55
60
  old_euid, old_egid = self.euid, self.egid
56
- old_groups = self.groups
57
61
  begin
58
- self.egid = convert_xid :gid, new_gid if new_gid
59
- self.initgroups(convert_xid(:uid, new_uid)) if new_uid
60
- self.euid = convert_xid :uid, new_uid if new_uid
62
+ change_group(new_gid) if new_gid
63
+ change_user(new_uid) if new_uid
61
64
 
62
65
  yield
63
66
  ensure
64
- self.euid, self.egid = old_euid, old_egid
65
- self.groups = old_groups
67
+ change_group(old_egid)
68
+ change_user(old_euid)
66
69
  end
67
70
  end
68
71
  module_function :asuser
69
72
 
73
+ def change_group(group, permanently=false)
74
+ gid = convert_xid(:gid, group)
75
+ raise Puppet::Error, "No such group #{group}" unless gid
76
+
77
+ if permanently
78
+ begin
79
+ Process::GID.change_privilege(gid)
80
+ rescue NotImplementedError
81
+ Process.egid = gid
82
+ Process.gid = gid
83
+ end
84
+ else
85
+ Process.egid = gid
86
+ end
87
+ end
88
+ module_function :change_group
89
+
90
+ def change_user(user, permanently=false)
91
+ uid = convert_xid(:uid, user)
92
+ raise Puppet::Error, "No such user #{user}" unless uid
93
+
94
+ if permanently
95
+ begin
96
+ Process::UID.change_privilege(uid)
97
+ rescue NotImplementedError
98
+ # If changing uid, we must be root. So initgroups first here.
99
+ initgroups(uid)
100
+ Process.euid = uid
101
+ Process.uid = uid
102
+ end
103
+ else
104
+ # If we're already root, initgroups before changing euid. If we're not,
105
+ # change euid (to root) first.
106
+ if Process.euid == 0
107
+ initgroups(uid)
108
+ Process.euid = uid
109
+ else
110
+ Process.euid = uid
111
+ initgroups(uid)
112
+ end
113
+ end
114
+ end
115
+ module_function :change_user
116
+
70
117
  # Make sure the passed argument is a number.
71
118
  def convert_xid(type, id)
72
119
  map = {:gid => :group, :uid => :user}