chef 14.12.9-universal-mingw32 → 14.13.11-universal-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -9
- data/lib/chef/chef_fs/command_line.rb +11 -12
- data/lib/chef/deprecated.rb +3 -3
- data/lib/chef/dsl/data_query.rb +22 -4
- data/lib/chef/dsl/recipe.rb +1 -7
- data/lib/chef/dsl/universal.rb +6 -0
- data/lib/chef/file_access_control/windows.rb +5 -3
- data/lib/chef/knife.rb +3 -3
- data/lib/chef/knife/bootstrap.rb +1 -1
- data/lib/chef/knife/bootstrap/templates/chef-full.erb +2 -1
- data/lib/chef/knife/config_list_profiles.rb +1 -1
- data/lib/chef/knife/core/status_presenter.rb +9 -2
- data/lib/chef/mixin/template.rb +14 -9
- data/lib/chef/node_map.rb +5 -24
- data/lib/chef/provider/cron.rb +14 -2
- data/lib/chef/provider/file.rb +1 -1
- data/lib/chef/provider/service/insserv.rb +3 -1
- data/lib/chef/resource.rb +3 -10
- data/lib/chef/resource/windows_feature_powershell.rb +1 -1
- data/lib/chef/resource_collection.rb +3 -2
- data/lib/chef/shell.rb +1 -0
- data/lib/chef/version.rb +1 -1
- data/lib/chef/win32/api/security.rb +2 -0
- data/lib/chef/win32/file.rb +8 -0
- data/lib/chef/win32/security.rb +1 -1
- data/spec/data/templates/failed.erb +5 -0
- data/spec/functional/assets/inittest +36 -0
- data/spec/functional/resource/insserv_spec.rb +205 -0
- data/spec/functional/resource/link_spec.rb +2 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/support/platform_helpers.rb +4 -0
- data/spec/support/shared/functional/directory_resource.rb +12 -10
- data/spec/support/shared/functional/file_resource.rb +2 -2
- data/spec/support/shared/functional/securable_resource.rb +102 -71
- data/spec/support/shared/unit/provider/file.rb +1 -0
- data/spec/unit/knife/bootstrap_spec.rb +22 -0
- data/spec/unit/knife_spec.rb +8 -5
- data/spec/unit/mixin/template_spec.rb +45 -0
- data/spec/unit/node_map_spec.rb +10 -43
- data/spec/unit/provider/cron_spec.rb +123 -20
- data/spec/unit/provider/service/insserv_service_spec.rb +2 -2
- data/spec/unit/resource_collection_spec.rb +8 -0
- data/spec/unit/resource_spec.rb +1 -13
- data/spec/unit/win32/security_spec.rb +25 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7f1987f0fe78cbdbc926defbdee341198e8fc38c647e7156c07d6c8829e18da
|
4
|
+
data.tar.gz: '094d973b808d23120d39a527dd64db72a124ee709c68ccd0fbb064b517372557'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5e977a3fa6c9e1ec6fbd332b91e489877836283fcacd32ba59125d500bb43b153d9d2fa3f63bdc8ff71f8aff777c755f7765c4bee2f1e990f4a1f795501013f1
|
7
|
+
data.tar.gz: 56329ad8a4e51b79e6b3bb0fb4fb96f89e3ef9ab44356c37590384460be3f3b2bf4e19f4c4b815163e51ae76ab688166dbd12b34469354cb031027d9fbd31905
|
data/Gemfile
CHANGED
@@ -28,17 +28,9 @@ group(:docgen) do
|
|
28
28
|
gem "yard"
|
29
29
|
end
|
30
30
|
|
31
|
-
group(:maintenance) do
|
32
|
-
gem "tomlrb"
|
33
|
-
|
34
|
-
# To sync maintainers with github
|
35
|
-
gem "octokit"
|
36
|
-
gem "netrc"
|
37
|
-
end
|
38
|
-
|
39
31
|
# Everything except AIX
|
40
32
|
group(:ruby_prof) do
|
41
|
-
gem "ruby-prof"
|
33
|
+
gem "ruby-prof", "< 0.18.0" # 0.18 breaks appveyor tests
|
42
34
|
end
|
43
35
|
|
44
36
|
# Everything except AIX and Windows
|
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: John Keiser (<jkeiser@chef.io>)
|
3
|
-
# Copyright:: Copyright 2012-
|
3
|
+
# Copyright:: Copyright 2012-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -271,19 +271,18 @@ class Chef
|
|
271
271
|
new_tempfile.write(new_value)
|
272
272
|
new_tempfile.close
|
273
273
|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
old_tempfile.close
|
274
|
+
old_tempfile = Tempfile.new("old")
|
275
|
+
old_tempfile.write(old_value)
|
276
|
+
old_tempfile.close
|
278
277
|
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
end
|
278
|
+
result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path)
|
279
|
+
result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}")
|
280
|
+
result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}")
|
281
|
+
result
|
282
|
+
rescue => e
|
283
|
+
"!!! Unable to diff #{old_path} and #{new_path} due to #{e}"
|
286
284
|
ensure
|
285
|
+
old_tempfile.close!
|
287
286
|
new_tempfile.close!
|
288
287
|
end
|
289
288
|
end
|
data/lib/chef/deprecated.rb
CHANGED
data/lib/chef/dsl/data_query.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
|
-
# Copyright:: Copyright 2008-
|
3
|
+
# Copyright:: Copyright 2008-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -25,9 +25,9 @@ require "chef/encrypted_data_bag_item/check_encrypted"
|
|
25
25
|
class Chef
|
26
26
|
module DSL
|
27
27
|
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
28
|
+
# Provides DSL helper methods for querying the search interface, data bag
|
29
|
+
# interface or node interface.
|
30
|
+
#
|
31
31
|
module DataQuery
|
32
32
|
include Chef::EncryptedDataBagItem::CheckEncrypted
|
33
33
|
|
@@ -80,6 +80,24 @@ class Chef
|
|
80
80
|
raise
|
81
81
|
end
|
82
82
|
|
83
|
+
#
|
84
|
+
# Note that this is mixed into the Universal DSL so access to the node needs to be done
|
85
|
+
# through the run_context and not accessing the node method directly, since the node method
|
86
|
+
# is not as universal as the run_context.
|
87
|
+
#
|
88
|
+
|
89
|
+
# True if all the tags are set on the node.
|
90
|
+
#
|
91
|
+
# @param [Array<String>] tags to check against
|
92
|
+
# @return boolean
|
93
|
+
#
|
94
|
+
def tagged?(*tags)
|
95
|
+
tags.each do |tag|
|
96
|
+
return false unless run_context.node.tags.include?(tag)
|
97
|
+
end
|
98
|
+
true
|
99
|
+
end
|
100
|
+
|
83
101
|
end
|
84
102
|
end
|
85
103
|
end
|
data/lib/chef/dsl/recipe.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@chef.io>)
|
3
3
|
# Author:: Christopher Walters (<cw@chef.io>)
|
4
|
-
# Copyright:: Copyright 2008-
|
4
|
+
# Copyright:: Copyright 2008-2019, Chef Software Inc.
|
5
5
|
# License:: Apache License, Version 2.0
|
6
6
|
#
|
7
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -20,12 +20,9 @@
|
|
20
20
|
require "chef/exceptions"
|
21
21
|
require "chef/dsl/resources"
|
22
22
|
require "chef/dsl/definitions"
|
23
|
-
require "chef/dsl/data_query"
|
24
23
|
require "chef/dsl/include_recipe"
|
25
|
-
require "chef/dsl/registry_helper"
|
26
24
|
require "chef/dsl/reboot_pending"
|
27
25
|
require "chef/dsl/audit"
|
28
|
-
require "chef/dsl/powershell"
|
29
26
|
require "chef/dsl/core"
|
30
27
|
require "chef/mixin/lazy_module_include"
|
31
28
|
|
@@ -51,12 +48,9 @@ class Chef
|
|
51
48
|
#
|
52
49
|
module Recipe
|
53
50
|
include Chef::DSL::Core
|
54
|
-
include Chef::DSL::DataQuery
|
55
51
|
include Chef::DSL::IncludeRecipe
|
56
|
-
include Chef::DSL::RegistryHelper
|
57
52
|
include Chef::DSL::RebootPending
|
58
53
|
include Chef::DSL::Audit
|
59
|
-
include Chef::DSL::Powershell
|
60
54
|
include Chef::DSL::Resources
|
61
55
|
include Chef::DSL::Definitions
|
62
56
|
extend Chef::Mixin::LazyModuleInclude
|
data/lib/chef/dsl/universal.rb
CHANGED
@@ -18,6 +18,9 @@
|
|
18
18
|
#
|
19
19
|
|
20
20
|
require "chef/dsl/platform_introspection"
|
21
|
+
require "chef/dsl/data_query"
|
22
|
+
require "chef/dsl/registry_helper"
|
23
|
+
require "chef/dsl/powershell"
|
21
24
|
require "chef/mixin/powershell_exec"
|
22
25
|
require "chef/mixin/powershell_out"
|
23
26
|
require "chef/mixin/shell_out"
|
@@ -45,6 +48,9 @@ class Chef
|
|
45
48
|
#
|
46
49
|
module Universal
|
47
50
|
include Chef::DSL::PlatformIntrospection
|
51
|
+
include Chef::DSL::DataQuery
|
52
|
+
include Chef::DSL::RegistryHelper
|
53
|
+
include Chef::DSL::Powershell
|
48
54
|
include Chef::Mixin::PowershellExec
|
49
55
|
include Chef::Mixin::PowershellOut
|
50
56
|
include Chef::Mixin::ShellOut
|
@@ -90,11 +90,13 @@ class Chef
|
|
90
90
|
target_acl.each do |target_ace|
|
91
91
|
if target_ace.flags & INHERIT_ONLY_ACE == 0
|
92
92
|
self_ace = target_ace.dup
|
93
|
-
|
93
|
+
# We need flag value which is already being set in case of WRITE permissions as 3, so we will not be overwriting it with the hard coded value.
|
94
|
+
self_ace.flags = 0 unless target_ace.mask == Chef::ReservedNames::Win32::API::Security::WRITE
|
94
95
|
self_ace.mask = securable_object.predict_rights_mask(target_ace.mask)
|
95
96
|
new_target_acl << self_ace
|
96
97
|
end
|
97
|
-
|
98
|
+
# As there is no inheritence needed in case of WRITE permissions.
|
99
|
+
if target_ace.mask != Chef::ReservedNames::Win32::API::Security::WRITE && target_ace.flags & (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE) != 0
|
98
100
|
children_ace = target_ace.dup
|
99
101
|
children_ace.flags |= INHERIT_ONLY_ACE
|
100
102
|
new_target_acl << children_ace
|
@@ -220,7 +222,7 @@ class Chef
|
|
220
222
|
when :read_execute
|
221
223
|
mask |= GENERIC_READ | GENERIC_EXECUTE
|
222
224
|
when :write
|
223
|
-
mask |=
|
225
|
+
mask |= WRITE
|
224
226
|
else
|
225
227
|
# Otherwise, assume it's an integer specifying the actual flags
|
226
228
|
mask |= permission
|
data/lib/chef/knife.rb
CHANGED
@@ -316,7 +316,7 @@ class Chef
|
|
316
316
|
exit 1
|
317
317
|
end
|
318
318
|
|
319
|
-
# copy Mixlib::CLI over so that it can be configured in knife.rb
|
319
|
+
# copy Mixlib::CLI over so that it can be configured in config.rb/knife.rb
|
320
320
|
# config file
|
321
321
|
Chef::Config[:verbosity] = config[:verbosity] if config[:verbosity]
|
322
322
|
end
|
@@ -446,7 +446,7 @@ class Chef
|
|
446
446
|
run
|
447
447
|
end
|
448
448
|
rescue Exception => e
|
449
|
-
raise if raise_exception || Chef::Config[:verbosity]
|
449
|
+
raise if raise_exception || ( Chef::Config[:verbosity] && Chef::Config[:verbosity] >= 2 )
|
450
450
|
humanize_exception(e)
|
451
451
|
exit 100
|
452
452
|
end
|
@@ -477,7 +477,7 @@ class Chef
|
|
477
477
|
ui.info "Check your configuration file and ensure that your private key is readable"
|
478
478
|
when Chef::Exceptions::InvalidRedirect
|
479
479
|
ui.error "Invalid Redirect: #{e.message}"
|
480
|
-
ui.info "Change your server location in knife.rb to the server's FQDN to avoid unwanted redirections."
|
480
|
+
ui.info "Change your server location in config.rb/knife.rb to the server's FQDN to avoid unwanted redirections."
|
481
481
|
else
|
482
482
|
ui.error "#{e.class.name}: #{e.message}"
|
483
483
|
end
|
data/lib/chef/knife/bootstrap.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
sh -c '
|
2
|
-
<%= "
|
2
|
+
<%= "https_proxy=\"#{knife_config[:bootstrap_proxy]}\" export https_proxy" if knife_config[:bootstrap_proxy] %>
|
3
|
+
<%= "no_proxy=\"#{knife_config[:bootstrap_no_proxy]}\" export no_proxy" if knife_config[:bootstrap_no_proxy] %>
|
3
4
|
|
4
5
|
if test "x$TMPDIR" = "x"; then
|
5
6
|
tmp="/tmp"
|
@@ -100,7 +100,14 @@ class Chef
|
|
100
100
|
fqdn = (node[:ec2] && node[:ec2][:public_hostname]) || node[:fqdn]
|
101
101
|
name = node["name"] || node.name
|
102
102
|
|
103
|
-
|
103
|
+
if config[:run_list]
|
104
|
+
if config[:long_output]
|
105
|
+
run_list = node.run_list.map { |rl| "#{rl.type}[#{rl.name}]" }
|
106
|
+
else
|
107
|
+
run_list = node["run_list"]
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
104
111
|
line_parts = Array.new
|
105
112
|
|
106
113
|
if node["ohai_time"]
|
@@ -128,7 +135,7 @@ class Chef
|
|
128
135
|
|
129
136
|
line_parts << fqdn if fqdn
|
130
137
|
line_parts << ip if ip
|
131
|
-
line_parts << run_list if run_list
|
138
|
+
line_parts << run_list.to_s if run_list
|
132
139
|
|
133
140
|
if node["platform"]
|
134
141
|
platform = node["platform"].dup
|
data/lib/chef/mixin/template.rb
CHANGED
@@ -138,11 +138,11 @@ class Chef
|
|
138
138
|
partial_context._extend_modules(@_extension_modules)
|
139
139
|
|
140
140
|
template_location = @template_finder.find(partial_name, options)
|
141
|
-
_render_template(IO.binread(template_location), partial_context)
|
141
|
+
_render_template(IO.binread(template_location), partial_context, filename: template_location)
|
142
142
|
end
|
143
143
|
|
144
144
|
def render_template(template_location)
|
145
|
-
_render_template(IO.binread(template_location), self)
|
145
|
+
_render_template(IO.binread(template_location), self, filename: template_location)
|
146
146
|
end
|
147
147
|
|
148
148
|
def render_template_from_string(template)
|
@@ -153,12 +153,13 @@ class Chef
|
|
153
153
|
# INTERNAL PUBLIC API
|
154
154
|
###
|
155
155
|
|
156
|
-
def _render_template(template, context)
|
156
|
+
def _render_template(template, context, options = {})
|
157
157
|
begin
|
158
|
-
eruby = Erubis::Eruby.new(template)
|
158
|
+
# eruby = Erubis::Eruby.new(template, options)
|
159
|
+
eruby = Erubis::Eruby.new(template, options)
|
159
160
|
output = eruby.evaluate(context)
|
160
161
|
rescue Object => e
|
161
|
-
raise TemplateError.new(e, template, context)
|
162
|
+
raise TemplateError.new(e, template, context, options)
|
162
163
|
end
|
163
164
|
|
164
165
|
# CHEF-4399
|
@@ -210,11 +211,11 @@ class Chef
|
|
210
211
|
end
|
211
212
|
|
212
213
|
class TemplateError < RuntimeError
|
213
|
-
attr_reader :original_exception, :context
|
214
|
+
attr_reader :original_exception, :context, :options
|
214
215
|
SOURCE_CONTEXT_WINDOW = 2
|
215
216
|
|
216
|
-
def initialize(original_exception, template, context)
|
217
|
-
@original_exception, @template, @context = original_exception, template, context
|
217
|
+
def initialize(original_exception, template, context, options)
|
218
|
+
@original_exception, @template, @context, @options = original_exception, template, context, options
|
218
219
|
end
|
219
220
|
|
220
221
|
def message
|
@@ -222,7 +223,11 @@ class Chef
|
|
222
223
|
end
|
223
224
|
|
224
225
|
def line_number
|
225
|
-
@line_number ||=
|
226
|
+
@line_number ||= if options[:filename]
|
227
|
+
$1.to_i if original_exception.backtrace.find { |line| line =~ /#{Regexp.escape(options[:filename])}:(\d+)/ }
|
228
|
+
else
|
229
|
+
$1.to_i if original_exception.backtrace.find { |line| line =~ /\(erubis\):(\d+)/ }
|
230
|
+
end
|
226
231
|
end
|
227
232
|
|
228
233
|
def source_location
|
data/lib/chef/node_map.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Lamont Granquist (<lamont@chef.io>)
|
3
|
-
# Copyright:: Copyright 2014-
|
3
|
+
# Copyright:: Copyright 2014-2019, Chef Software Inc.
|
4
4
|
# License:: Apache License, Version 2.0
|
5
5
|
#
|
6
6
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -37,12 +37,7 @@
|
|
37
37
|
#
|
38
38
|
class Chef
|
39
39
|
class NodeMap
|
40
|
-
|
41
|
-
%{type_caps} %{key} from a cookbook is overriding the %{type} from the client. Please upgrade your cookbook
|
42
|
-
or remove the cookbook from your run_list before the next major release of Chef.
|
43
|
-
EOH
|
44
|
-
|
45
|
-
COLLISION_WARNING_15 = <<~EOH.gsub(/\s+/, " ").strip
|
40
|
+
COLLISION_WARNING = <<~EOH.gsub(/\s+/, " ").strip
|
46
41
|
%{type_caps} %{key} from the client is overriding the %{type} from a cookbook. Please upgrade your cookbook
|
47
42
|
or remove the cookbook from your run_list.
|
48
43
|
EOH
|
@@ -54,19 +49,13 @@ EOH
|
|
54
49
|
# @param key [Object] Key to store
|
55
50
|
# @param value [Object] Value associated with the key
|
56
51
|
# @param filters [Hash] Node filter options to apply to key retrieval
|
57
|
-
# @param allow_cookbook_override [Boolean, String] Allow a cookbook to add
|
58
|
-
# to this key even in locked mode. If a string is given, it should be a
|
59
|
-
# Gem::Requirement-compatible value indicating for which Chef versions an
|
60
|
-
# override from cookbooks is allowed.
|
61
|
-
# @param __core_override__ [Boolean] Advanced-mode override to add to a key
|
62
|
-
# even in locked mode.
|
63
52
|
# @param chef_version [String] version constraint to match against the running Chef::VERSION
|
64
53
|
#
|
65
54
|
# @yield [node] Arbitrary node filter as a block which takes a node argument
|
66
55
|
#
|
67
56
|
# @return [NodeMap] Returns self for possible chaining
|
68
57
|
#
|
69
|
-
def set(key, klass, platform: nil, platform_version: nil, platform_family: nil, os: nil, canonical: nil, override: nil,
|
58
|
+
def set(key, klass, platform: nil, platform_version: nil, platform_family: nil, os: nil, canonical: nil, override: nil, chef_version: nil, &block)
|
70
59
|
new_matcher = { klass: klass }
|
71
60
|
new_matcher[:platform] = platform if platform
|
72
61
|
new_matcher[:platform_version] = platform_version if platform_version
|
@@ -75,8 +64,6 @@ EOH
|
|
75
64
|
new_matcher[:block] = block if block
|
76
65
|
new_matcher[:canonical] = canonical if canonical
|
77
66
|
new_matcher[:override] = override if override
|
78
|
-
new_matcher[:cookbook_override] = allow_cookbook_override
|
79
|
-
new_matcher[:core_override] = __core_override__
|
80
67
|
|
81
68
|
if chef_version && Chef::VERSION !~ chef_version
|
82
69
|
return map
|
@@ -87,9 +74,7 @@ EOH
|
|
87
74
|
# 1. Core override mode is not set.
|
88
75
|
# 2. The key exists.
|
89
76
|
# 3. At least one previous `provides` is now locked.
|
90
|
-
|
91
|
-
# true or with a string version matcher that still matches Chef::VERSION
|
92
|
-
if !__core_override__ && map[key] && map[key].any? { |matcher| matcher[:locked] } && !map[key].any? { |matcher| matcher[:cookbook_override].is_a?(String) ? Chef::VERSION =~ matcher[:cookbook_override] : matcher[:cookbook_override] }
|
77
|
+
if map[key] && map[key].any? { |matcher| matcher[:locked] } && !map[key].any? { |matcher| matcher[:cookbook_override].is_a?(String) ? Chef::VERSION =~ matcher[:cookbook_override] : matcher[:cookbook_override] }
|
93
78
|
# If we ever use locked mode on things other than the resource and provider handler maps, this probably needs a tweak.
|
94
79
|
type_of_thing = if klass < Chef::Resource
|
95
80
|
"resource"
|
@@ -98,11 +83,7 @@ EOH
|
|
98
83
|
else
|
99
84
|
klass.superclass.to_s
|
100
85
|
end
|
101
|
-
|
102
|
-
Chef.deprecated(:map_collision, COLLISION_WARNING_14 % { type: type_of_thing, key: key, type_caps: type_of_thing.capitalize })
|
103
|
-
# In 15.0, uncomment this and remove the log above.
|
104
|
-
# Chef.deprecated(:map_collision, COLLISION_WARNING_15 % {type: type_of_thing, key: key, type_caps: type_of_thing.capitalize}))
|
105
|
-
# return
|
86
|
+
Chef::Log.warn( COLLISION_WARNING % { type: type_of_thing, key: key, type_caps: type_of_thing.capitalize } )
|
106
87
|
end
|
107
88
|
|
108
89
|
# The map is sorted in order of preference already; we just need to find
|
data/lib/chef/provider/cron.rb
CHANGED
@@ -32,6 +32,7 @@ class Chef
|
|
32
32
|
CRON_PATTERN = /\A([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+)\s([-0-9*,\/]+|[a-zA-Z]{3})\s([-0-9*,\/]+|[a-zA-Z]{3})\s(.*)/
|
33
33
|
SPECIAL_PATTERN = /\A(@(#{SPECIAL_TIME_VALUES.join('|')}))\s(.*)/
|
34
34
|
ENV_PATTERN = /\A(\S+)=(\S*)/
|
35
|
+
ENVIRONMENT_PROPERTIES = %w{MAILTO PATH SHELL HOME}.freeze
|
35
36
|
|
36
37
|
def initialize(new_resource, run_context)
|
37
38
|
super(new_resource, run_context)
|
@@ -192,7 +193,7 @@ class Chef
|
|
192
193
|
private
|
193
194
|
|
194
195
|
def set_environment_var(attr_name, attr_value)
|
195
|
-
if
|
196
|
+
if ENVIRONMENT_PROPERTIES.include?(attr_name)
|
196
197
|
current_resource.send(attr_name.downcase.to_sym, attr_value.gsub(/^"|"$/, ""))
|
197
198
|
else
|
198
199
|
current_resource.environment(current_resource.environment.merge(attr_name => attr_value))
|
@@ -221,7 +222,18 @@ class Chef
|
|
221
222
|
newcron << "#{v.to_s.upcase}=\"#{new_resource.send(v)}\"\n" if new_resource.send(v)
|
222
223
|
end
|
223
224
|
new_resource.environment.each do |name, value|
|
224
|
-
|
225
|
+
if ENVIRONMENT_PROPERTIES.include?(name)
|
226
|
+
unless new_resource.property_is_set?(name.downcase)
|
227
|
+
logger.warn("#{new_resource.name}: the environment property contains the '#{name}' variable, which should be set separately as a property.")
|
228
|
+
new_resource.send(name.downcase.to_sym, value.gsub(/^"|"$/, ""))
|
229
|
+
new_resource.environment.delete(name)
|
230
|
+
newcron << "#{name.to_s.upcase}=\"#{value}\"\n"
|
231
|
+
else
|
232
|
+
raise Chef::Exceptions::Cron, "#{new_resource.name}: the '#{name}' property is set and environment property also contains the '#{name}' variable. Remove the variable from the environment property."
|
233
|
+
end
|
234
|
+
else
|
235
|
+
newcron << "#{name}=#{value}\n"
|
236
|
+
end
|
225
237
|
end
|
226
238
|
if new_resource.time
|
227
239
|
newcron << "@#{new_resource.time} #{new_resource.command}\n"
|