puppet 0.24.5 → 0.24.6

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 (354) hide show
  1. data/CHANGELOG +206 -0
  2. data/Rakefile +53 -0
  3. data/bin/filebucket +0 -0
  4. data/bin/puppet +32 -11
  5. data/bin/puppetca +1 -0
  6. data/bin/puppetd +0 -0
  7. data/bin/puppetdoc +0 -0
  8. data/bin/puppetmasterd +0 -0
  9. data/bin/puppetrun +16 -8
  10. data/bin/ralsh +0 -0
  11. data/conf/debian/rules +0 -0
  12. data/conf/gentoo/init.d/puppetmaster +0 -0
  13. data/conf/osx/PackageInfo.plist +36 -0
  14. data/conf/osx/createpackage.sh +167 -0
  15. data/conf/osx/preflight +12 -0
  16. data/conf/redhat/client.init +1 -1
  17. data/conf/redhat/puppet.spec +34 -6
  18. data/conf/redhat/server.init +42 -7
  19. data/conf/redhat/server.sysconfig +22 -0
  20. data/conf/solaris/smf/svc-puppetd +0 -0
  21. data/conf/solaris/smf/svc-puppetmasterd +0 -0
  22. data/examples/etc/init.d/sleeper +0 -0
  23. data/examples/mac_dscl.pp +0 -0
  24. data/examples/mac_dscl_revert.pp +0 -0
  25. data/examples/mac_netinfo.pp +0 -0
  26. data/examples/mac_pkgdmg.pp +0 -0
  27. data/ext/bin/sleeper +0 -0
  28. data/ext/module_puppet +0 -0
  29. data/ext/nagios/check_puppet.rb +0 -0
  30. data/ext/passenger/README +63 -0
  31. data/ext/passenger/apache2.conf +29 -0
  32. data/ext/passenger/config.ru +40 -0
  33. data/ext/puppet-test +0 -0
  34. data/ext/puppetlast +6 -31
  35. data/ext/puppetstoredconfigclean.rb +87 -0
  36. data/install.rb +75 -20
  37. data/lib/puppet.rb +1 -1
  38. data/lib/puppet/daemon.rb +0 -0
  39. data/lib/puppet/defaults.rb +3 -7
  40. data/lib/puppet/external/base64.rb +0 -0
  41. data/lib/puppet/external/nagios.rb +0 -0
  42. data/lib/puppet/external/nagios/base.rb +0 -0
  43. data/lib/puppet/file_serving/fileset.rb +2 -2
  44. data/lib/puppet/file_serving/metadata.rb +3 -3
  45. data/lib/puppet/indirector/facts/facter.rb +3 -2
  46. data/lib/puppet/indirector/yaml.rb +10 -1
  47. data/lib/puppet/module.rb +36 -12
  48. data/lib/puppet/network/authstore.rb +0 -0
  49. data/lib/puppet/network/client/master.rb +12 -11
  50. data/lib/puppet/network/handler/filebucket.rb +0 -0
  51. data/lib/puppet/network/handler/fileserver.rb +38 -46
  52. data/lib/puppet/network/handler/master.rb +1 -1
  53. data/lib/puppet/network/handler/report.rb +0 -0
  54. data/lib/puppet/network/handler/resource.rb +0 -0
  55. data/lib/puppet/network/handler/runner.rb +0 -0
  56. data/lib/puppet/network/http_server/rack.rb +148 -0
  57. data/lib/puppet/network/rights.rb +0 -0
  58. data/lib/puppet/network/xmlrpc/client.rb +5 -5
  59. data/lib/puppet/node.rb +5 -9
  60. data/lib/puppet/node/environment.rb +1 -17
  61. data/lib/puppet/node/facts.rb +0 -0
  62. data/lib/puppet/parameter.rb +1 -28
  63. data/lib/puppet/parser/ast.rb +6 -0
  64. data/lib/puppet/parser/ast/arithmetic_operator.rb +41 -0
  65. data/lib/puppet/parser/ast/boolean_operator.rb +48 -0
  66. data/lib/puppet/parser/ast/collexpr.rb +6 -1
  67. data/lib/puppet/parser/ast/comparison_operator.rb +37 -0
  68. data/lib/puppet/parser/ast/minus.rb +23 -0
  69. data/lib/puppet/parser/ast/nop.rb +11 -0
  70. data/lib/puppet/parser/ast/not.rb +19 -0
  71. data/lib/puppet/parser/ast/resource_override.rb +23 -16
  72. data/lib/puppet/parser/ast/resource_reference.rb +10 -6
  73. data/lib/puppet/parser/ast/vardef.rb +2 -2
  74. data/lib/puppet/parser/collector.rb +2 -1
  75. data/lib/puppet/parser/functions.rb +7 -217
  76. data/lib/puppet/parser/functions/defined.rb +27 -0
  77. data/lib/puppet/parser/functions/fail.rb +4 -0
  78. data/lib/puppet/parser/functions/file.rb +21 -0
  79. data/lib/puppet/parser/functions/fqdn_rand.rb +15 -0
  80. data/lib/puppet/parser/functions/generate.rb +35 -0
  81. data/lib/puppet/parser/functions/include.rb +26 -0
  82. data/lib/puppet/parser/functions/realize.rb +14 -0
  83. data/lib/puppet/parser/functions/search.rb +7 -0
  84. data/lib/puppet/parser/functions/sha1.rb +6 -0
  85. data/lib/puppet/parser/functions/tag.rb +6 -0
  86. data/lib/puppet/parser/functions/tagged.rb +18 -0
  87. data/lib/puppet/parser/functions/template.rb +22 -0
  88. data/lib/puppet/parser/lexer.rb +15 -5
  89. data/lib/puppet/parser/parser.rb +1073 -715
  90. data/lib/puppet/parser/parser_support.rb +18 -13
  91. data/lib/puppet/parser/resource.rb +1 -1
  92. data/lib/puppet/parser/resource/param.rb +10 -2
  93. data/lib/puppet/parser/scope.rb +63 -5
  94. data/lib/puppet/parser/templatewrapper.rb +61 -15
  95. data/lib/puppet/property.rb +7 -1
  96. data/lib/puppet/property/keyvalue.rb +96 -0
  97. data/lib/puppet/property/list.rb +78 -0
  98. data/lib/puppet/provider/confine.rb +1 -1
  99. data/lib/puppet/provider/confine/variable.rb +10 -1
  100. data/lib/puppet/provider/cron/crontab.rb +0 -0
  101. data/lib/puppet/provider/mailalias/aliases.rb +0 -0
  102. data/lib/puppet/provider/maillist/mailman.rb +0 -0
  103. data/lib/puppet/provider/mount/parsed.rb +0 -0
  104. data/lib/puppet/provider/nameservice.rb +24 -39
  105. data/lib/puppet/provider/nameservice/directoryservice.rb +12 -3
  106. data/lib/puppet/provider/nameservice/netinfo.rb +12 -2
  107. data/lib/puppet/provider/nameservice/objectadd.rb +1 -10
  108. data/lib/puppet/provider/package/appdmg.rb +1 -1
  109. data/lib/puppet/provider/package/apple.rb +0 -0
  110. data/lib/puppet/provider/package/apt.rb +14 -21
  111. data/lib/puppet/provider/package/aptitude.rb +0 -0
  112. data/lib/puppet/provider/package/blastwave.rb +2 -0
  113. data/lib/puppet/provider/package/darwinport.rb +0 -0
  114. data/lib/puppet/provider/package/dpkg.rb +33 -51
  115. data/lib/puppet/provider/package/fink.rb +1 -1
  116. data/lib/puppet/provider/package/freebsd.rb +0 -0
  117. data/lib/puppet/provider/package/gem.rb +0 -0
  118. data/lib/puppet/provider/package/hpux.rb +46 -0
  119. data/lib/puppet/provider/package/openbsd.rb +0 -0
  120. data/lib/puppet/provider/package/pkgdmg.rb +1 -1
  121. data/lib/puppet/provider/package/portage.rb +3 -1
  122. data/lib/puppet/provider/package/ports.rb +3 -3
  123. data/lib/puppet/provider/package/rpm.rb +8 -1
  124. data/lib/puppet/provider/package/rug.rb +2 -2
  125. data/lib/puppet/provider/package/sun.rb +2 -0
  126. data/lib/puppet/provider/package/sunfreeware.rb +3 -0
  127. data/lib/puppet/provider/package/yum.rb +24 -17
  128. data/lib/puppet/provider/package/yumhelper.py +92 -11
  129. data/lib/puppet/provider/parsedfile.rb +0 -0
  130. data/lib/puppet/provider/port/parsed.rb +0 -0
  131. data/lib/puppet/provider/selboolean/getsetsebool.rb +47 -0
  132. data/lib/puppet/provider/selmodule/semodule.rb +143 -0
  133. data/lib/puppet/provider/service/base.rb +0 -0
  134. data/lib/puppet/provider/service/daemontools.rb +154 -0
  135. data/lib/puppet/provider/service/debian.rb +1 -1
  136. data/lib/puppet/provider/service/freebsd.rb +2 -0
  137. data/lib/puppet/provider/service/gentoo.rb +2 -0
  138. data/lib/puppet/provider/service/init.rb +0 -0
  139. data/lib/puppet/provider/service/redhat.rb +1 -1
  140. data/lib/puppet/provider/service/runit.rb +93 -0
  141. data/lib/puppet/provider/service/smf.rb +2 -0
  142. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +7 -1
  143. data/lib/puppet/provider/sshkey/parsed.rb +0 -0
  144. data/lib/puppet/provider/user/hpux.rb +30 -0
  145. data/lib/puppet/provider/user/user_role_add.rb +156 -0
  146. data/lib/puppet/provider/user/useradd.rb +23 -14
  147. data/lib/puppet/rails/database/002_remove_duplicated_index_on_all_tables.rb +17 -0
  148. data/lib/puppet/rails/database/schema.rb +0 -8
  149. data/lib/puppet/rails/resource.rb +6 -6
  150. data/lib/puppet/reference/configuration.rb +0 -7
  151. data/lib/puppet/reports.rb +0 -0
  152. data/lib/puppet/reports/rrdgraph.rb +3 -2
  153. data/lib/puppet/sslcertificates.rb +0 -0
  154. data/lib/puppet/sslcertificates/inventory.rb +3 -2
  155. data/lib/puppet/sslcertificates/support.rb +3 -0
  156. data/lib/puppet/transaction/report.rb +1 -7
  157. data/lib/puppet/transportable.rb +10 -7
  158. data/lib/puppet/type.rb +2110 -14
  159. data/lib/puppet/type/cron.rb +0 -0
  160. data/lib/puppet/type/exec.rb +0 -0
  161. data/lib/puppet/type/file.rb +12 -2
  162. data/lib/puppet/type/file/checksum.rb +4 -0
  163. data/lib/puppet/type/file/content.rb +0 -0
  164. data/lib/puppet/type/file/ensure.rb +0 -0
  165. data/lib/puppet/type/file/group.rb +30 -43
  166. data/lib/puppet/type/file/mode.rb +0 -0
  167. data/lib/puppet/type/file/owner.rb +0 -0
  168. data/lib/puppet/type/file/selcontext.rb +104 -0
  169. data/lib/puppet/type/file/source.rb +0 -0
  170. data/lib/puppet/type/file/type.rb +0 -0
  171. data/lib/puppet/type/filebucket.rb +0 -0
  172. data/lib/puppet/type/group.rb +0 -8
  173. data/lib/puppet/type/host.rb +0 -0
  174. data/lib/puppet/type/mailalias.rb +0 -0
  175. data/lib/puppet/type/maillist.rb +0 -0
  176. data/lib/puppet/type/mount.rb +0 -0
  177. data/lib/puppet/type/package.rb +2 -2
  178. data/lib/puppet/type/port.rb +0 -0
  179. data/lib/puppet/type/schedule.rb +0 -0
  180. data/lib/puppet/type/selboolean.rb +31 -0
  181. data/lib/puppet/type/selmodule.rb +54 -0
  182. data/lib/puppet/type/ssh_authorized_key.rb +3 -3
  183. data/lib/puppet/type/sshkey.rb +0 -0
  184. data/lib/puppet/type/tidy.rb +0 -0
  185. data/lib/puppet/type/user.rb +153 -137
  186. data/lib/puppet/type/yumrepo.rb +18 -2
  187. data/lib/puppet/type/zone.rb +5 -1
  188. data/lib/puppet/util.rb +7 -7
  189. data/lib/puppet/util/filetype.rb +7 -0
  190. data/lib/puppet/util/instance_loader.rb +0 -0
  191. data/lib/puppet/util/ldap/connection.rb +11 -1
  192. data/lib/puppet/util/ldap/manager.rb +1 -1
  193. data/lib/puppet/util/loadedfile.rb +0 -0
  194. data/lib/puppet/util/log.rb +42 -43
  195. data/lib/puppet/util/metric.rb +23 -9
  196. data/lib/puppet/util/posix.rb +69 -18
  197. data/lib/puppet/util/selinux.rb +139 -0
  198. data/lib/puppet/util/settings.rb +5 -7
  199. data/lib/puppet/util/user_attr.rb +21 -0
  200. data/test/certmgr/ca.rb +0 -0
  201. data/test/certmgr/certmgr.rb +0 -0
  202. data/test/certmgr/inventory.rb +0 -0
  203. data/test/certmgr/support.rb +0 -0
  204. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys1 +3 -0
  205. data/test/data/snippets/append.pp +11 -0
  206. data/test/data/snippets/arithmetic_expression.pp +8 -0
  207. data/test/data/snippets/arraytrailingcomma.pp +3 -0
  208. data/test/data/snippets/emptyifelse.pp +9 -0
  209. data/test/data/snippets/funccomma.pp +5 -0
  210. data/test/data/snippets/ifexpression.rb +6 -0
  211. data/test/data/snippets/subclass_name_duplication.pp +0 -0
  212. data/test/executables/filebucket.rb +0 -0
  213. data/test/executables/puppetbin.rb +0 -0
  214. data/test/executables/puppetca.rb +0 -0
  215. data/test/executables/puppetd.rb +0 -0
  216. data/test/executables/puppetmasterd.rb +0 -0
  217. data/test/executables/puppetmodule.rb +0 -0
  218. data/test/language/ast.rb +0 -0
  219. data/test/language/ast/casestatement.rb +0 -0
  220. data/test/language/ast/resource.rb +0 -0
  221. data/test/language/ast/resource_reference.rb +0 -28
  222. data/test/language/ast/selector.rb +0 -0
  223. data/test/language/ast/variable.rb +0 -0
  224. data/test/language/functions.rb +91 -12
  225. data/test/language/parser.rb +21 -0
  226. data/test/language/resource.rb +0 -0
  227. data/test/language/scope.rb +28 -0
  228. data/test/language/snippets.rb +14 -0
  229. data/test/language/transportable.rb +0 -0
  230. data/test/lib/puppettest.rb +0 -0
  231. data/test/lib/puppettest/reporttesting.rb +0 -2
  232. data/test/lib/puppettest/runnable_test.rb +2 -0
  233. data/test/lib/puppettest/support/resources.rb +0 -0
  234. data/test/network/authconfig.rb +0 -0
  235. data/test/network/authorization.rb +0 -0
  236. data/test/network/authstore.rb +0 -0
  237. data/test/network/client/ca.rb +0 -0
  238. data/test/network/client/client.rb +0 -0
  239. data/test/network/client/dipper.rb +0 -0
  240. data/test/network/client/master.rb +2 -6
  241. data/test/network/client/resource.rb +0 -0
  242. data/test/network/client_request.rb +0 -0
  243. data/test/network/daemon.rb +0 -0
  244. data/test/network/handler/bucket.rb +0 -0
  245. data/test/network/handler/ca.rb +0 -0
  246. data/test/network/handler/fileserver.rb +8 -0
  247. data/test/network/handler/handler.rb +0 -0
  248. data/test/network/handler/master.rb +3 -1
  249. data/test/network/handler/report.rb +0 -0
  250. data/test/network/handler/resource.rb +0 -0
  251. data/test/network/handler/runner.rb +0 -0
  252. data/test/network/rights.rb +0 -0
  253. data/test/network/server/mongrel_test.rb +0 -0
  254. data/test/network/server/webrick.rb +0 -0
  255. data/test/network/xmlrpc/client.rb +0 -0
  256. data/test/network/xmlrpc/processor.rb +0 -0
  257. data/test/network/xmlrpc/server.rb +0 -0
  258. data/test/network/xmlrpc/webrick_servlet.rb +0 -0
  259. data/test/other/dsl.rb +0 -0
  260. data/test/other/events.rb +0 -0
  261. data/test/other/overrides.rb +0 -0
  262. data/test/other/provider.rb +0 -0
  263. data/test/other/puppet.rb +0 -0
  264. data/test/other/relationships.rb +0 -0
  265. data/test/other/report.rb +2 -4
  266. data/test/other/transactions.rb +1 -1
  267. data/test/puppet/conffiles.rb +0 -0
  268. data/test/puppet/defaults.rb +0 -0
  269. data/test/puppet/errortest.rb +0 -0
  270. data/test/puppet/tc_suidmanager.rb +0 -0
  271. data/test/rails/ast.rb +0 -0
  272. data/test/rails/configuration.rb +0 -0
  273. data/test/rails/host.rb +0 -0
  274. data/test/rails/rails.rb +0 -0
  275. data/test/rails/railsparameter.rb +0 -0
  276. data/test/rails/railsresource.rb +0 -0
  277. data/test/ral/manager/attributes.rb +0 -0
  278. data/test/ral/manager/instances.rb +0 -0
  279. data/test/ral/manager/manager.rb +0 -0
  280. data/test/ral/manager/provider.rb +0 -0
  281. data/test/ral/manager/type.rb +0 -0
  282. data/test/ral/providers/cron/crontab.rb +0 -0
  283. data/test/ral/providers/group.rb +14 -13
  284. data/test/ral/providers/host/netinfo.rb +0 -0
  285. data/test/ral/providers/host/parsed.rb +0 -0
  286. data/test/ral/providers/mailalias/aliases.rb +0 -0
  287. data/test/ral/providers/mount/netinfo.rb +0 -0
  288. data/test/ral/providers/nameservice.rb +0 -0
  289. data/test/ral/providers/package.rb +0 -31
  290. data/test/ral/providers/package/aptitude.rb +1 -2
  291. data/test/ral/providers/package/aptrpm.rb +2 -2
  292. data/test/ral/providers/parsedfile.rb +0 -0
  293. data/test/ral/providers/port/parsed.rb +0 -0
  294. data/test/ral/providers/provider.rb +0 -0
  295. data/test/ral/providers/service/base.rb +0 -0
  296. data/test/ral/providers/service/debian.rb +0 -0
  297. data/test/ral/providers/sshkey/parsed.rb +0 -0
  298. data/test/ral/providers/user.rb +8 -8
  299. data/test/ral/providers/user/useradd.rb +0 -0
  300. data/test/ral/type/basic.rb +0 -0
  301. data/test/ral/type/cron.rb +0 -0
  302. data/test/ral/type/exec.rb +0 -0
  303. data/test/ral/type/file.rb +0 -0
  304. data/test/ral/type/file/target.rb +0 -0
  305. data/test/ral/type/filebucket.rb +0 -0
  306. data/test/ral/type/fileignoresource.rb +0 -0
  307. data/test/ral/type/filesources.rb +1 -3
  308. data/test/ral/type/group.rb +0 -0
  309. data/test/ral/type/host.rb +0 -0
  310. data/test/ral/type/mailalias.rb +1 -2
  311. data/test/ral/type/parameter.rb +0 -0
  312. data/test/ral/type/port.rb +0 -0
  313. data/test/ral/type/property.rb +0 -0
  314. data/test/ral/type/resources.rb +0 -0
  315. data/test/ral/type/service.rb +0 -0
  316. data/test/ral/type/sshkey.rb +0 -0
  317. data/test/ral/type/tidy.rb +0 -0
  318. data/test/ral/type/user.rb +0 -50
  319. data/test/ral/type/yumrepo.rb +7 -1
  320. data/test/ral/type/zone.rb +0 -0
  321. data/test/test +0 -0
  322. data/test/util/autoload.rb +0 -0
  323. data/test/util/classgen.rb +0 -0
  324. data/test/util/execution.rb +0 -0
  325. data/test/util/features.rb +0 -0
  326. data/test/util/fileparsing.rb +0 -0
  327. data/test/util/filetype.rb +0 -0
  328. data/test/util/inifile.rb +0 -0
  329. data/test/util/instance_loader.rb +0 -0
  330. data/test/util/log.rb +0 -59
  331. data/test/util/metrics.rb +0 -0
  332. data/test/util/package.rb +0 -0
  333. data/test/util/pidlock.rb +0 -0
  334. data/test/util/settings.rb +0 -0
  335. data/test/util/storage.rb +0 -0
  336. data/test/util/subclass_loader.rb +0 -0
  337. data/test/util/utiltest.rb +0 -0
  338. metadata +54 -19
  339. data/lib/puppet/metatype/attributes.rb +0 -685
  340. data/lib/puppet/metatype/closure.rb +0 -49
  341. data/lib/puppet/metatype/container.rb +0 -50
  342. data/lib/puppet/metatype/evaluation.rb +0 -163
  343. data/lib/puppet/metatype/instances.rb +0 -305
  344. data/lib/puppet/metatype/metaparams.rb +0 -423
  345. data/lib/puppet/metatype/providers.rb +0 -247
  346. data/lib/puppet/metatype/relationships.rb +0 -115
  347. data/lib/puppet/metatype/schedules.rb +0 -33
  348. data/lib/puppet/metatype/tags.rb +0 -38
  349. data/lib/puppet/util/plist.rb +0 -23
  350. data/lib/puppet/util/plist/generator.rb +0 -225
  351. data/lib/puppet/util/plist/parser.rb +0 -226
  352. data/test/ral/providers/package/apt.rb +0 -169
  353. data/test/ral/providers/package/dpkg.rb +0 -64
  354. data/test/util/posixtest.rb +0 -169
@@ -1,8 +1,13 @@
1
1
  # Basic classes for reading, writing, and emptying files. Not much
2
2
  # to see here.
3
+
4
+ require 'puppet/util/selinux'
5
+
3
6
  class Puppet::Util::FileType
4
7
  attr_accessor :loaded, :path, :synced
5
8
 
9
+ include Puppet::Util::SELinux
10
+
6
11
  class << self
7
12
  attr_accessor :name
8
13
  include Puppet::Util::ClassGen
@@ -109,6 +114,8 @@ class Puppet::Util::FileType
109
114
  tf.print text; tf.flush
110
115
  FileUtils.cp(tf.path, @path)
111
116
  tf.close
117
+ # If SELinux is present, we need to ensure the file has its expected context
118
+ set_selinux_default_context(@path)
112
119
  end
113
120
  end
114
121
 
File without changes
@@ -17,7 +17,17 @@ class Puppet::Util::Ldap::Connection
17
17
  else
18
18
  false
19
19
  end
20
- new(Puppet[:ldapserver], Puppet[:ldapport], :ssl => ssl)
20
+
21
+ options = {}
22
+ options[:ssl] = ssl
23
+ if user = Puppet.settings[:ldapuser] and user != ""
24
+ options[:user] = user
25
+ if pass = Puppet.settings[:ldappassword] and pass != ""
26
+ options[:password] = pass
27
+ end
28
+ end
29
+
30
+ new(Puppet[:ldapserver], Puppet[:ldapport], options)
21
31
  end
22
32
 
23
33
  def close
@@ -80,7 +80,7 @@ class Puppet::Util::Ldap::Manager
80
80
 
81
81
  # Calculate the dn for a given resource.
82
82
  def dn(name)
83
- ["#{rdn.to_s}=%s" % name, base].join(",")
83
+ ["%s=%s" % [rdn, name], base].join(",")
84
84
  end
85
85
 
86
86
  # Convert an ldap-style entry hash to a provider-style hash.
File without changes
@@ -1,10 +1,12 @@
1
1
  require 'syslog'
2
+ require 'puppet/util/tagging'
2
3
 
3
4
  # Pass feedback to the user. Log levels are modeled after syslog's, and it is
4
5
  # expected that that will be the most common log destination. Supports
5
6
  # multiple destinations, one of which is a remote server.
6
7
  class Puppet::Util::Log
7
8
  include Puppet::Util
9
+ include Puppet::Util::Tagging
8
10
 
9
11
  @levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit]
10
12
  @loglevel = 2
@@ -244,23 +246,31 @@ class Puppet::Util::Log
244
246
  newdesttype :console do
245
247
 
246
248
 
247
- PINK = {:console => "", :html => "FFA0A0"}
248
- GREEN = {:console => "", :html => "00CD00"}
249
- YELLOW = {:console => "", :html => "FFFF60"}
250
- SLATE = {:console => "", :html => "80A0FF"}
251
- ORANGE = {:console => "", :html => "FFA500"}
252
- BLUE = {:console => "", :html => "40FFFF"}
253
- RESET = {:console => "", :html => ""}
249
+ RED = {:console => "", :html => "FFA0A0"}
250
+ GREEN = {:console => "", :html => "00CD00"}
251
+ YELLOW = {:console => "", :html => "FFFF60"}
252
+ BLUE = {:console => "", :html => "80A0FF"}
253
+ PURPLE = {:console => "", :html => "FFA500"}
254
+ CYAN = {:console => "", :html => "40FFFF"}
255
+ WHITE = {:console => "", :html => "FFFFFF"}
256
+ HRED = {:console => "", :html => "FFA0A0"}
257
+ HGREEN = {:console => "", :html => "00CD00"}
258
+ HYELLOW = {:console => "", :html => "FFFF60"}
259
+ HBLUE = {:console => "", :html => "80A0FF"}
260
+ HPURPLE = {:console => "", :html => "FFA500"}
261
+ HCYAN = {:console => "", :html => "40FFFF"}
262
+ HWHITE = {:console => "", :html => "FFFFFF"}
263
+ RESET = {:console => "", :html => ""}
254
264
 
255
265
  @@colormap = {
256
- :debug => SLATE,
266
+ :debug => WHITE,
257
267
  :info => GREEN,
258
- :notice => PINK,
259
- :warning => ORANGE,
260
- :err => YELLOW,
261
- :alert => BLUE,
262
- :emerg => RESET,
263
- :crit => RESET
268
+ :notice => CYAN,
269
+ :warning => YELLOW,
270
+ :err => HPURPLE,
271
+ :alert => RED,
272
+ :emerg => HRED,
273
+ :crit => HRED
264
274
  }
265
275
 
266
276
  def colorize(level, str)
@@ -462,12 +472,12 @@ class Puppet::Util::Log
462
472
  @levels.include?(level)
463
473
  end
464
474
 
465
- attr_accessor :level, :message, :time, :tags, :remote
475
+ attr_accessor :level, :message, :time, :remote
466
476
  attr_reader :source
467
477
 
468
478
  def initialize(args)
469
479
  unless args.include?(:level) && args.include?(:message)
470
- raise Puppet::DevError, "Puppet::Util::Log called incorrectly"
480
+ raise ArgumentError, "Puppet::Util::Log called incorrectly"
471
481
  end
472
482
 
473
483
  if args[:level].class == String
@@ -475,35 +485,27 @@ class Puppet::Util::Log
475
485
  elsif args[:level].class == Symbol
476
486
  @level = args[:level]
477
487
  else
478
- raise Puppet::DevError,
479
- "Level is not a string or symbol: #{args[:level].class}"
488
+ raise ArgumentError, "Level is not a string or symbol: #{args[:level].class}"
480
489
  end
481
490
 
482
- # Just return unless we're actually at a level we should send
483
- #return unless self.class.sendlevel?(@level)
484
-
485
491
  @message = args[:message].to_s
486
492
  @time = Time.now
487
- # this should include the host name, and probly lots of other
488
- # stuff, at some point
489
- unless self.class.validlevel?(level)
490
- raise Puppet::DevError, "Invalid message level #{level}"
491
- end
492
493
 
493
- if args.include?(:tags)
494
- @tags = args[:tags]
495
- end
494
+ raise ArgumentError, "Invalid log level %s" % level unless self.class.validlevel?(level)
496
495
 
497
- if args.include?(:source)
498
- self.source = args[:source]
499
- else
500
- @source = "Puppet"
496
+ if tags = args[:tags]
497
+ tags.each { |t| self.tag(t) }
501
498
  end
502
499
 
500
+ self.source = args[:source] || "Puppet"
501
+
502
+ # Tag myself with my log level
503
+ tag(level)
504
+
503
505
  Log.newmessage(self)
504
506
  end
505
507
 
506
- # Was the source of this log an object?
508
+ # Was the source of this log a Puppet resource or parameter?
507
509
  def objectsource?
508
510
  if defined? @objectsource and @objectsource
509
511
  @objectsource
@@ -525,17 +527,11 @@ class Puppet::Util::Log
525
527
  @objectsource = false
526
528
  @source = source.to_s
527
529
  end
528
- unless defined? @tags and @tags
529
- if source.respond_to?(:tags)
530
- @tags = source.tags
531
- end
530
+ if source.respond_to?(:tags)
531
+ source.tags.each { |t| tag(t) }
532
532
  end
533
533
  end
534
534
 
535
- def tagged?(tag)
536
- @tags.detect { |t| t.to_s == tag.to_s }
537
- end
538
-
539
535
  def to_report
540
536
  "%s %s (%s): %s" % [self.time, self.source, self.level, self.to_s]
541
537
  end
@@ -544,5 +540,8 @@ class Puppet::Util::Log
544
540
  return @message
545
541
  end
546
542
  end
547
- Puppet::Log = Puppet::Util::Log
548
543
 
544
+ # This is for backward compatibility from when we changed the constant to Puppet::Util::Log
545
+ # because the reports include the constant name. Apparently the alias was created in
546
+ # March 2007, should could probably be removed soon.
547
+ Puppet::Log = Puppet::Util::Log
@@ -5,6 +5,8 @@ require 'puppet'
5
5
  class Puppet::Util::Metric
6
6
 
7
7
  # Load the library as a feature, so we can test its presence.
8
+ # It's only used by this class, so there's no reason to move it
9
+ # to the main feature list.
8
10
  Puppet.features.add :rrd, :libs => 'RRDtool'
9
11
 
10
12
  attr_accessor :type, :name, :value, :label
@@ -12,6 +14,15 @@ class Puppet::Util::Metric
12
14
 
13
15
  attr_writer :basedir
14
16
 
17
+ # Return a specific value
18
+ def [](name)
19
+ if value = @values.find { |v| v[0] == name }
20
+ return value[2]
21
+ else
22
+ return nil
23
+ end
24
+ end
25
+
15
26
  def basedir
16
27
  if defined? @basedir
17
28
  @basedir
@@ -93,11 +104,7 @@ class Puppet::Util::Metric
93
104
  def initialize(name,label = nil)
94
105
  @name = name.to_s
95
106
 
96
- if label
97
- @label = label
98
- else
99
- @label = name.to_s.capitalize.gsub("_", " ")
100
- end
107
+ @label = label || labelize(name)
101
108
 
102
109
  @values = []
103
110
  end
@@ -107,9 +114,7 @@ class Puppet::Util::Metric
107
114
  end
108
115
 
109
116
  def newvalue(name,value,label = nil)
110
- unless label
111
- label = name.to_s.capitalize.gsub("_", " ")
112
- end
117
+ label ||= labelize(name)
113
118
  @values.push [name,label,value]
114
119
  end
115
120
 
@@ -145,7 +150,16 @@ class Puppet::Util::Metric
145
150
  def values
146
151
  @values.sort { |a, b| a[1] <=> b[1] }
147
152
  end
153
+
154
+ private
155
+
156
+ # Convert a name into a label.
157
+ def labelize(name)
158
+ name.to_s.capitalize.gsub("_", " ")
159
+ end
148
160
  end
149
161
 
162
+ # This is necessary because we changed the class path in early 2007,
163
+ # and reports directly yaml-dump these metrics, so both client and server
164
+ # have to agree on the class name.
150
165
  Puppet::Metric = Puppet::Util::Metric
151
-
@@ -3,23 +3,20 @@ module Puppet::Util::POSIX
3
3
 
4
4
  # Retrieve a field from a POSIX Etc object. The id can be either an integer
5
5
  # or a name. This only works for users and groups. It's also broken on
6
- # some platforms, unfortunately.
7
- def old_get_posix_field(space, field, id)
8
- unless id
9
- raise ArgumentError, "Did not get id"
10
- end
11
- if id =~ /^\d+$/
12
- id = Integer(id)
13
- end
14
- prefix = "get" + space.to_s
6
+ # some platforms, unfortunately, which is why we fall back to the other
7
+ # method search_posix_field in the gid and uid methods if a sanity check
8
+ # fails
9
+ def get_posix_field(space, field, id)
10
+ raise Puppet::DevError, "Did not get id from caller" unless id
11
+
15
12
  if id.is_a?(Integer)
16
13
  if id > Puppet[:maximum_uid].to_i
17
14
  Puppet.err "Tried to get %s field for silly id %s" % [field, id]
18
15
  return nil
19
16
  end
20
- method = (prefix + idfield(space).to_s).intern
17
+ method = methodbyid(space)
21
18
  else
22
- method = (prefix + "nam").intern
19
+ method = methodbyname(space)
23
20
  end
24
21
 
25
22
  begin
@@ -31,13 +28,11 @@ module Puppet::Util::POSIX
31
28
  end
32
29
 
33
30
  # A degenerate method of retrieving name/id mappings. The job of this method is
34
- # to find a specific entry and then return a given field from that entry.
35
- def get_posix_field(type, field, id)
31
+ # to retrieve all objects of a certain type, search for a specific entry
32
+ # and then return a given field from that entry.
33
+ def search_posix_field(type, field, id)
36
34
  idmethod = idfield(type)
37
35
  integer = false
38
- if id =~ /^\d+$/
39
- id = Integer(id)
40
- end
41
36
  if id.is_a?(Integer)
42
37
  integer = true
43
38
  if id > Puppet[:maximum_uid].to_i
@@ -112,14 +107,70 @@ module Puppet::Util::POSIX
112
107
  end
113
108
  end
114
109
 
110
+ # Determine what the method is to get users and groups by id
111
+ def methodbyid(space)
112
+ case Puppet::Util.symbolize(space)
113
+ when :gr, :group: return :getgrgid
114
+ when :pw, :user, :passwd: return :getpwuid
115
+ else
116
+ raise ArgumentError.new("Can only handle users and groups")
117
+ end
118
+ end
119
+
120
+ # Determine what the method is to get users and groups by name
121
+ def methodbyname(space)
122
+ case Puppet::Util.symbolize(space)
123
+ when :gr, :group: return :getgrnam
124
+ when :pw, :user, :passwd: return :getpwnam
125
+ else
126
+ raise ArgumentError.new("Can only handle users and groups")
127
+ end
128
+ end
129
+
115
130
  # Get the GID of a given group, provided either a GID or a name
116
131
  def gid(group)
117
- get_posix_field(:group, :gid, group)
132
+ begin
133
+ group = Integer(group)
134
+ rescue ArgumentError
135
+ # pass
136
+ end
137
+ if group.is_a?(Integer)
138
+ return nil unless name = get_posix_field(:group, :name, group)
139
+ gid = get_posix_field(:group, :gid, name)
140
+ check_value = gid
141
+ else
142
+ return nil unless gid = get_posix_field(:group, :gid, group)
143
+ name = get_posix_field(:group, :name, gid)
144
+ check_value = name
145
+ end
146
+ if check_value != group
147
+ return search_posix_field(:group, :gid, group)
148
+ else
149
+ return gid
150
+ end
118
151
  end
119
152
 
120
153
  # Get the UID of a given user, whether a UID or name is provided
121
154
  def uid(user)
122
- get_posix_field(:passwd, :uid, user)
155
+ begin
156
+ user = Integer(user)
157
+ rescue ArgumentError
158
+ # pass
159
+ end
160
+ if user.is_a?(Integer)
161
+ return nil unless name = get_posix_field(:passwd, :name, user)
162
+ uid = get_posix_field(:passwd, :uid, name)
163
+ check_value = uid
164
+ else
165
+ return nil unless uid = get_posix_field(:passwd, :uid, user)
166
+ name = get_posix_field(:passwd, :name, uid)
167
+ check_value = name
168
+ end
169
+ if check_value != user
170
+ return search_posix_field(:passwd, :uid, user)
171
+ else
172
+ return uid
173
+ end
123
174
  end
124
175
  end
125
176
 
@@ -0,0 +1,139 @@
1
+ # Provides utility functions to help interfaces Puppet to SELinux.
2
+ #
3
+ # Currently this is implemented via the command line tools. At some
4
+ # point support should be added to use the new SELinux ruby bindings
5
+ # as that will be faster and more reliable then shelling out when they
6
+ # are available. At this time (2008-09-26) these bindings aren't bundled on
7
+ # any SELinux-using distribution I know of.
8
+
9
+ require 'puppet/util'
10
+
11
+ module Puppet::Util::SELinux
12
+
13
+ include Puppet::Util
14
+
15
+ def selinux_support?
16
+ FileTest.exists?("/selinux/enforce")
17
+ end
18
+
19
+ # Retrieve and return the full context of the file. If we don't have
20
+ # SELinux support or if the stat call fails then return nil.
21
+ def get_selinux_current_context(file)
22
+ unless selinux_support?
23
+ return nil
24
+ end
25
+ context = ""
26
+ begin
27
+ execpipe("/usr/bin/stat -c %C #{file}") do |out|
28
+ out.each do |line|
29
+ context << line
30
+ end
31
+ end
32
+ rescue Puppet::ExecutionFailure
33
+ return nil
34
+ end
35
+ context.chomp!
36
+ # Handle the case that the system seems to have SELinux support but
37
+ # stat finds unlabled files.
38
+ if context == "(null)"
39
+ return nil
40
+ end
41
+ return context
42
+ end
43
+
44
+ # Use the matchpathcon command, if present, to return the SELinux context
45
+ # which the SELinux policy on the system expects the file to have. We can
46
+ # use this to obtain a good default context. If the command does not
47
+ # exist or the call fails return nil.
48
+ #
49
+ # Note: For this command to work a full, non-relative, filesystem path
50
+ # should be given.
51
+ def get_selinux_default_context(file)
52
+ unless selinux_support?
53
+ return nil
54
+ end
55
+ unless FileTest.executable?("/usr/sbin/matchpathcon")
56
+ return nil
57
+ end
58
+ context = ""
59
+ begin
60
+ execpipe("/usr/sbin/matchpathcon #{file}") do |out|
61
+ out.each do |line|
62
+ context << line
63
+ end
64
+ end
65
+ rescue Puppet::ExecutionFailure
66
+ return nil
67
+ end
68
+ # For a successful match, matchpathcon returns two fields separated by
69
+ # a variable amount of whitespace. The second field is the full context.
70
+ context = context.split(/\s/)[1]
71
+ return context
72
+ end
73
+
74
+ # Take the full SELinux context returned from the tools and parse it
75
+ # out to the three (or four) component parts. Supports :seluser, :selrole,
76
+ # :seltype, and on systems with range support, :selrange.
77
+ def parse_selinux_context(component, context)
78
+ if context.nil? or context == "unlabeled"
79
+ return nil
80
+ end
81
+ unless context =~ /^([a-z0-9_]+):([a-z0-9_]+):([a-z0-9_]+)(?::([a-zA-Z0-9:,._-]+))?/
82
+ raise Puppet::Error, "Invalid context to parse: #{context}"
83
+ end
84
+ ret = {
85
+ :seluser => $1,
86
+ :selrole => $2,
87
+ :seltype => $3,
88
+ :selrange => $4,
89
+ }
90
+ return ret[component]
91
+ end
92
+
93
+ # This updates the actual SELinux label on the file. You can update
94
+ # only a single component or update the entire context. It is just a
95
+ # wrapper around the chcon command.
96
+ def set_selinux_context(file, value, component = false)
97
+ unless selinux_support?
98
+ return nil
99
+ end
100
+ case component
101
+ when :seluser
102
+ flag = "-u"
103
+ when :selrole
104
+ flag = "-r"
105
+ when :seltype
106
+ flag = "-t"
107
+ when :selrange
108
+ flag = "-l"
109
+ else
110
+ flag = nil
111
+ end
112
+
113
+ if flag.nil?
114
+ cmd = ["/usr/bin/chcon","-h",value,file]
115
+ else
116
+ cmd = ["/usr/bin/chcon","-h",flag,value,file]
117
+ end
118
+ execute(cmd)
119
+ return true
120
+ end
121
+
122
+ # Since this call relies on get_selinux_default_context it also needs a
123
+ # full non-relative path to the file. Fortunately, that seems to be all
124
+ # Puppet uses. This will set the file's SELinux context to the policy's
125
+ # default context (if any) if it differs from the context currently on
126
+ # the file.
127
+ def set_selinux_default_context(file)
128
+ new_context = get_selinux_default_context(file)
129
+ unless new_context
130
+ return nil
131
+ end
132
+ cur_context = get_selinux_current_context(file)
133
+ if new_context != cur_context
134
+ set_selinux_context(file, new_context)
135
+ return new_context
136
+ end
137
+ return nil
138
+ end
139
+ end