summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-06-23 09:20:28 -0700
committerGitHub <noreply@github.com>2020-06-23 09:20:28 -0700
commite5cbe8e7f9313bd6ae8c2c336fb4f0d9332b978f (patch)
tree0e76ed5931a03471ef7749ea7b5228c1d83d8322
parentb6b5e2d2c1e50dd1fe574c9da406d45843c022aa (diff)
parent3f09022631ce031964500bec0093de8f3c4b9cc4 (diff)
downloadchef-e5cbe8e7f9313bd6ae8c2c336fb4f0d9332b978f.tar.gz
Merge pull request #10036 from chef/cron_access_15
Support for AIX and Solaris in cron_allow resource
-rw-r--r--lib/chef/resource/cron_access.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/chef/resource/cron_access.rb b/lib/chef/resource/cron_access.rb
index 9939437a2d..7ec5387c0c 100644
--- a/lib/chef/resource/cron_access.rb
+++ b/lib/chef/resource/cron_access.rb
@@ -27,7 +27,7 @@ class Chef
provides(:cron_manage) # legacy name @todo in Chef 15 we should { true } this so it wins over the cookbook
introduced "14.4"
- description "Use the cron_access resource to manage the /etc/cron.allow and /etc/cron.deny files."
+ description "Use the **cron_access** resource to manage cron's cron.allow and cron.deny files. Note: This resource previously shipped in the `cron` cookbook as `cron_manage`, which it can still be used as for backwards compatibility with existing Chef Infra Client releases."
examples <<~DOC
Add the mike user to cron.allow
```ruby
@@ -54,11 +54,18 @@ class Chef
description: "An optional property to set the user name if it differs from the resource block's name.",
name_property: true
+ CRON_PATHS = {
+ "aix" => "/var/adm/cron",
+ "solaris" => "/etc/cron.d",
+ "default" => "/etc",
+ }.freeze
+
action :allow do
description "Add the user to the cron.allow file."
+ allow_path = ::File.join(value_for_platform_family(CRON_PATHS), "cron.allow")
with_run_context :root do
- edit_resource(:template, "/etc/cron.allow") do |new_resource|
+ edit_resource(:template, allow_path) do |new_resource|
source ::File.expand_path("../support/cron_access.erb", __FILE__)
local true
mode "0600"
@@ -72,9 +79,10 @@ class Chef
action :deny do
description "Add the user to the cron.deny file."
+ deny_path = ::File.join(value_for_platform_family(CRON_PATHS), "cron.deny")
with_run_context :root do
- edit_resource(:template, "/etc/cron.deny") do |new_resource|
+ edit_resource(:template, deny_path) do |new_resource|
source ::File.expand_path("../support/cron_access.erb", __FILE__)
local true
mode "0600"