chef 14.12.9 → 14.13.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -9
  3. data/lib/chef/chef_fs/command_line.rb +11 -12
  4. data/lib/chef/deprecated.rb +3 -3
  5. data/lib/chef/dsl/data_query.rb +22 -4
  6. data/lib/chef/dsl/recipe.rb +1 -7
  7. data/lib/chef/dsl/universal.rb +6 -0
  8. data/lib/chef/file_access_control/windows.rb +5 -3
  9. data/lib/chef/knife.rb +3 -3
  10. data/lib/chef/knife/bootstrap.rb +1 -1
  11. data/lib/chef/knife/bootstrap/templates/chef-full.erb +2 -1
  12. data/lib/chef/knife/config_list_profiles.rb +1 -1
  13. data/lib/chef/knife/core/status_presenter.rb +9 -2
  14. data/lib/chef/mixin/template.rb +14 -9
  15. data/lib/chef/node_map.rb +5 -24
  16. data/lib/chef/provider/cron.rb +14 -2
  17. data/lib/chef/provider/file.rb +1 -1
  18. data/lib/chef/provider/service/insserv.rb +3 -1
  19. data/lib/chef/resource.rb +3 -10
  20. data/lib/chef/resource/windows_feature_powershell.rb +1 -1
  21. data/lib/chef/resource_collection.rb +3 -2
  22. data/lib/chef/shell.rb +1 -0
  23. data/lib/chef/version.rb +1 -1
  24. data/lib/chef/win32/api/security.rb +2 -0
  25. data/lib/chef/win32/file.rb +8 -0
  26. data/lib/chef/win32/security.rb +1 -1
  27. data/spec/data/templates/failed.erb +5 -0
  28. data/spec/functional/assets/inittest +36 -0
  29. data/spec/functional/resource/insserv_spec.rb +205 -0
  30. data/spec/functional/resource/link_spec.rb +2 -2
  31. data/spec/spec_helper.rb +1 -0
  32. data/spec/support/platform_helpers.rb +4 -0
  33. data/spec/support/shared/functional/directory_resource.rb +12 -10
  34. data/spec/support/shared/functional/file_resource.rb +2 -2
  35. data/spec/support/shared/functional/securable_resource.rb +102 -71
  36. data/spec/support/shared/unit/provider/file.rb +1 -0
  37. data/spec/unit/knife/bootstrap_spec.rb +22 -0
  38. data/spec/unit/knife_spec.rb +8 -5
  39. data/spec/unit/mixin/template_spec.rb +45 -0
  40. data/spec/unit/node_map_spec.rb +10 -43
  41. data/spec/unit/provider/cron_spec.rb +123 -20
  42. data/spec/unit/provider/service/insserv_service_spec.rb +2 -2
  43. data/spec/unit/resource_collection_spec.rb +8 -0
  44. data/spec/unit/resource_spec.rb +1 -13
  45. data/spec/unit/win32/security_spec.rb +25 -0
  46. metadata +7 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba2c144a8325940f3614227422c68dab092efa4a1f57cda860fe0e7e3d9ca5be
4
- data.tar.gz: 57e44bc56561da8da2c748df399dfa740fc88f4f82cc71ae91d6bb591104f6f2
3
+ metadata.gz: fd16cc94143fe27b43ec4b04d1e113ab4f6aa595b95c0b5dddf81e328b54315b
4
+ data.tar.gz: 0a3c98308ebc117e8025a1c89ae5e34f76a6ebb74ffcd9842fd295185700be7c
5
5
  SHA512:
6
- metadata.gz: 62c7a1c3ed7cfb852225142265382cdc7d4524557c3cbbe8c9eebe06d88c0085d656a6ceb1fe167adfd0d85da8eefe6fef9aae2a3f1fa197784c624967ad2b20
7
- data.tar.gz: ddce5eee3f87f972c30ad0a195d5329b9722294fac097b337cd2057379cb18af4aad8007ef955f9387805e9c4fff8702f6c413cfc940de21d3d7594ed62d4851
6
+ metadata.gz: 6b0d8765da523b8dfe3936e1f6b124a2f70da0cff35c66543de13c54b3045eb8a8c8c6306d3ce2624479763ab401c24ca0d34f4c9adf9f700239812d743210e1
7
+ data.tar.gz: 2c980eb861ec3f59e30dbcec3b4035512a9b3dd2406677cea90cc6d269383f13db8203e15b5f695a65c47f8ea6423cab66eb3b46633e946d875ddf40a2d43a63
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-2016, Chef Software Inc.
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
- begin
275
- old_tempfile = Tempfile.new("old")
276
- old_tempfile.write(old_value)
277
- old_tempfile.close
274
+ old_tempfile = Tempfile.new("old")
275
+ old_tempfile.write(old_value)
276
+ old_tempfile.close
278
277
 
279
- result = Chef::Util::Diff.new.udiff(old_tempfile.path, new_tempfile.path)
280
- result = result.gsub(/^--- #{old_tempfile.path}/, "--- #{old_path}")
281
- result = result.gsub(/^\+\+\+ #{new_tempfile.path}/, "+++ #{new_path}")
282
- result
283
- ensure
284
- old_tempfile.close!
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
@@ -216,9 +216,9 @@ class Chef
216
216
  end
217
217
  end
218
218
 
219
- class MapCollision < Base
220
- target 25
221
- end
219
+ # id 25 was deleted
220
+
221
+ # id 3694 was deleted
222
222
 
223
223
  class ShellOut < Base
224
224
  target 26
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Adam Jacob (<adam@chef.io>)
3
- # Copyright:: Copyright 2008-2018, Chef Software Inc.
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
- # ==Chef::DSL::DataQuery
29
- # Provides DSL for querying data from the chef-server via search or data
30
- # bag.
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
@@ -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-2018, Chef Software Inc.
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
@@ -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
- self_ace.flags = 0
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
- if target_ace.flags & (CONTAINER_INHERIT_ACE | OBJECT_INHERIT_ACE) != 0
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 |= GENERIC_WRITE
225
+ mask |= WRITE
224
226
  else
225
227
  # Otherwise, assume it's an integer specifying the actual flags
226
228
  mask |= permission
@@ -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] == 2
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
@@ -330,7 +330,7 @@ class Chef
330
330
  raise Errno::ENOENT
331
331
  end
332
332
 
333
- Chef::Log.trace("Found bootstrap template in #{File.dirname(template_file)}")
333
+ Chef::Log.trace("Found bootstrap template: #{template_file}")
334
334
 
335
335
  template_file
336
336
  end
@@ -1,5 +1,6 @@
1
1
  sh -c '
2
- <%= "export https_proxy=\"#{knife_config[:bootstrap_proxy]}\"" if knife_config[:bootstrap_proxy] -%>
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"
@@ -26,7 +26,7 @@ class Chef
26
26
  option :ignore_knife_rb,
27
27
  short: "-i",
28
28
  long: "--ignore-knife-rb",
29
- description: "Ignore the current knife.rb configuration.",
29
+ description: "Ignore the current config.rb/knife.rb configuration.",
30
30
  default: false
31
31
 
32
32
  def run
@@ -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
- run_list = (node["run_list"]).to_s if config[:run_list]
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
@@ -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 ||= $1.to_i if original_exception.backtrace.find { |line| line =~ /\(erubis\):(\d+)/ }
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
@@ -1,6 +1,6 @@
1
1
  #
2
2
  # Author:: Lamont Granquist (<lamont@chef.io>)
3
- # Copyright:: Copyright 2014-2018, Chef Software Inc.
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
- COLLISION_WARNING_14 = <<~EOH.gsub(/\s+/, " ").strip
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, allow_cookbook_override: false, __core_override__: false, chef_version: nil, &block) # rubocop:disable Lint/UnderscorePrefixedVariableName
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
- # 4. No previous `provides` had `allow_cookbook_override`, either set to
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
- # For now, only log the warning.
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
@@ -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 %w{MAILTO PATH SHELL HOME}.include?(attr_name)
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
- newcron << "#{name}=#{value}\n"
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"