puppet 2.7.18 → 2.7.19
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.
- data/CHANGELOG +82 -0
- data/CONTRIBUTING.md +114 -171
- data/README.md +8 -0
- data/README_DEVELOPER.md +38 -3
- data/Rakefile +19 -3
- data/conf/osx/createpackage.sh +3 -1
- data/conf/redhat/logrotate +1 -1
- data/conf/redhat/puppet.spec +35 -8
- data/lib/puppet.rb +1 -1
- data/lib/puppet/application/agent.rb +2 -0
- data/lib/puppet/application/master.rb +2 -0
- data/lib/puppet/configurer.rb +2 -3
- data/lib/puppet/defaults.rb +6 -5
- data/lib/puppet/face/module/install.rb +2 -1
- data/lib/puppet/file_bucket/dipper.rb +1 -1
- data/lib/puppet/indirector/file_content.rb +2 -2
- data/lib/puppet/indirector/file_metadata.rb +2 -2
- data/lib/puppet/indirector/indirection.rb +3 -4
- data/lib/puppet/indirector/rest.rb +12 -6
- data/lib/puppet/interface/action_manager.rb +1 -2
- data/lib/puppet/module_tool/applications/unpacker.rb +22 -3
- data/lib/puppet/network/handler/fileserver.rb +2 -2
- data/lib/puppet/parser/ast/resource.rb +9 -2
- data/lib/puppet/parser/functions/fqdn_rand.rb +2 -1
- data/lib/puppet/parser/functions/md5.rb +2 -2
- data/lib/puppet/parser/functions/sha1.rb +2 -2
- data/lib/puppet/parser/functions/template.rb +0 -2
- data/lib/puppet/parser/type_loader.rb +1 -2
- data/lib/puppet/provider/augeas/augeas.rb +19 -1
- data/lib/puppet/provider/confine.rb +1 -1
- data/lib/puppet/provider/package/msi.rb +97 -51
- data/lib/puppet/provider/scheduled_task/win32_taskscheduler.rb +1 -0
- data/lib/puppet/provider/service/gentoo.rb +0 -2
- data/lib/puppet/provider/service/openrc.rb +69 -0
- data/lib/puppet/provider/service/windows.rb +6 -4
- data/lib/puppet/provider/user/aix.rb +8 -4
- data/lib/puppet/provider/user/useradd.rb +6 -0
- data/lib/puppet/rails/benchmark.rb +2 -2
- data/lib/puppet/reports/store.rb +9 -9
- data/lib/puppet/resource/catalog.rb +2 -1
- data/lib/puppet/resource/type_collection.rb +2 -1
- data/lib/puppet/ssl/base.rb +1 -2
- data/lib/puppet/ssl/certificate_authority/interface.rb +1 -0
- data/lib/puppet/test/test_helper.rb +2 -1
- data/lib/puppet/type.rb +1 -1
- data/lib/puppet/type/augeas.rb +1 -1
- data/lib/puppet/type/file.rb +4 -2
- data/lib/puppet/type/scheduled_task.rb +8 -10
- data/lib/puppet/type/tidy.rb +1 -1
- data/lib/puppet/util.rb +63 -25
- data/lib/puppet/util/autoload.rb +6 -4
- data/lib/puppet/util/checksums.rb +3 -8
- data/lib/puppet/util/diff.rb +2 -1
- data/lib/puppet/util/filetype.rb +1 -3
- data/lib/puppet/util/run_mode.rb +2 -1
- data/lib/puppet/util/suidmanager.rb +1 -1
- data/lib/puppet/util/windows.rb +1 -0
- data/lib/puppet/util/windows/file.rb +27 -0
- data/lib/puppet/util/windows/user.rb +1 -2
- data/man/man8/puppet-agent.8 +4 -0
- data/man/man8/puppet-master.8 +4 -0
- data/man/man8/puppetmasterd.8 +4 -0
- data/spec/fixtures/unit/provider/augeas/augeas/augeas/lenses/test.aug +13 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/fstab +10 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/hosts +6 -0
- data/spec/fixtures/unit/provider/augeas/augeas/etc/test +3 -0
- data/spec/fixtures/unit/provider/augeas/augeas/test.aug +13 -0
- data/spec/fixtures/unit/provider/service/openrc/rcservice_list +8 -0
- data/spec/fixtures/unit/provider/service/openrc/rcstatus +43 -0
- data/spec/integration/defaults_spec.rb +3 -3
- data/spec/integration/network/server/mongrel_spec.rb +8 -6
- data/spec/integration/parser/parser_spec.rb +1 -1
- data/spec/integration/type/file_spec.rb +49 -12
- data/spec/lib/puppet_spec/database.rb +5 -3
- data/spec/lib/puppet_spec/files.rb +2 -1
- data/spec/monkey_patches/alias_should_to_must.rb +15 -2
- data/spec/shared_behaviours/file_serving_model.rb +9 -6
- data/spec/shared_behaviours/path_parameters.rb +5 -5
- data/spec/shared_behaviours/things_that_declare_options.rb +5 -5
- data/spec/unit/application/facts_spec.rb +1 -1
- data/spec/unit/application_spec.rb +10 -8
- data/spec/unit/configurer_spec.rb +11 -2
- data/spec/unit/face/ca_spec.rb +15 -15
- data/spec/unit/face/help_spec.rb +5 -5
- data/spec/unit/face/module/install_spec.rb +13 -2
- data/spec/unit/face/node_spec.rb +7 -6
- data/spec/unit/indirector/certificate_request/ca_spec.rb +1 -1
- data/spec/unit/indirector/envelope_spec.rb +0 -13
- data/spec/unit/indirector/facts/inventory_service_spec.rb +1 -1
- data/spec/unit/indirector/queue_spec.rb +3 -3
- data/spec/unit/indirector/rest_spec.rb +31 -20
- data/spec/unit/indirector_spec.rb +5 -5
- data/spec/unit/interface/action_builder_spec.rb +3 -2
- data/spec/unit/interface/action_manager_spec.rb +1 -1
- data/spec/unit/interface/action_spec.rb +4 -3
- data/spec/unit/interface/face_collection_spec.rb +1 -1
- data/spec/unit/interface/option_spec.rb +13 -9
- data/spec/unit/interface_spec.rb +5 -5
- data/spec/unit/module_tool/applications/unpacker_spec.rb +61 -0
- data/spec/unit/network/handler/fileserver_spec.rb +3 -3
- data/spec/unit/other/transbucket_spec.rb +6 -9
- data/spec/unit/parser/ast/resource_spec.rb +27 -0
- data/spec/unit/parser/functions/create_resources_spec.rb +12 -12
- data/spec/unit/parser/lexer_spec.rb +5 -5
- data/spec/unit/provider/augeas/augeas_spec.rb +78 -0
- data/spec/unit/provider/nameservice/directoryservice_spec.rb +6 -6
- data/spec/unit/provider/package/freebsd_spec.rb +2 -2
- data/spec/unit/provider/package/msi_spec.rb +181 -114
- data/spec/unit/provider/package/openbsd_spec.rb +1 -0
- data/spec/unit/provider/package/pkgdmg_spec.rb +3 -3
- data/spec/unit/provider/scheduled_task/win32_taskscheduler_spec.rb +1 -1
- data/spec/unit/provider/service/openrc_spec.rb +209 -0
- data/spec/unit/provider/service/windows_spec.rb +57 -59
- data/spec/unit/provider/user/useradd_spec.rb +7 -0
- data/spec/unit/reports/store_spec.rb +13 -13
- data/spec/unit/resource/catalog_spec.rb +29 -24
- data/spec/unit/resource_spec.rb +13 -13
- data/spec/unit/simple_graph_spec.rb +12 -12
- data/spec/unit/ssl/certificate_authority/interface_spec.rb +3 -3
- data/spec/unit/ssl/certificate_authority_spec.rb +11 -10
- data/spec/unit/transaction_spec.rb +3 -3
- data/spec/unit/type/cron_spec.rb +171 -171
- data/spec/unit/type/exec_spec.rb +29 -27
- data/spec/unit/type/file_spec.rb +22 -13
- data/spec/unit/type/interface_spec.rb +1 -1
- data/spec/unit/type/scheduled_task_spec.rb +15 -14
- data/spec/unit/type/tidy_spec.rb +2 -2
- data/spec/unit/type/user_spec.rb +15 -15
- data/spec/unit/type/vlan_spec.rb +1 -1
- data/spec/unit/type_spec.rb +22 -25
- data/spec/unit/util/autoload_spec.rb +13 -7
- data/spec/unit/util/backups_spec.rb +36 -67
- data/spec/unit/util/storage_spec.rb +2 -9
- data/spec/unit/util/suidmanager_spec.rb +1 -1
- data/spec/unit/util_spec.rb +20 -28
- data/test/ral/manager/attributes.rb +1 -1
- metadata +1553 -1542
@@ -400,7 +400,8 @@ class Puppet::Resource::Catalog < Puppet::SimpleGraph
|
|
400
400
|
# references to the resource instances.
|
401
401
|
def remove_resource(*resources)
|
402
402
|
resources.each do |resource|
|
403
|
-
|
403
|
+
title_key = title_key_for_ref(resource.ref)
|
404
|
+
@resource_table.delete(title_key)
|
404
405
|
if aliases = @aliases[resource.ref]
|
405
406
|
aliases.each { |res_alias| @resource_table.delete(res_alias) }
|
406
407
|
@aliases.delete(resource.ref)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'puppet/parser/type_loader'
|
2
|
+
|
1
3
|
class Puppet::Resource::TypeCollection
|
2
4
|
attr_reader :environment
|
3
5
|
attr_accessor :parse_failed
|
@@ -68,7 +70,6 @@ class Puppet::Resource::TypeCollection
|
|
68
70
|
end
|
69
71
|
|
70
72
|
def loader
|
71
|
-
require 'puppet/parser/type_loader'
|
72
73
|
@loader ||= Puppet::Parser::TypeLoader.new(environment)
|
73
74
|
end
|
74
75
|
|
data/lib/puppet/ssl/base.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'openssl/digest'
|
1
2
|
require 'puppet/ssl'
|
2
3
|
|
3
4
|
# The base class for wrapping SSL instances.
|
@@ -63,8 +64,6 @@ class Puppet::SSL::Base
|
|
63
64
|
end
|
64
65
|
|
65
66
|
def fingerprint(md = :MD5)
|
66
|
-
require 'openssl/digest'
|
67
|
-
|
68
67
|
# ruby 1.8.x openssl digest constants are string
|
69
68
|
# but in 1.9.x they are symbols
|
70
69
|
mds = md.to_s.upcase
|
@@ -79,6 +79,7 @@ module Puppet::Test
|
|
79
79
|
Puppet[:req_bits] = 512
|
80
80
|
Puppet[:keylength] = 512
|
81
81
|
|
82
|
+
Puppet.clear_deprecation_warnings
|
82
83
|
end
|
83
84
|
|
84
85
|
# Call this method once per test, after execution of each individual test.
|
@@ -135,4 +136,4 @@ module Puppet::Test
|
|
135
136
|
end
|
136
137
|
private_class_method :clear_settings_after_each
|
137
138
|
end
|
138
|
-
end
|
139
|
+
end
|
data/lib/puppet/type.rb
CHANGED
@@ -503,7 +503,7 @@ class Type
|
|
503
503
|
|
504
504
|
if provider and ! provider.class.supports_parameter?(klass)
|
505
505
|
missing = klass.required_features.find_all { |f| ! provider.class.feature?(f) }
|
506
|
-
|
506
|
+
debug "Provider %s does not support features %s; not managing attribute %s" % [provider.class.name, missing.join(", "), name]
|
507
507
|
return nil
|
508
508
|
end
|
509
509
|
|
data/lib/puppet/type/augeas.rb
CHANGED
@@ -149,7 +149,7 @@ Puppet::Type.newtype(:augeas) do
|
|
149
149
|
end
|
150
150
|
|
151
151
|
newparam(:load_path) do
|
152
|
-
desc "Optional colon-separated list of directories; these directories are searched for schema definitions."
|
152
|
+
desc "Optional colon-separated list or array of directories; these directories are searched for schema definitions. The agent's `$libdir/augeas/lenses` path will always be added to support pluginsync."
|
153
153
|
defaultto ""
|
154
154
|
end
|
155
155
|
|
data/lib/puppet/type/file.rb
CHANGED
@@ -202,7 +202,7 @@ Puppet::Type.newtype(:file) do
|
|
202
202
|
whose content doesn't match what the `source` or `content` attribute
|
203
203
|
specifies. Setting this to false allows file resources to initialize files
|
204
204
|
without overwriting future changes. Note that this only affects content;
|
205
|
-
Puppet will still manage ownership and permissions."
|
205
|
+
Puppet will still manage ownership and permissions. Defaults to `true`."
|
206
206
|
newvalues(:true, :false)
|
207
207
|
aliasvalue(:yes, :true)
|
208
208
|
aliasvalue(:no, :false)
|
@@ -437,7 +437,7 @@ Puppet::Type.newtype(:file) do
|
|
437
437
|
# from it.
|
438
438
|
unless self[:ensure]
|
439
439
|
if self[:target]
|
440
|
-
self[:ensure] = :
|
440
|
+
self[:ensure] = :link
|
441
441
|
elsif self[:content]
|
442
442
|
self[:ensure] = :file
|
443
443
|
end
|
@@ -724,6 +724,8 @@ Puppet::Type.newtype(:file) do
|
|
724
724
|
::File.send(method, self[:path])
|
725
725
|
rescue Errno::ENOENT => error
|
726
726
|
nil
|
727
|
+
rescue Errno::ENOTDIR => error
|
728
|
+
nil
|
727
729
|
rescue Errno::EACCES => error
|
728
730
|
warning "Could not stat; permission denied"
|
729
731
|
nil
|
@@ -33,6 +33,12 @@ Puppet::Type.newtype(:scheduled_task) do
|
|
33
33
|
validate do |value|
|
34
34
|
raise Puppet::Error.new('Must be specified using an absolute path.') unless absolute_path?(value)
|
35
35
|
end
|
36
|
+
munge do |value|
|
37
|
+
# windows converts slashes to backslashes, so the *is* value
|
38
|
+
# has backslashes. Do the same for the *should* value, so that
|
39
|
+
# we are slash-insensitive. See #13009
|
40
|
+
File.expand_path(value).gsub(/\//, '\\')
|
41
|
+
end
|
36
42
|
end
|
37
43
|
|
38
44
|
newproperty(:working_dir) do
|
@@ -43,9 +49,9 @@ Puppet::Type.newtype(:scheduled_task) do
|
|
43
49
|
end
|
44
50
|
end
|
45
51
|
|
46
|
-
newproperty(:arguments
|
52
|
+
newproperty(:arguments) do
|
47
53
|
desc "Any arguments or flags that should be passed to the command. Multiple arguments
|
48
|
-
|
54
|
+
should be specified as a space-separated string."
|
49
55
|
end
|
50
56
|
|
51
57
|
newproperty(:user) do
|
@@ -157,12 +163,4 @@ Puppet::Type.newtype(:scheduled_task) do
|
|
157
163
|
self.class.format_value_for_display(current_value)
|
158
164
|
end
|
159
165
|
end
|
160
|
-
|
161
|
-
validate do
|
162
|
-
return true if self[:ensure] == :absent
|
163
|
-
|
164
|
-
if self[:arguments] and !(self[:arguments].is_a?(Array) and self[:arguments].length == 1)
|
165
|
-
self.fail('Parameter arguments failed: Must be specified as a single string')
|
166
|
-
end
|
167
|
-
end
|
168
166
|
end
|
data/lib/puppet/type/tidy.rb
CHANGED
data/lib/puppet/util.rb
CHANGED
@@ -9,6 +9,7 @@ require 'sync'
|
|
9
9
|
require 'monitor'
|
10
10
|
require 'tempfile'
|
11
11
|
require 'pathname'
|
12
|
+
require 'ostruct'
|
12
13
|
require 'puppet/util/platform'
|
13
14
|
|
14
15
|
module Puppet
|
@@ -417,11 +418,13 @@ module Util
|
|
417
418
|
# well.
|
418
419
|
2.times do |try|
|
419
420
|
if File.exists?(stdout.path)
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
421
|
+
stdout.open
|
422
|
+
begin
|
423
|
+
return stdout.read
|
424
|
+
ensure
|
425
|
+
stdout.close
|
426
|
+
stdout.unlink
|
427
|
+
end
|
425
428
|
else
|
426
429
|
time_to_sleep = try / 2.0
|
427
430
|
Puppet.warning "Waiting for output; will sleep #{time_to_sleep} seconds"
|
@@ -521,34 +524,31 @@ module Util
|
|
521
524
|
# across.
|
522
525
|
def replace_file(file, default_mode, &block)
|
523
526
|
raise Puppet::DevError, "replace_file requires a block" unless block_given?
|
524
|
-
raise Puppet::DevError, "replace_file is non-functional on Windows" if Puppet.features.microsoft_windows?
|
525
527
|
|
526
528
|
file = Pathname(file)
|
527
529
|
tempfile = Tempfile.new(file.basename.to_s, file.dirname.to_s)
|
528
530
|
|
529
531
|
file_exists = file.exist?
|
530
532
|
|
531
|
-
# If the file exists, use its current mode/owner/group. If it doesn't, use
|
532
|
-
# the supplied mode, and default to current user/group.
|
533
|
-
if file_exists
|
534
|
-
stat = file.lstat
|
535
|
-
|
536
|
-
# We only care about the four lowest-order octets. Higher octets are
|
537
|
-
# filesystem-specific.
|
538
|
-
mode = stat.mode & 07777
|
539
|
-
uid = stat.uid
|
540
|
-
gid = stat.gid
|
541
|
-
else
|
542
|
-
mode = default_mode
|
543
|
-
uid = Process.euid
|
544
|
-
gid = Process.egid
|
545
|
-
end
|
546
|
-
|
547
533
|
# Set properties of the temporary file before we write the content, because
|
548
534
|
# Tempfile doesn't promise to be safe from reading by other people, just
|
549
535
|
# that it avoids races around creating the file.
|
550
|
-
|
551
|
-
|
536
|
+
#
|
537
|
+
# Our Windows emulation is pretty limited, and so we have to carefully
|
538
|
+
# and specifically handle the platform, which has all sorts of magic.
|
539
|
+
# So, unlike Unix, we don't pre-prep security; we use the default "quite
|
540
|
+
# secure" tempfile permissions instead. Magic happens later.
|
541
|
+
unless Puppet.features.microsoft_windows?
|
542
|
+
# Grab the current file mode, and fall back to the defaults.
|
543
|
+
stat = file.lstat rescue OpenStruct.new(:mode => default_mode,
|
544
|
+
:uid => Process.euid,
|
545
|
+
:gid => Process.egid)
|
546
|
+
|
547
|
+
# We only care about the bottom four slots, which make the real mode,
|
548
|
+
# and not the rest of the platform stat call fluff and stuff.
|
549
|
+
tempfile.chmod(stat.mode & 07777)
|
550
|
+
tempfile.chown(stat.uid, stat.gid)
|
551
|
+
end
|
552
552
|
|
553
553
|
# OK, now allow the caller to write the content of the file.
|
554
554
|
yield tempfile
|
@@ -569,7 +569,45 @@ module Util
|
|
569
569
|
|
570
570
|
tempfile.close
|
571
571
|
|
572
|
-
|
572
|
+
if Puppet.features.microsoft_windows?
|
573
|
+
# This will appropriately clone the file, but only if the file we are
|
574
|
+
# replacing exists. Which is kind of annoying; thanks Microsoft.
|
575
|
+
#
|
576
|
+
# So, to avoid getting into an infinite loop we will retry once if the
|
577
|
+
# file doesn't exist, but only the once...
|
578
|
+
have_retried = false
|
579
|
+
|
580
|
+
begin
|
581
|
+
# Yes, the arguments are reversed compared to the rename in the rest
|
582
|
+
# of the world.
|
583
|
+
Puppet::Util::Windows::File.replace_file(file, tempfile.path)
|
584
|
+
rescue Puppet::Util::Windows::Error => e
|
585
|
+
# This might race, but there are enough possible cases that there
|
586
|
+
# isn't a good, solid "better" way to do this, and the next call
|
587
|
+
# should fail in the same way anyhow.
|
588
|
+
raise if have_retried or File.exist?(file)
|
589
|
+
have_retried = true
|
590
|
+
|
591
|
+
# OK, so, we can't replace a file that doesn't exist, so let us put
|
592
|
+
# one in place and set the permissions. Then we can retry and the
|
593
|
+
# magic makes this all work.
|
594
|
+
#
|
595
|
+
# This is the least-worst option for handling Windows, as far as we
|
596
|
+
# can determine.
|
597
|
+
File.open(file, 'a') do |fh|
|
598
|
+
# this space deliberately left empty for auto-close behaviour,
|
599
|
+
# append mode, and not actually changing any of the content.
|
600
|
+
end
|
601
|
+
|
602
|
+
# Set the permissions to what we want.
|
603
|
+
Puppet::Util::Windows::Security.set_mode(default_mode, file.to_s)
|
604
|
+
|
605
|
+
# ...and finally retry the operation.
|
606
|
+
retry
|
607
|
+
end
|
608
|
+
else
|
609
|
+
File.rename(tempfile.path, file)
|
610
|
+
end
|
573
611
|
|
574
612
|
# Ideally, we would now fsync the directory as well, but Ruby doesn't
|
575
613
|
# have support for that, and it doesn't matter /that/ much...
|
data/lib/puppet/util/autoload.rb
CHANGED
@@ -107,8 +107,8 @@ class Puppet::Util::Autoload
|
|
107
107
|
name = File.basename(file).chomp(".rb").intern
|
108
108
|
next if loaded?(name)
|
109
109
|
begin
|
110
|
-
Kernel.require file
|
111
110
|
loaded(name, file)
|
111
|
+
Kernel.require file
|
112
112
|
rescue SystemExit,NoMemoryError
|
113
113
|
raise
|
114
114
|
rescue Exception => detail
|
@@ -128,9 +128,11 @@ class Puppet::Util::Autoload
|
|
128
128
|
end
|
129
129
|
|
130
130
|
def module_directories(env=nil)
|
131
|
-
# We have to require this late in the process because otherwise we might
|
132
|
-
# load order issues.
|
133
|
-
require
|
131
|
+
# We have to require this late in the process because otherwise we might
|
132
|
+
# have load order issues. Since require is much slower than defined?, we
|
133
|
+
# can skip that - and save some 2,155 invocations of require in my real
|
134
|
+
# world testing. --daniel 2012-07-10
|
135
|
+
require 'puppet/node/environment' unless defined?(Puppet::Node::Environment)
|
134
136
|
|
135
137
|
real_env = Puppet::Node::Environment.new(env)
|
136
138
|
|
@@ -1,3 +1,6 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'digest/sha1'
|
3
|
+
|
1
4
|
# A stand-alone module for calculating checksums
|
2
5
|
# in a generic way.
|
3
6
|
module Puppet::Util::Checksums
|
@@ -24,7 +27,6 @@ module Puppet::Util::Checksums
|
|
24
27
|
|
25
28
|
# Calculate a checksum using Digest::MD5.
|
26
29
|
def md5(content)
|
27
|
-
require 'digest/md5'
|
28
30
|
Digest::MD5.hexdigest(content)
|
29
31
|
end
|
30
32
|
|
@@ -35,8 +37,6 @@ module Puppet::Util::Checksums
|
|
35
37
|
|
36
38
|
# Calculate a checksum of a file's content using Digest::MD5.
|
37
39
|
def md5_file(filename, lite = false)
|
38
|
-
require 'digest/md5'
|
39
|
-
|
40
40
|
digest = Digest::MD5.new
|
41
41
|
checksum_file(digest, filename, lite)
|
42
42
|
end
|
@@ -47,7 +47,6 @@ module Puppet::Util::Checksums
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def md5_stream(&block)
|
50
|
-
require 'digest/md5'
|
51
50
|
digest = Digest::MD5.new
|
52
51
|
yield digest
|
53
52
|
digest.hexdigest
|
@@ -74,7 +73,6 @@ module Puppet::Util::Checksums
|
|
74
73
|
|
75
74
|
# Calculate a checksum using Digest::SHA1.
|
76
75
|
def sha1(content)
|
77
|
-
require 'digest/sha1'
|
78
76
|
Digest::SHA1.hexdigest(content)
|
79
77
|
end
|
80
78
|
|
@@ -85,8 +83,6 @@ module Puppet::Util::Checksums
|
|
85
83
|
|
86
84
|
# Calculate a checksum of a file's content using Digest::SHA1.
|
87
85
|
def sha1_file(filename, lite = false)
|
88
|
-
require 'digest/sha1'
|
89
|
-
|
90
86
|
digest = Digest::SHA1.new
|
91
87
|
checksum_file(digest, filename, lite)
|
92
88
|
end
|
@@ -97,7 +93,6 @@ module Puppet::Util::Checksums
|
|
97
93
|
end
|
98
94
|
|
99
95
|
def sha1_stream
|
100
|
-
require 'digest/sha1'
|
101
96
|
digest = Digest::SHA1.new
|
102
97
|
yield digest
|
103
98
|
digest.hexdigest
|
data/lib/puppet/util/diff.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
1
3
|
# Provide a diff between two strings.
|
2
4
|
module Puppet::Util::Diff
|
3
5
|
include Puppet::Util
|
@@ -64,7 +66,6 @@ module Puppet::Util::Diff
|
|
64
66
|
end
|
65
67
|
|
66
68
|
def string_file_diff(path, string)
|
67
|
-
require 'tempfile'
|
68
69
|
tempfile = Tempfile.new("puppet-diffing")
|
69
70
|
tempfile.open
|
70
71
|
tempfile.print string
|
data/lib/puppet/util/filetype.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
# to see here.
|
3
3
|
|
4
4
|
require 'puppet/util/selinux'
|
5
|
+
require 'tempfile'
|
5
6
|
require 'fileutils'
|
6
7
|
|
7
8
|
class Puppet::Util::FileType
|
@@ -103,7 +104,6 @@ class Puppet::Util::FileType
|
|
103
104
|
|
104
105
|
# Overwrite the file.
|
105
106
|
def write(text)
|
106
|
-
require "tempfile"
|
107
107
|
tf = Tempfile.new("puppet")
|
108
108
|
tf.print text; tf.flush
|
109
109
|
FileUtils.cp(tf.path, @path)
|
@@ -223,7 +223,6 @@ class Puppet::Util::FileType
|
|
223
223
|
# and the text with which to create the cron tab.
|
224
224
|
def write(text)
|
225
225
|
puts text
|
226
|
-
require "tempfile"
|
227
226
|
output_file = Tempfile.new("puppet")
|
228
227
|
fh = output_file.open
|
229
228
|
fh.print text
|
@@ -262,7 +261,6 @@ class Puppet::Util::FileType
|
|
262
261
|
# Overwrite a specific @path's cron tab; must be passed the @path name
|
263
262
|
# and the text with which to create the cron tab.
|
264
263
|
def write(text)
|
265
|
-
require "tempfile"
|
266
264
|
output_file = Tempfile.new("puppet")
|
267
265
|
fh = output_file.open
|
268
266
|
fh.print text
|
data/lib/puppet/util/run_mode.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'facter'
|
1
2
|
require 'puppet/util/warnings'
|
2
3
|
require 'forwardable'
|
3
4
|
require 'etc'
|
@@ -17,7 +18,6 @@ module Puppet::Util::SUIDManager
|
|
17
18
|
|
18
19
|
def osx_maj_ver
|
19
20
|
return @osx_maj_ver unless @osx_maj_ver.nil?
|
20
|
-
require 'facter'
|
21
21
|
# 'kernel' is available without explicitly loading all facts
|
22
22
|
if Facter.value('kernel') != 'Darwin'
|
23
23
|
@osx_maj_ver = false
|
data/lib/puppet/util/windows.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'puppet/util/windows'
|
2
|
+
|
3
|
+
module Puppet::Util::Windows::File
|
4
|
+
require 'windows/api'
|
5
|
+
require 'windows/wide_string'
|
6
|
+
|
7
|
+
ReplaceFileWithoutBackupW = Windows::API.new('ReplaceFileW', 'PPVLVV', 'B')
|
8
|
+
def replace_file(target, source)
|
9
|
+
result = ReplaceFileWithoutBackupW.call(WideString.new(target.to_s),
|
10
|
+
WideString.new(source.to_s),
|
11
|
+
0, 0x1, 0, 0)
|
12
|
+
return true unless result == 0
|
13
|
+
raise Puppet::Util::Windows::Error.new("ReplaceFile(#{target}, #{source})")
|
14
|
+
end
|
15
|
+
module_function :replace_file
|
16
|
+
|
17
|
+
MoveFileEx = Windows::API.new('MoveFileExW', 'PPL', 'B')
|
18
|
+
def move_file_ex(source, target, flags = 0)
|
19
|
+
result = MoveFileEx.call(WideString.new(source.to_s),
|
20
|
+
WideString.new(target.to_s),
|
21
|
+
flags)
|
22
|
+
return true unless result == 0
|
23
|
+
raise Puppet::Util::Windows::Error.
|
24
|
+
new("MoveFileEx(#{source}, #{target}, #{flags.to_s(8)})")
|
25
|
+
end
|
26
|
+
module_function :move_file_ex
|
27
|
+
end
|