puppet 0.25.1 → 0.25.2

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 (198) hide show
  1. data/CHANGELOG +159 -135
  2. data/Rakefile +4 -1
  3. data/conf/gentoo/conf.d/puppetmaster +1 -1
  4. data/conf/osx/createpackage.sh +12 -0
  5. data/conf/osx/preflight +4 -0
  6. data/conf/redhat/puppet.spec +12 -2
  7. data/conf/redhat/server.init +1 -0
  8. data/conf/redhat/server.sysconfig +1 -1
  9. data/ext/ldap/puppet.schema +5 -9
  10. data/ext/puppetlast +2 -1
  11. data/ext/rack/README +2 -2
  12. data/ext/regexp_nodes/classes/databases +2 -0
  13. data/ext/regexp_nodes/classes/webservers +2 -0
  14. data/ext/regexp_nodes/parameters/environment/prod +1 -0
  15. data/ext/regexp_nodes/parameters/environment/qa +3 -0
  16. data/ext/regexp_nodes/regexp_nodes.rb +215 -0
  17. data/lib/puppet.rb +1 -1
  18. data/lib/puppet/agent.rb +2 -2
  19. data/lib/puppet/application/puppet.rb +1 -1
  20. data/lib/puppet/application/puppetd.rb +1 -1
  21. data/lib/puppet/application/puppetdoc.rb +4 -3
  22. data/lib/puppet/application/puppetrun.rb +5 -14
  23. data/lib/puppet/application/ralsh.rb +9 -25
  24. data/lib/puppet/configurer.rb +2 -1
  25. data/lib/puppet/configurer/fact_handler.rb +8 -6
  26. data/lib/puppet/daemon.rb +2 -2
  27. data/lib/puppet/defaults.rb +21 -2
  28. data/lib/puppet/external/pson/common.rb +1 -1
  29. data/lib/puppet/external/pson/pure.rb +3 -3
  30. data/lib/puppet/feature/base.rb +3 -0
  31. data/lib/puppet/feature/selinux.rb +3 -0
  32. data/lib/puppet/feature/zlib.rb +6 -0
  33. data/lib/puppet/file_serving/base.rb +16 -1
  34. data/lib/puppet/file_serving/metadata.rb +46 -9
  35. data/lib/puppet/file_serving/mount/file.rb +4 -1
  36. data/lib/puppet/indirector/catalog/active_record.rb +5 -0
  37. data/lib/puppet/indirector/envelope.rb +1 -3
  38. data/lib/puppet/indirector/indirection.rb +13 -16
  39. data/lib/puppet/indirector/node/ldap.rb +7 -4
  40. data/lib/puppet/indirector/ssl_file.rb +1 -1
  41. data/lib/puppet/network/authstore.rb +48 -118
  42. data/lib/puppet/network/client/resource.rb +2 -15
  43. data/lib/puppet/network/format.rb +2 -12
  44. data/lib/puppet/network/format_handler.rb +15 -1
  45. data/lib/puppet/network/formats.rb +19 -4
  46. data/lib/puppet/network/handler/fileserver.rb +1 -0
  47. data/lib/puppet/network/http/handler.rb +1 -0
  48. data/lib/puppet/network/http/rack/httphandler.rb +0 -18
  49. data/lib/puppet/network/http/rack/rest.rb +4 -4
  50. data/lib/puppet/network/http/rack/xmlrpc.rb +4 -4
  51. data/lib/puppet/network/http/webrick.rb +2 -1
  52. data/lib/puppet/network/server.rb +1 -1
  53. data/lib/puppet/node/environment.rb +20 -9
  54. data/lib/puppet/parameter.rb +17 -1
  55. data/lib/puppet/parser/ast/boolean_operator.rb +2 -2
  56. data/lib/puppet/parser/ast/leaf.rb +5 -1
  57. data/lib/puppet/parser/ast/resourceparam.rb +4 -0
  58. data/lib/puppet/parser/ast/selector.rb +4 -0
  59. data/lib/puppet/parser/functions/generate.rb +2 -2
  60. data/lib/puppet/parser/functions/shellquote.rb +1 -1
  61. data/lib/puppet/property.rb +3 -11
  62. data/lib/puppet/provider/cron/crontab.rb +2 -0
  63. data/lib/puppet/provider/host/parsed.rb +9 -9
  64. data/lib/puppet/provider/package/blastwave.rb +7 -6
  65. data/lib/puppet/provider/package/portage.rb +23 -27
  66. data/lib/puppet/provider/package/rug.rb +1 -1
  67. data/lib/puppet/provider/package/sun.rb +5 -3
  68. data/lib/puppet/provider/service/daemontools.rb +1 -1
  69. data/lib/puppet/provider/service/debian.rb +1 -1
  70. data/lib/puppet/provider/service/runit.rb +1 -1
  71. data/lib/puppet/provider/ssh_authorized_key/parsed.rb +2 -1
  72. data/lib/puppet/provider/sshkey/parsed.rb +3 -5
  73. data/lib/puppet/provider/zone/solaris.rb +1 -1
  74. data/lib/puppet/rails.rb +9 -2
  75. data/lib/puppet/rails/benchmark.rb +1 -1
  76. data/lib/puppet/rails/host.rb +2 -7
  77. data/lib/puppet/rails/resource.rb +20 -26
  78. data/lib/puppet/resource/catalog.rb +3 -3
  79. data/lib/puppet/resource/reference.rb +13 -25
  80. data/lib/puppet/ssl/certificate.rb +3 -2
  81. data/lib/puppet/ssl/host.rb +14 -33
  82. data/lib/puppet/sslcertificates.rb +1 -5
  83. data/lib/puppet/sslcertificates/ca.rb +8 -7
  84. data/lib/puppet/transaction.rb +15 -12
  85. data/lib/puppet/type.rb +12 -5
  86. data/lib/puppet/type/file.rb +26 -32
  87. data/lib/puppet/type/file/content.rb +5 -5
  88. data/lib/puppet/type/file/ensure.rb +6 -17
  89. data/lib/puppet/type/file/mode.rb +18 -1
  90. data/lib/puppet/type/file/source.rb +12 -12
  91. data/lib/puppet/type/host.rb +6 -9
  92. data/lib/puppet/type/k5login.rb +1 -1
  93. data/lib/puppet/type/maillist.rb +4 -7
  94. data/lib/puppet/type/port.rb +6 -5
  95. data/lib/puppet/type/resources.rb +12 -12
  96. data/lib/puppet/type/sshkey.rb +5 -5
  97. data/lib/puppet/type/tidy.rb +9 -2
  98. data/lib/puppet/type/yumrepo.rb +3 -1
  99. data/lib/puppet/util.rb +64 -56
  100. data/lib/puppet/util/backups.rb +2 -1
  101. data/lib/puppet/util/filetype.rb +46 -0
  102. data/lib/puppet/util/log.rb +10 -18
  103. data/lib/puppet/util/log_paths.rb +14 -0
  104. data/lib/puppet/util/methodhelper.rb +3 -4
  105. data/lib/puppet/util/monkey_patches.rb +8 -0
  106. data/lib/puppet/util/rdoc/generators/puppet_generator.rb +5 -3
  107. data/lib/puppet/util/rdoc/parser.rb +32 -16
  108. data/lib/puppet/util/reference.rb +6 -3
  109. data/lib/puppet/util/selinux.rb +21 -14
  110. data/lib/puppet/util/settings.rb +30 -25
  111. data/lib/puppet/util/settings/file_setting.rb +7 -4
  112. data/lib/puppet/util/subclass_loader.rb +1 -1
  113. data/lib/puppet/util/suidmanager.rb +11 -1
  114. data/lib/puppet/util/tagging.rb +22 -4
  115. data/man/man8/filebucket.8 +23 -18
  116. data/man/man8/pi.8 +42 -20
  117. data/man/man8/puppet.8 +47 -32
  118. data/man/man8/puppet.conf.8 +807 -764
  119. data/man/man8/puppetca.8 +24 -14
  120. data/man/man8/puppetd.8 +33 -16
  121. data/man/man8/puppetdoc.8 +71 -18
  122. data/man/man8/puppetmasterd.8 +18 -25
  123. data/man/man8/puppetqd.8 +60 -0
  124. data/man/man8/puppetrun.8 +27 -14
  125. data/man/man8/ralsh.8 +33 -40
  126. data/spec/integration/bin/puppetmasterd.rb +3 -2
  127. data/spec/integration/defaults.rb +11 -0
  128. data/spec/integration/file_serving/metadata.rb +1 -0
  129. data/spec/integration/indirector/file_content/file_server.rb +2 -1
  130. data/spec/integration/ssl/certificate_request.rb +2 -0
  131. data/spec/integration/type/file.rb +20 -1
  132. data/spec/shared_behaviours/file_serving.rb +1 -1
  133. data/spec/spec_helper.rb +1 -1
  134. data/spec/unit/application/puppet.rb +11 -30
  135. data/spec/unit/application/puppetd.rb +1 -0
  136. data/spec/unit/application/puppetdoc.rb +13 -4
  137. data/spec/unit/application/puppetmasterd.rb +1 -0
  138. data/spec/unit/application/puppetrun.rb +12 -2
  139. data/spec/unit/application/ralsh.rb +39 -22
  140. data/spec/unit/configurer.rb +6 -0
  141. data/spec/unit/configurer/fact_handler.rb +15 -1
  142. data/spec/unit/file_serving/metadata.rb +128 -16
  143. data/spec/unit/file_serving/mount/file.rb +8 -0
  144. data/spec/unit/indirector/catalog/active_record.rb +20 -1
  145. data/spec/unit/indirector/catalog/compiler.rb +2 -1
  146. data/spec/unit/indirector/indirection.rb +29 -18
  147. data/spec/unit/indirector/node/ldap.rb +20 -6
  148. data/spec/unit/network/authstore.rb +197 -0
  149. data/spec/unit/network/format_handler.rb +28 -8
  150. data/spec/unit/network/formats.rb +31 -0
  151. data/spec/unit/network/http/handler.rb +10 -0
  152. data/spec/unit/network/http/webrick.rb +2 -2
  153. data/spec/unit/network/rest_authconfig.rb +2 -2
  154. data/spec/unit/network/rights.rb +1 -1
  155. data/spec/unit/node/environment.rb +39 -23
  156. data/spec/unit/other/selinux.rb +2 -2
  157. data/spec/unit/parameter.rb +8 -0
  158. data/spec/unit/parser/ast/leaf.rb +9 -0
  159. data/spec/unit/parser/ast/selector.rb +8 -1
  160. data/spec/unit/parser/lexer.rb +1 -1
  161. data/spec/unit/parser/resource.rb +11 -0
  162. data/spec/unit/parser/resource/reference.rb +13 -1
  163. data/spec/unit/property.rb +6 -0
  164. data/spec/unit/provider/mount/parsed.rb +3 -1
  165. data/spec/unit/provider/service/debian.rb +1 -1
  166. data/spec/unit/provider/ssh_authorized_key/parsed.rb +9 -1
  167. data/spec/unit/provider/sshkey/parsed.rb +19 -0
  168. data/spec/unit/rails.rb +22 -9
  169. data/spec/unit/rails/resource.rb +20 -0
  170. data/spec/unit/ssl/host.rb +19 -57
  171. data/spec/unit/transaction.rb +39 -4
  172. data/spec/unit/type.rb +9 -0
  173. data/spec/unit/type/file/content.rb +29 -0
  174. data/spec/unit/type/maillist.rb +42 -0
  175. data/spec/unit/type/resources.rb +66 -1
  176. data/spec/unit/type/tidy.rb +14 -1
  177. data/spec/unit/util/autoload.rb +2 -0
  178. data/spec/unit/util/ldap/connection.rb +1 -1
  179. data/spec/unit/util/log.rb +14 -0
  180. data/spec/unit/util/monkey_patches.rb +103 -0
  181. data/spec/unit/util/queue.rb +10 -2
  182. data/spec/unit/util/selinux.rb +61 -2
  183. data/spec/unit/util/settings.rb +19 -0
  184. data/spec/unit/util/settings/file_setting.rb +25 -0
  185. data/spec/unit/util/tagging.rb +10 -0
  186. data/tasks/rake/changelog.rake +15 -0
  187. data/tasks/rake/ci.rake +22 -0
  188. data/tasks/rake/dailybuild.rake +9 -0
  189. data/tasks/rake/gem.rake +46 -0
  190. data/tasks/rake/git_workflow.rake +121 -0
  191. data/tasks/rake/metrics.rake +6 -0
  192. data/tasks/rake/sign.rake +14 -0
  193. data/tasks/rake/testbranch.rake +16 -0
  194. data/tasks/rake/tracdocs.rake +8 -0
  195. data/test/data/providers/ssh_authorized_key/parsed/authorized_keys +1 -0
  196. metadata +1042 -1288
  197. data/ext/bin/sleeper +0 -67
  198. data/ext/module_puppet +0 -209
@@ -13,12 +13,11 @@ module Puppet
13
13
 
14
14
  end
15
15
 
16
- newproperty(:alias) do
17
- desc "Any alias the host might have. Multiple values must be
18
- specified as an array. Note that this state has the same name
19
- as one of the metaparams; using this state to set aliases will
20
- make those aliases available in your Puppet scripts and also on
21
- disk."
16
+ newproperty(:host_aliases) do
17
+ desc 'Any aliases the host might have. Multiple values must be
18
+ specified as an array. Note that this property is not the same as
19
+ the "alias" metaparam; use this property to add aliases to a host
20
+ on disk, and "alias" to aliases for use in your Puppet scripts.'
22
21
 
23
22
  def insync?(is)
24
23
  is == @should
@@ -63,9 +62,7 @@ module Puppet
63
62
  end
64
63
 
65
64
  validate do |value|
66
- if value =~ /\s/
67
- raise Puppet::Error, "Aliases cannot include whitespace"
68
- end
65
+ raise Puppet::Error, "Host aliases cannot include whitespace" if value =~ /\s/
69
66
  end
70
67
  end
71
68
 
@@ -56,7 +56,7 @@ Puppet::Type.newtype(:k5login) do
56
56
  end
57
57
 
58
58
  # Return the principals
59
- def principals
59
+ def principals(dummy_argument=:work_arround_for_ruby_GC_bug)
60
60
  if File.exists?(@resource[:name])
61
61
  File.readlines(@resource[:name]).collect { |line| line.chomp }
62
62
  else
@@ -42,13 +42,10 @@ module Puppet
42
42
  should = :absent
43
43
  end
44
44
  atype = Puppet::Type.type(:mailalias)
45
- return provider.aliases.collect do |name, recipient|
46
- if atype[name]
47
- nil
48
- else
49
- malias = Puppet::Type.type(:mailalias).new(:name => name, :recipient => recipient, :ensure => should)
50
- end
51
- end.compact
45
+
46
+ provider.aliases.
47
+ reject { |name,recipient| catalog.resource(:mailalias, name) }.
48
+ collect { |name,recipient| atype.new(:name => name, :recipient => recipient, :ensure => should) }
52
49
  end
53
50
  end
54
51
  end
@@ -57,11 +57,12 @@
57
57
  # desc "The port description."
58
58
  # end
59
59
  #
60
- # newproperty(:alias) do
61
- # desc "Any aliases the port might have. Multiple values must be
62
- # specified as an array. Note that this property has the same name as
63
- # one of the metaparams; using this property to set aliases will make
64
- # those aliases available in your Puppet scripts and also on disk."
60
+ # newproperty(:port_aliases) do
61
+ # desc 'Any aliases the port might have. Multiple values must be
62
+ # specified as an array. Note that this property is not the same as
63
+ # the "alias" metaparam; use this property to add aliases to a port
64
+ # in the services file, and "alias" to aliases for use in your Puppet
65
+ # scripts.'
65
66
  #
66
67
  # # We actually want to return the whole array here, not just the first
67
68
  # # value.
@@ -99,18 +99,18 @@ Puppet::Type.newtype(:resources) do
99
99
  def generate
100
100
  return [] unless self.purge?
101
101
  resource_type.instances.
102
- reject { |r| managed? }.
103
- reject { |r| catalog.resources.include? r.ref }.
104
- select { |r| check(r) }.
105
- select { |r| able_to_ensure_absent?(r) }.
106
- each { |resource|
107
- @parameters.each do |name, param|
108
- resource[name] = param.value if param.metaparam?
109
- end
110
-
111
- # Mark that we're purging, so transactions can handle relationships
112
- # correctly
113
- resource.purging
102
+ reject { |r| catalog.resources.include? r.ref }.
103
+ select { |r| check(r) }.
104
+ select { |r| r.class.validproperty?(:ensure) }.
105
+ select { |r| able_to_ensure_absent?(r) }.
106
+ each { |resource|
107
+ @parameters.each do |name, param|
108
+ resource[name] = param.value if param.metaparam?
109
+ end
110
+
111
+ # Mark that we're purging, so transactions can handle relationships
112
+ # correctly
113
+ resource.purging
114
114
  }
115
115
  end
116
116
 
@@ -21,11 +21,11 @@ module Puppet
21
21
 
22
22
  # FIXME This should automagically check for aliases to the hosts, just
23
23
  # to see if we can automatically glean any aliases.
24
- newproperty(:alias) do
25
- desc "Any alias the host might have. Multiple values must be
26
- specified as an array. Note that this parameter has the same name
27
- as one of the metaparams; using this parameter to set aliases will
28
- make those aliases available in your Puppet scripts."
24
+ newproperty(:host_aliases) do
25
+ desc 'Any aliases the host might have. Multiple values must be
26
+ specified as an array. Note that this property is not the same as
27
+ the "alias" metaparam; use this property to add aliases to a host
28
+ on disk, and "alias" to aliases for use in your Puppet scripts.'
29
29
 
30
30
  attr_accessor :meta
31
31
 
@@ -247,8 +247,15 @@ Puppet::Type.newtype(:tidy) do
247
247
  def generate
248
248
  return [] unless stat(self[:path])
249
249
 
250
- if self[:recurse]
251
- files = Puppet::FileServing::Fileset.new(self[:path], :recurse => self[:recurse]).files.collect do |f|
250
+ case self[:recurse]
251
+ when Integer, Fixnum, Bignum, /^\d+$/
252
+ parameter = { :recurse => true, :recurselimit => self[:recurse] }
253
+ when true, :true, :inf
254
+ parameter = { :recurse => true }
255
+ end
256
+
257
+ if parameter
258
+ files = Puppet::FileServing::Fileset.new(self[:path], parameter).files.collect do |f|
252
259
  f == "." ? self[:path] : File.join(self[:path], f)
253
260
  end
254
261
  else
@@ -233,12 +233,14 @@ module Puppet
233
233
  end
234
234
 
235
235
  newparam(:name) do
236
- desc "The name of the repository."
236
+ desc "The name of the repository. This corresponds to the
237
+ repositoryid parameter in yum.conf(5)."
237
238
  isnamevar
238
239
  end
239
240
 
240
241
  newproperty(:descr, :parent => Puppet::IniProperty) do
241
242
  desc "A human readable description of the repository.
243
+ This corresponds to the name parameter in yum.conf(5).
242
244
  #{ABSENT_DOC}"
243
245
  newvalue(:absent) { self.should = :absent }
244
246
  newvalue(/.*/) { }
@@ -55,10 +55,11 @@ module Util
55
55
  end
56
56
  unless Puppet::Util::SUIDManager.uid == user
57
57
  begin
58
+ Puppet::Util::SUIDManager.initgroups(user)
58
59
  Puppet::Util::SUIDManager.uid = user
59
60
  Puppet::Util::SUIDManager.euid = user
60
- rescue
61
- $stderr.puts "could not change to user %s" % user
61
+ rescue => detail
62
+ $stderr.puts "Could not change to user %s: %s" % [user, detail]
62
63
  exit(74)
63
64
  end
64
65
  end
@@ -258,39 +259,56 @@ module Util
258
259
  @@os ||= Facter.value(:operatingsystem)
259
260
  output = nil
260
261
  child_pid, child_status = nil
261
- # There are problems with read blocking with badly behaved children
262
- # read.partialread doesn't seem to capture either stdout or stderr
263
- # We hack around this using a temporary file
264
-
265
- # The idea here is to avoid IO#read whenever possible.
266
- output_file="/dev/null"
267
- error_file="/dev/null"
268
- if ! arguments[:squelch]
269
- require "tempfile"
270
- output_file = Tempfile.new("puppet")
271
- if arguments[:combine]
272
- error_file=output_file
273
- end
274
- end
262
+ output_read, output_write = IO.pipe
275
263
 
276
264
  oldverb = $VERBOSE
277
265
  $VERBOSE = nil
278
266
  child_pid = Kernel.fork
279
267
  $VERBOSE = oldverb
280
268
  if child_pid
269
+ output_write.close
270
+
271
+ # Read output in if required
272
+ if ! arguments[:squelch]
273
+ output = ''
274
+ begin
275
+ loop do
276
+ output << output_read.readpartial(4096)
277
+ end
278
+ rescue EOFError
279
+ # End of file
280
+ ensure
281
+ output_read.close
282
+ end
283
+ end
284
+
281
285
  # Parent process executes this
282
- child_status = (Process.waitpid2(child_pid)[1]).to_i >> 8
286
+ Process.waitpid(child_pid)
287
+ child_status = $?.exitstatus
283
288
  else
284
289
  # Child process executes this
285
290
  Process.setsid
286
291
  begin
292
+ output_read.close
293
+
294
+ if arguments[:squelch]
295
+ output_write.close
296
+ $stdout.reopen('/dev/null', 'w')
297
+ $stderr.reopen('/dev/null', 'w')
298
+ else
299
+ $stdout.reopen(output_write)
300
+ if arguments[:combine]
301
+ $stderr.reopen(output_write)
302
+ else
303
+ $stderr.reopen('/dev/null', 'w')
304
+ end
305
+ end
306
+
287
307
  if arguments[:stdinfile]
288
308
  $stdin.reopen(arguments[:stdinfile])
289
309
  else
290
- $stdin.reopen("/dev/null")
310
+ $stdin.close
291
311
  end
292
- $stdout.reopen(output_file)
293
- $stderr.reopen(error_file)
294
312
 
295
313
  3.upto(256){|fd| IO::new(fd).close rescue nil}
296
314
  if arguments[:gid]
@@ -302,42 +320,10 @@ module Util
302
320
  Process.uid = arguments[:uid] unless @@os == "Darwin"
303
321
  end
304
322
  ENV['LANG'] = ENV['LC_ALL'] = ENV['LC_MESSAGES'] = ENV['LANGUAGE'] = 'C'
305
- if command.is_a?(Array)
306
- Kernel.exec(*command)
307
- else
308
- Kernel.exec(command)
309
- end
323
+ Kernel.exec(*command)
310
324
  rescue => detail
311
- puts detail.to_s
312
- exit!(1)
313
- end # begin; rescue
314
- end # if child_pid
315
-
316
- # read output in if required
317
- if ! arguments[:squelch]
318
-
319
- # Make sure the file's actually there. This is
320
- # basically a race condition, and is probably a horrible
321
- # way to handle it, but, well, oh well.
322
- unless FileTest.exists?(output_file.path)
323
- Puppet.warning "sleeping"
324
- sleep 0.5
325
- unless FileTest.exists?(output_file.path)
326
- Puppet.warning "sleeping 2"
327
- sleep 1
328
- unless FileTest.exists?(output_file.path)
329
- Puppet.warning "Could not get output"
330
- output = ""
331
- end
332
- end
333
- end
334
- unless output
335
- # We have to explicitly open here, so that it reopens
336
- # after the child writes.
337
- output = output_file.open.read
338
-
339
- # The 'true' causes the file to get unlinked right away.
340
- output_file.close(true)
325
+ puts detail
326
+ exit(1)
341
327
  end
342
328
  end
343
329
 
@@ -347,7 +333,7 @@ module Util
347
333
  end
348
334
  end
349
335
 
350
- return output
336
+ output
351
337
  end
352
338
 
353
339
  module_function :execute
@@ -421,6 +407,28 @@ module Util
421
407
  end
422
408
 
423
409
  module_function :memory, :thinmark
410
+
411
+ def secure_open(file,must_be_w,&block)
412
+ raise Puppet::DevError,"secure_open only works with mode 'w'" unless must_be_w == 'w'
413
+ raise Puppet::DevError,"secure_open only requires a block" unless block_given?
414
+ Puppet.warning "#{file} was a symlink to #{File.readlink(file)}" if File.symlink?(file)
415
+ if File.exists?(file) or File.symlink?(file)
416
+ wait = File.symlink?(file) ? 5.0 : 0.1
417
+ File.delete(file)
418
+ sleep wait # give it a chance to reappear, just in case someone is actively trying something.
419
+ end
420
+ begin
421
+ File.open(file,File::CREAT|File::EXCL|File::TRUNC|File::WRONLY,&block)
422
+ rescue Errno::EEXIST
423
+ desc = File.symlink?(file) ? "symlink to #{File.readlink(file)}" : File.stat(file).ftype
424
+ puts "Warning: #{file} was apparently created by another process (as"
425
+ puts "a #{desc}) as soon as it was deleted by this process. Someone may be trying"
426
+ puts "to do something objectionable (such as tricking you into overwriting system"
427
+ puts "files if you are running as root)."
428
+ raise
429
+ end
430
+ end
431
+ module_function :secure_open
424
432
  end
425
433
  end
426
434
 
@@ -26,8 +26,9 @@ module Puppet::Util::Backups
26
26
  info "Recursively backing up to filebucket"
27
27
  Find.find(self[:path]) { |f| backup_file_with_filebucket(f) if File.file?(f) }
28
28
  when "file"; backup_file_with_filebucket(file)
29
- when "link"; return true
29
+ when "link";
30
30
  end
31
+ true
31
32
  end
32
33
 
33
34
  def perform_backup_with_backuplocal(fileobj, backup)
@@ -251,4 +251,50 @@ class Puppet::Util::FileType
251
251
  output_file.delete
252
252
  end
253
253
  end
254
+
255
+ # Support for AIX crontab with output different than suntab's crontab command.
256
+ newfiletype(:aixtab) do
257
+ # Read a specific @path's cron tab.
258
+ def read
259
+ begin
260
+ output = Puppet::Util.execute(%w{crontab -l}, :uid => @path)
261
+ if output.include?("You are not authorized to use the cron command")
262
+ raise Puppet::Error, "User %s not authorized to use cron" % @path
263
+ end
264
+ return output
265
+ rescue => detail
266
+ raise Puppet::Error, "Could not read crontab for %s: %s" % [@path, detail]
267
+ end
268
+ end
269
+
270
+ # Remove a specific @path's cron tab.
271
+ def remove
272
+ begin
273
+ Puppet::Util.execute(%w{crontab -r}, :uid => @path)
274
+ rescue => detail
275
+ raise Puppet::Error, "Could not remove crontab for %s: %s" % [@path, detail]
276
+ end
277
+ end
278
+
279
+ # Overwrite a specific @path's cron tab; must be passed the @path name
280
+ # and the text with which to create the cron tab.
281
+ def write(text)
282
+ require "tempfile"
283
+ output_file = Tempfile.new("puppet")
284
+ fh = output_file.open
285
+ fh.print text
286
+ fh.close
287
+
288
+ # We have to chown the stupid file to the user.
289
+ File.chown(Puppet::Util.uid(@path), nil, output_file.path)
290
+
291
+ begin
292
+ Puppet::Util.execute(["crontab", output_file.path], :uid => @path)
293
+ rescue => detail
294
+ raise Puppet::Error, "Could not write crontab for %s: %s" % [@path, detail]
295
+ ensure
296
+ output_file.delete
297
+ end
298
+ end
299
+ end
254
300
  end
@@ -511,11 +511,16 @@ class Puppet::Util::Log
511
511
  # If they pass a source in to us, we make sure it is a string, and
512
512
  # we retrieve any tags we can.
513
513
  def source=(source)
514
- # We can't store the actual source, we just store the path.
515
- # We can't just check for whether it responds to :path, because
516
- # plenty of providers respond to that in their normal function.
517
- if (source.is_a?(Puppet::Type) or source.is_a?(Puppet::Parameter)) and source.respond_to?(:path)
518
- set_source_from_ral(source)
514
+ if source.respond_to?(:source_descriptors)
515
+ descriptors = source.source_descriptors
516
+ @source = descriptors[:path]
517
+
518
+ descriptors[:tags].each { |t| tag(t) }
519
+
520
+ [:file, :line, :version].each do |param|
521
+ next unless descriptors[param]
522
+ send(param.to_s + "=", descriptors[param])
523
+ end
519
524
  else
520
525
  @source = source.to_s
521
526
  end
@@ -528,19 +533,6 @@ class Puppet::Util::Log
528
533
  def to_s
529
534
  return @message
530
535
  end
531
-
532
- private
533
-
534
- def set_source_from_ral(source)
535
- @source = source.path
536
-
537
- source.tags.each { |t| tag(t) }
538
-
539
- [:file, :line, :version].each do |param|
540
- next unless value = source.send(param)
541
- send(param.to_s + "=", value)
542
- end
543
- end
544
536
  end
545
537
 
546
538
  # This is for backward compatibility from when we changed the constant to Puppet::Util::Log
@@ -11,5 +11,19 @@ module Puppet::Util::LogPaths
11
11
 
12
12
  return "/" + @path.join("/")
13
13
  end
14
+
15
+ def source_descriptors
16
+ descriptors = {}
17
+
18
+ descriptors[:tags] = tags
19
+
20
+ [:path, :file, :line, :version].each do |param|
21
+ next unless value = send(param)
22
+ descriptors[param] = value
23
+ end
24
+
25
+ return descriptors
26
+ end
27
+
14
28
  end
15
29