puppet 7.12.1 → 7.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +13 -8
- data/ext/project_data.yaml +1 -1
- data/lib/puppet/application/lookup.rb +72 -24
- data/lib/puppet/concurrent/thread_local_singleton.rb +5 -3
- data/lib/puppet/defaults.rb +3 -1
- data/lib/puppet/file_serving/metadata.rb +3 -0
- data/lib/puppet/file_system/file_impl.rb +7 -7
- data/lib/puppet/file_system/jruby.rb +1 -1
- data/lib/puppet/file_system/path_pattern.rb +10 -15
- data/lib/puppet/file_system/uniquefile.rb +1 -1
- data/lib/puppet/file_system/windows.rb +4 -4
- data/lib/puppet/file_system.rb +1 -1
- data/lib/puppet/functions/versioncmp.rb +6 -2
- data/lib/puppet/graph/simple_graph.rb +2 -1
- data/lib/puppet/pops/parser/code_merger.rb +4 -4
- data/lib/puppet/pops/parser/egrammar.ra +2 -0
- data/lib/puppet/pops/parser/eparser.rb +574 -558
- data/lib/puppet/pops/serialization/to_data_converter.rb +6 -18
- data/lib/puppet/pops/validation/checker4_0.rb +7 -2
- data/lib/puppet/provider/service/init.rb +5 -4
- data/lib/puppet/ssl/verifier.rb +3 -1
- data/lib/puppet/transaction/persistence.rb +22 -12
- data/lib/puppet/type/file/data_sync.rb +1 -1
- data/lib/puppet/type/file/group.rb +8 -1
- data/lib/puppet/type/file/owner.rb +8 -1
- data/lib/puppet/type/user.rb +40 -38
- data/lib/puppet/util/json.rb +17 -0
- data/lib/puppet/util/log.rb +7 -2
- data/lib/puppet/util/monkey_patches.rb +26 -2
- data/lib/puppet/util/package.rb +25 -16
- data/lib/puppet/util/yaml.rb +11 -0
- data/lib/puppet/version.rb +1 -1
- data/lib/puppet.rb +1 -0
- data/locales/puppet.pot +115 -93
- data/man/man5/puppet.conf.5 +10 -2
- data/man/man8/puppet-agent.8 +1 -1
- data/man/man8/puppet-apply.8 +1 -1
- data/man/man8/puppet-catalog.8 +1 -1
- data/man/man8/puppet-config.8 +1 -1
- data/man/man8/puppet-describe.8 +1 -1
- data/man/man8/puppet-device.8 +1 -1
- data/man/man8/puppet-doc.8 +1 -1
- data/man/man8/puppet-epp.8 +1 -1
- data/man/man8/puppet-facts.8 +1 -1
- data/man/man8/puppet-filebucket.8 +1 -1
- data/man/man8/puppet-generate.8 +1 -1
- data/man/man8/puppet-help.8 +1 -1
- data/man/man8/puppet-lookup.8 +9 -6
- data/man/man8/puppet-module.8 +1 -1
- data/man/man8/puppet-node.8 +1 -1
- data/man/man8/puppet-parser.8 +1 -1
- data/man/man8/puppet-plugin.8 +1 -1
- data/man/man8/puppet-report.8 +1 -1
- data/man/man8/puppet-resource.8 +1 -1
- data/man/man8/puppet-script.8 +1 -1
- data/man/man8/puppet-ssl.8 +1 -1
- data/man/man8/puppet.8 +2 -2
- data/spec/fixtures/unit/forge/bacula.json +1 -1
- data/spec/integration/application/lookup_spec.rb +29 -6
- data/spec/integration/parser/pcore_resource_spec.rb +10 -0
- data/spec/shared_contexts/l10n.rb +5 -0
- data/spec/unit/application/lookup_spec.rb +131 -10
- data/spec/unit/concurrent/thread_local_singleton_spec.rb +39 -0
- data/spec/unit/file_system/uniquefile_spec.rb +7 -1
- data/spec/unit/file_system_spec.rb +34 -4
- data/spec/unit/forge/module_release_spec.rb +3 -3
- data/spec/unit/functions/versioncmp_spec.rb +40 -4
- data/spec/unit/pops/parser/parse_containers_spec.rb +2 -2
- data/spec/unit/pops/serialization/to_from_hr_spec.rb +0 -58
- data/spec/unit/pops/validator/validator_spec.rb +5 -0
- data/spec/unit/provider/service/gentoo_spec.rb +6 -5
- data/spec/unit/provider/service/init_spec.rb +15 -9
- data/spec/unit/provider/service/openwrt_spec.rb +21 -29
- data/spec/unit/provider/service/redhat_spec.rb +3 -2
- data/spec/unit/transaction/persistence_spec.rb +51 -0
- data/spec/unit/type/file/group_spec.rb +7 -0
- data/spec/unit/type/file/owner_spec.rb +7 -0
- data/spec/unit/type/user_spec.rb +0 -45
- data/spec/unit/util/json_spec.rb +126 -0
- data/spec/unit/util/yaml_spec.rb +37 -13
- metadata +14 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 45045b95a6ecb2a310d7114e78c48e812cbaa18e396eba63a399b3f6221e947e
|
4
|
+
data.tar.gz: 9196874c694b632b984fd0fc7b2304a2a2b6551328cbb81d62f664c282bd0ba9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e318a7303b592cb3b2cd0dd26c5e7b8ea57ab410aa79bd77c06acf60509d6f2fb5a55bf4fbea9aeeb8e4f660dd3f3c2c65062b3f0a0a3ba806c713264140b24a
|
7
|
+
data.tar.gz: e23422e5834aa7eedbc7e25bcaaf04d9ca3a48604c94d2c84085348cc1c41aad33299e0de3a247f9769222ba7d67b55de0deeab96037245b3214ef903d8bbbaa
|
data/Gemfile
CHANGED
@@ -3,7 +3,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
def location_for(place, fake_version = nil)
|
6
|
-
if place.is_a?(String) && place =~ /^(git[:@][^#]*)#(.*)/
|
6
|
+
if place.is_a?(String) && place =~ /^((?:git[:@]|https:)[^#]*)#(.*)/
|
7
7
|
[fake_version, { git: $1, branch: $2, require: false }].compact
|
8
8
|
elsif place.is_a?(String) && place =~ /^file:\/\/(.*)/
|
9
9
|
['>= 0', { path: File.expand_path($1), require: false }]
|
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
GIT
|
2
|
-
remote:
|
3
|
-
revision:
|
2
|
+
remote: https://github.com/puppetlabs/packaging
|
3
|
+
revision: 98613aaebad419700b4c37163fe3bbc612f2239d
|
4
4
|
branch: 1.0.x
|
5
5
|
specs:
|
6
|
-
packaging (0.
|
6
|
+
packaging (0.104.0.4.g98613aa)
|
7
|
+
apt_stage_artifacts
|
7
8
|
artifactory (~> 2)
|
8
9
|
csv (= 3.1.5)
|
9
10
|
rake (>= 12.3)
|
@@ -12,12 +13,12 @@ GIT
|
|
12
13
|
PATH
|
13
14
|
remote: .
|
14
15
|
specs:
|
15
|
-
puppet (7.
|
16
|
+
puppet (7.13.1)
|
16
17
|
CFPropertyList (~> 2.2)
|
17
18
|
concurrent-ruby (~> 1.0)
|
18
19
|
deep_merge (~> 1.0)
|
19
20
|
facter (>= 2.4.0, < 5)
|
20
|
-
fast_gettext (
|
21
|
+
fast_gettext (>= 1.1, < 3)
|
21
22
|
hiera (>= 3.2.1, < 4)
|
22
23
|
locale (~> 2.1)
|
23
24
|
multi_json (~> 1.13)
|
@@ -30,6 +31,8 @@ GEM
|
|
30
31
|
CFPropertyList (2.3.6)
|
31
32
|
addressable (2.8.0)
|
32
33
|
public_suffix (>= 2.0.2, < 5.0)
|
34
|
+
apt_stage_artifacts (0.10.1)
|
35
|
+
docopt
|
33
36
|
artifactory (2.8.2)
|
34
37
|
ast (2.4.2)
|
35
38
|
coderay (1.1.3)
|
@@ -87,7 +90,7 @@ GEM
|
|
87
90
|
rake
|
88
91
|
rake (13.0.6)
|
89
92
|
rdiscount (2.2.0.2)
|
90
|
-
rdoc (6.3.
|
93
|
+
rdoc (6.3.3)
|
91
94
|
release-metrics (1.1.0)
|
92
95
|
csv
|
93
96
|
docopt
|
@@ -111,7 +114,7 @@ GEM
|
|
111
114
|
rspec-mocks (3.10.2)
|
112
115
|
diff-lcs (>= 1.2.0, < 2.0)
|
113
116
|
rspec-support (~> 3.10.0)
|
114
|
-
rspec-support (3.10.
|
117
|
+
rspec-support (3.10.3)
|
115
118
|
rubocop (0.49.1)
|
116
119
|
parallel (~> 1.10)
|
117
120
|
parser (>= 2.3.3.1, < 3.0)
|
@@ -133,7 +136,9 @@ GEM
|
|
133
136
|
addressable (>= 2.8.0)
|
134
137
|
crack (>= 0.3.2)
|
135
138
|
hashdiff (>= 0.4.0, < 2.0.0)
|
136
|
-
|
139
|
+
webrick (1.7.0)
|
140
|
+
yard (0.9.27)
|
141
|
+
webrick (~> 1.7.0)
|
137
142
|
|
138
143
|
PLATFORMS
|
139
144
|
ruby
|
data/ext/project_data.yaml
CHANGED
@@ -7,6 +7,7 @@ class Puppet::Application::Lookup < Puppet::Application
|
|
7
7
|
|
8
8
|
RUN_HELP = _("Run 'puppet lookup --help' for more details").freeze
|
9
9
|
DEEP_MERGE_OPTIONS = '--knock-out-prefix, --sort-merged-arrays, and --merge-hash-arrays'.freeze
|
10
|
+
TRUSTED_INFORMATION_FACTS = ["hostname", "domain", "fqdn", "clientcert"].freeze
|
10
11
|
|
11
12
|
run_mode :server
|
12
13
|
|
@@ -54,11 +55,7 @@ class Puppet::Application::Lookup < Puppet::Application
|
|
54
55
|
end
|
55
56
|
|
56
57
|
option('--facts FACT_FILE') do |arg|
|
57
|
-
|
58
|
-
options[:fact_file] = arg
|
59
|
-
else
|
60
|
-
raise _("The --fact file only accepts yaml and json files.\n%{run_help}") % { run_help: RUN_HELP }
|
61
|
-
end
|
58
|
+
options[:fact_file] = arg
|
62
59
|
end
|
63
60
|
|
64
61
|
def app_defaults
|
@@ -137,7 +134,9 @@ DESCRIPTION
|
|
137
134
|
The lookup command is a CLI for Puppet's 'lookup()' function. It searches your
|
138
135
|
Hiera data and returns a value for the requested lookup key, so you can test and
|
139
136
|
explore your data. It is a modern replacement for the 'hiera' command.
|
140
|
-
|
137
|
+
Lookup uses the setting for global hiera.yaml from puppet's config,
|
138
|
+
and the environment to find the environment level hiera.yaml as well as the
|
139
|
+
resulting modulepath for the environment (for hiera.yaml files in modules).
|
141
140
|
Hiera usually relies on a node's facts to locate the relevant data sources. By
|
142
141
|
default, 'puppet lookup' uses facts from the node you run the command on, but
|
143
142
|
you can get data for any other node with the '--node <NAME>' option. If
|
@@ -186,7 +185,8 @@ OPTIONS
|
|
186
185
|
* --environment <ENV>
|
187
186
|
Like with most Puppet commands, you can specify an environment on the command
|
188
187
|
line. This is important for lookup because different environments can have
|
189
|
-
different Hiera data.
|
188
|
+
different Hiera data. This environment will be always be the one used regardless
|
189
|
+
of any other factors.
|
190
190
|
|
191
191
|
* --merge first|unique|hash|deep:
|
192
192
|
Specify the merge behavior, overriding any merge behavior from the data's
|
@@ -237,6 +237,13 @@ EXAMPLE
|
|
237
237
|
To look up 'key_name' using the Puppet Server node's facts:
|
238
238
|
$ puppet lookup key_name
|
239
239
|
|
240
|
+
To look up 'key_name' using the Puppet Server node's arbitrary variables from a manifest, and
|
241
|
+
classify the node if applicable:
|
242
|
+
$ puppet lookup key_name --compile
|
243
|
+
|
244
|
+
To look up 'key_name' using the Puppet Server node's facts, overridden by facts given in a file:
|
245
|
+
$ puppet lookup key_name --facts fact_file.yaml
|
246
|
+
|
240
247
|
To look up 'key_name' with agent.local's facts:
|
241
248
|
$ puppet lookup --node agent.local key_name
|
242
249
|
|
@@ -341,31 +348,60 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
|
|
341
348
|
Puppet.settings[:facts_terminus] = 'facter'
|
342
349
|
end
|
343
350
|
|
344
|
-
unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
|
345
|
-
ni = Puppet::Node.indirection
|
346
|
-
tc = ni.terminus_class
|
347
|
-
if tc == :plain || options[:compile]
|
348
|
-
node = ni.find(node)
|
349
|
-
else
|
350
|
-
ni.terminus_class = :plain
|
351
|
-
node = ni.find(node)
|
352
|
-
ni.terminus_class = tc
|
353
|
-
end
|
354
|
-
end
|
355
|
-
|
356
351
|
fact_file = options[:fact_file]
|
357
352
|
|
358
353
|
if fact_file
|
359
|
-
if fact_file.end_with?(
|
360
|
-
given_facts = Puppet::Util::Json.
|
361
|
-
|
354
|
+
if fact_file.end_with?('.json')
|
355
|
+
given_facts = Puppet::Util::Json.load_file(fact_file)
|
356
|
+
elsif fact_file.end_with?('.yml', '.yaml')
|
362
357
|
given_facts = Puppet::Util::Yaml.safe_load_file(fact_file)
|
358
|
+
else
|
359
|
+
given_facts = Puppet::Util::Json.load_file_if_valid(fact_file)
|
360
|
+
given_facts = Puppet::Util::Yaml.safe_load_file_if_valid(fact_file) unless given_facts
|
363
361
|
end
|
364
362
|
|
365
363
|
unless given_facts.instance_of?(Hash)
|
366
|
-
raise _("
|
364
|
+
raise _("Incorrectly formatted data in %{fact_file} given via the --facts flag (only accepts yaml and json files)") % { fact_file: fact_file }
|
365
|
+
end
|
366
|
+
|
367
|
+
if TRUSTED_INFORMATION_FACTS.any? { |key| given_facts.key? key }
|
368
|
+
unless TRUSTED_INFORMATION_FACTS.all? { |key| given_facts.key? key }
|
369
|
+
raise _("When overriding any of the %{trusted_facts_list} facts with %{fact_file} "\
|
370
|
+
"given via the --facts flag, they must all be overridden.") % { fact_file: fact_file ,trusted_facts_list: TRUSTED_INFORMATION_FACTS.join(',')}
|
371
|
+
end
|
367
372
|
end
|
368
|
-
|
373
|
+
end
|
374
|
+
|
375
|
+
unless node.is_a?(Puppet::Node) # to allow unit tests to pass a node instance
|
376
|
+
facts = retrieve_node_facts(node, given_facts)
|
377
|
+
if Puppet.settings.set_by_cli?('environment')
|
378
|
+
node = Puppet::Node.new(node, :classes => nil, :parameters => nil, :facts => facts, :environment => Puppet.settings.value('environment'))
|
379
|
+
else
|
380
|
+
ni = Puppet::Node.indirection
|
381
|
+
tc = ni.terminus_class
|
382
|
+
|
383
|
+
service = Puppet.runtime[:http]
|
384
|
+
session = service.create_session
|
385
|
+
cert = session.route_to(:ca)
|
386
|
+
|
387
|
+
_, x509 = cert.get_certificate(node)
|
388
|
+
cert = OpenSSL::X509::Certificate.new(x509)
|
389
|
+
|
390
|
+
Puppet::SSL::Oids.register_puppet_oids
|
391
|
+
trusted = Puppet::Context::TrustedInformation.remote(true, facts.values['certname'] || node, Puppet::SSL::Certificate.from_instance(cert))
|
392
|
+
|
393
|
+
Puppet.override(trusted_information: trusted) do
|
394
|
+
if tc == :plain || options[:compile]
|
395
|
+
node = ni.find(node, facts: facts)
|
396
|
+
else
|
397
|
+
ni.terminus_class = :plain
|
398
|
+
node = ni.find(node, facts: facts)
|
399
|
+
ni.terminus_class = tc
|
400
|
+
end
|
401
|
+
end
|
402
|
+
end
|
403
|
+
else
|
404
|
+
node.add_extra_facts(given_facts) if given_facts
|
369
405
|
end
|
370
406
|
|
371
407
|
Puppet[:code] = 'undef' unless options[:compile]
|
@@ -378,4 +414,16 @@ Copyright (c) 2015 Puppet Inc., LLC Licensed under the Apache 2.0 License
|
|
378
414
|
compiler.compile { |catalog| yield(compiler.topscope); catalog }
|
379
415
|
end
|
380
416
|
end
|
417
|
+
|
418
|
+
def retrieve_node_facts(node, given_facts)
|
419
|
+
facts = Puppet::Node::Facts.indirection.find(node, :environment => Puppet.lookup(:current_environment))
|
420
|
+
|
421
|
+
facts = Puppet::Node::Facts.new(node, {}) if facts.nil?
|
422
|
+
facts.add_extra_values(given_facts) if given_facts
|
423
|
+
|
424
|
+
if facts.values.empty?
|
425
|
+
raise _("No facts available for target node: %{node}") % { node: node}
|
426
|
+
end
|
427
|
+
facts
|
428
|
+
end
|
381
429
|
end
|
@@ -5,10 +5,12 @@ module Puppet
|
|
5
5
|
def singleton
|
6
6
|
key = (name + ".singleton").intern
|
7
7
|
thread = Thread.current
|
8
|
-
|
9
|
-
|
8
|
+
value = thread.thread_variable_get(key)
|
9
|
+
if value.nil?
|
10
|
+
value = new
|
11
|
+
thread.thread_variable_set(key, value)
|
10
12
|
end
|
11
|
-
|
13
|
+
value
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
data/lib/puppet/defaults.rb
CHANGED
@@ -1983,7 +1983,9 @@ EOT
|
|
1983
1983
|
:call_hook => :on_initialize_and_write, # Call our hook with the default value, so we always get the value added to facter.
|
1984
1984
|
:hook => proc do |value|
|
1985
1985
|
paths = value.split(File::PATH_SEPARATOR)
|
1986
|
-
Puppet.runtime[:facter]
|
1986
|
+
facter = Puppet.runtime[:facter]
|
1987
|
+
facter.reset
|
1988
|
+
facter.search(*paths)
|
1987
1989
|
end
|
1988
1990
|
}
|
1989
1991
|
)
|
@@ -118,6 +118,9 @@ class Puppet::FileServing::Metadata < Puppet::FileServing::Base
|
|
118
118
|
when "link"
|
119
119
|
@destination = Puppet::FileSystem.readlink(real_path)
|
120
120
|
@checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s rescue nil
|
121
|
+
when "fifo", "socket"
|
122
|
+
@checksum_type = "none"
|
123
|
+
@checksum = ("{#{@checksum_type}}") + send("#{@checksum_type}_file", real_path).to_s
|
121
124
|
else
|
122
125
|
raise ArgumentError, _("Cannot manage files of type %{file_type}") % { file_type: stat.ftype }
|
123
126
|
end
|
@@ -130,23 +130,23 @@ class Puppet::FileSystem::FileImpl
|
|
130
130
|
end
|
131
131
|
|
132
132
|
def symlink?(path)
|
133
|
-
File.symlink?(path)
|
133
|
+
::File.symlink?(path)
|
134
134
|
end
|
135
135
|
|
136
136
|
def readlink(path)
|
137
|
-
File.readlink(path)
|
137
|
+
::File.readlink(path)
|
138
138
|
end
|
139
139
|
|
140
140
|
def unlink(*paths)
|
141
|
-
File.unlink(*paths)
|
141
|
+
::File.unlink(*paths)
|
142
142
|
end
|
143
143
|
|
144
144
|
def stat(path)
|
145
|
-
File.stat(path)
|
145
|
+
::File.stat(path)
|
146
146
|
end
|
147
147
|
|
148
148
|
def lstat(path)
|
149
|
-
File.lstat(path)
|
149
|
+
::File.lstat(path)
|
150
150
|
end
|
151
151
|
|
152
152
|
def compare_stream(path, stream)
|
@@ -159,7 +159,7 @@ class Puppet::FileSystem::FileImpl
|
|
159
159
|
|
160
160
|
def replace_file(path, mode = nil)
|
161
161
|
begin
|
162
|
-
stat =
|
162
|
+
stat = lstat(path)
|
163
163
|
gid = stat.gid
|
164
164
|
uid = stat.uid
|
165
165
|
mode ||= stat.mode & 07777
|
@@ -180,7 +180,7 @@ class Puppet::FileSystem::FileImpl
|
|
180
180
|
tempfile_path = tempfile.path
|
181
181
|
FileUtils.chown(uid, gid, tempfile_path) if uid && gid
|
182
182
|
chmod(mode, tempfile_path)
|
183
|
-
File.rename(tempfile_path,
|
183
|
+
::File.rename(tempfile_path, path_string(path))
|
184
184
|
ensure
|
185
185
|
tempfile.close!
|
186
186
|
end
|
@@ -14,7 +14,7 @@ class Puppet::FileSystem::JRuby < Puppet::FileSystem::Posix
|
|
14
14
|
def replace_file(path, mode = nil, &block)
|
15
15
|
# MRI Ruby rename checks if destination is a directory and raises, while
|
16
16
|
# JRuby removes the directory and replaces the file.
|
17
|
-
if
|
17
|
+
if directory?(path)
|
18
18
|
raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: path }
|
19
19
|
end
|
20
20
|
|
@@ -5,10 +5,9 @@ module Puppet::FileSystem
|
|
5
5
|
class PathPattern
|
6
6
|
class InvalidPattern < Puppet::Error; end
|
7
7
|
|
8
|
-
|
8
|
+
DOTDOT = '..'.freeze
|
9
9
|
ABSOLUTE_UNIX = /^\//
|
10
10
|
ABSOLUTE_WINDOWS = /^[a-z]:/i
|
11
|
-
#ABSOLUT_VODKA #notappearinginthisclass
|
12
11
|
CURRENT_DRIVE_RELATIVE_WINDOWS = /^\\/
|
13
12
|
|
14
13
|
def self.relative(pattern)
|
@@ -32,11 +31,11 @@ module Puppet::FileSystem
|
|
32
31
|
end
|
33
32
|
|
34
33
|
def glob
|
35
|
-
Dir.glob(
|
34
|
+
Dir.glob(@pathstr)
|
36
35
|
end
|
37
36
|
|
38
37
|
def to_s
|
39
|
-
|
38
|
+
@pathstr
|
40
39
|
end
|
41
40
|
|
42
41
|
protected
|
@@ -46,13 +45,9 @@ module Puppet::FileSystem
|
|
46
45
|
private
|
47
46
|
|
48
47
|
def validate
|
49
|
-
@
|
50
|
-
|
51
|
-
|
52
|
-
end
|
53
|
-
end
|
54
|
-
case @pathname.to_s
|
55
|
-
when CURRENT_DRIVE_RELATIVE_WINDOWS
|
48
|
+
if @pathstr.split(Pathname::SEPARATOR_PAT).any? { |f| f == DOTDOT }
|
49
|
+
raise(InvalidPattern, _("PathPatterns cannot be created with directory traversals."))
|
50
|
+
elsif @pathstr.match?(CURRENT_DRIVE_RELATIVE_WINDOWS)
|
56
51
|
raise(InvalidPattern, _("A PathPattern cannot be a Windows current drive relative path."))
|
57
52
|
end
|
58
53
|
end
|
@@ -60,6 +55,7 @@ module Puppet::FileSystem
|
|
60
55
|
def initialize(pattern)
|
61
56
|
begin
|
62
57
|
@pathname = Pathname.new(pattern.strip)
|
58
|
+
@pathstr = @pathname.to_s
|
63
59
|
rescue ArgumentError => error
|
64
60
|
raise InvalidPattern.new(_("PathPatterns cannot be created with a zero byte."), error)
|
65
61
|
end
|
@@ -74,10 +70,9 @@ module Puppet::FileSystem
|
|
74
70
|
|
75
71
|
def validate
|
76
72
|
super
|
77
|
-
|
78
|
-
when ABSOLUTE_WINDOWS
|
73
|
+
if @pathstr.match?(ABSOLUTE_WINDOWS)
|
79
74
|
raise(InvalidPattern, _("A relative PathPattern cannot be prefixed with a drive."))
|
80
|
-
|
75
|
+
elsif @pathstr.match?(ABSOLUTE_UNIX)
|
81
76
|
raise(InvalidPattern, _("A relative PathPattern cannot be an absolute path."))
|
82
77
|
end
|
83
78
|
end
|
@@ -90,7 +85,7 @@ module Puppet::FileSystem
|
|
90
85
|
|
91
86
|
def validate
|
92
87
|
super
|
93
|
-
if
|
88
|
+
if !@pathstr.match?(ABSOLUTE_UNIX) && !@pathstr.match?(ABSOLUTE_WINDOWS)
|
94
89
|
raise(InvalidPattern, _("An absolute PathPattern cannot be a relative path."))
|
95
90
|
end
|
96
91
|
end
|
@@ -127,7 +127,7 @@ class Puppet::FileSystem::Uniquefile < DelegateClass(File)
|
|
127
127
|
tmpdir ||= tmpdir()
|
128
128
|
n = nil
|
129
129
|
begin
|
130
|
-
path = File.
|
130
|
+
path = File.join(tmpdir, make_tmpname(basename, n))
|
131
131
|
yield(path, n, *opts)
|
132
132
|
rescue Errno::EEXIST
|
133
133
|
n ||= 0
|
@@ -123,7 +123,7 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
|
|
123
123
|
LOCK_VIOLATION = 33
|
124
124
|
|
125
125
|
def replace_file(path, mode = nil)
|
126
|
-
if
|
126
|
+
if directory?(path)
|
127
127
|
raise Errno::EISDIR, _("Is a directory: %{directory}") % { directory: path }
|
128
128
|
end
|
129
129
|
|
@@ -159,14 +159,14 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
|
|
159
159
|
end
|
160
160
|
|
161
161
|
set_dacl(tempfile.path, dacl) if dacl
|
162
|
-
File.rename(tempfile.path,
|
162
|
+
::File.rename(tempfile.path, path_string(path))
|
163
163
|
ensure
|
164
164
|
tempfile.close!
|
165
165
|
end
|
166
166
|
rescue Puppet::Util::Windows::Error => e
|
167
167
|
case e.code
|
168
168
|
when ACCESS_DENIED, SHARING_VIOLATION, LOCK_VIOLATION
|
169
|
-
raise Errno::EACCES.new(
|
169
|
+
raise Errno::EACCES.new(path_string(path), e)
|
170
170
|
else
|
171
171
|
raise SystemCallError.new(e.message)
|
172
172
|
end
|
@@ -193,7 +193,7 @@ class Puppet::FileSystem::Windows < Puppet::FileSystem::Posix
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def get_dacl_from_file(path)
|
196
|
-
sd = Puppet::Util::Windows::Security.get_security_descriptor(
|
196
|
+
sd = Puppet::Util::Windows::Security.get_security_descriptor(path_string(path))
|
197
197
|
sd.dacl
|
198
198
|
rescue Puppet::Util::Windows::Error => e
|
199
199
|
raise e unless e.code == FILE_NOT_FOUND
|
data/lib/puppet/file_system.rb
CHANGED
@@ -8,6 +8,9 @@ require_relative '../../puppet/util/package'
|
|
8
8
|
#
|
9
9
|
# Where a and b are arbitrary version strings.
|
10
10
|
#
|
11
|
+
# Optional parameter ignore_trailing_zeroes is used to ignore unnecessary
|
12
|
+
# trailing version numbers like .0 or .0.00
|
13
|
+
#
|
11
14
|
# This function returns:
|
12
15
|
#
|
13
16
|
# * `1` if version a is greater than version b
|
@@ -28,9 +31,10 @@ Puppet::Functions.create_function(:versioncmp) do
|
|
28
31
|
dispatch :versioncmp do
|
29
32
|
param 'String', :a
|
30
33
|
param 'String', :b
|
34
|
+
optional_param 'Boolean', :ignore_trailing_zeroes
|
31
35
|
end
|
32
36
|
|
33
|
-
def versioncmp(a, b)
|
34
|
-
Puppet::Util::Package.versioncmp(a, b)
|
37
|
+
def versioncmp(a, b, ignore_trailing_zeroes = false)
|
38
|
+
Puppet::Util::Package.versioncmp(a, b, ignore_trailing_zeroes)
|
35
39
|
end
|
36
40
|
end
|
@@ -38,11 +38,12 @@ class Puppet::Graph::SimpleGraph
|
|
38
38
|
@downstream_from.clear
|
39
39
|
end
|
40
40
|
|
41
|
-
# Which resources
|
41
|
+
# Which resources the given resource depends on.
|
42
42
|
def dependencies(resource)
|
43
43
|
vertex?(resource) ? upstream_from_vertex(resource).keys : []
|
44
44
|
end
|
45
45
|
|
46
|
+
# Which resources depend upon the given resource.
|
46
47
|
def dependents(resource)
|
47
48
|
vertex?(resource) ? downstream_from_vertex(resource).keys : []
|
48
49
|
end
|
@@ -11,17 +11,17 @@ class Puppet::Pops::Parser::CodeMerger
|
|
11
11
|
# PUP-5299, some sites have thousands of entries, and run out of stack when evaluating - the logic
|
12
12
|
# below maps the logic as flatly as possible.
|
13
13
|
#
|
14
|
-
children = parse_results.select {|x| !x.nil? && x.code}.
|
14
|
+
children = parse_results.select {|x| !x.nil? && x.code}.flat_map do |parsed_class|
|
15
15
|
case parsed_class.code
|
16
16
|
when Puppet::Parser::AST::BlockExpression
|
17
17
|
# the BlockExpression wraps a single 4x instruction that is most likely wrapped in a Factory
|
18
|
-
|
18
|
+
parsed_class.code.children.map {|c| c.is_a?(Puppet::Pops::Model::Factory) ? c.model : c }
|
19
19
|
when Puppet::Pops::Model::Factory
|
20
20
|
# If it is a 4x instruction wrapped in a Factory
|
21
|
-
|
21
|
+
parsed_class.code.model
|
22
22
|
else
|
23
23
|
# It is the instruction directly
|
24
|
-
|
24
|
+
parsed_class.code
|
25
25
|
end
|
26
26
|
end
|
27
27
|
Puppet::Parser::AST::BlockExpression.new(:children => children)
|