diff options
author | Tim Smith <tsmith@chef.io> | 2019-03-04 10:45:51 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-04 10:45:51 -0800 |
commit | fa32383e548b1aa282639aa64e1d96780c1f823d (patch) | |
tree | 5e26a2673e58b9474f62951acc0bae4b0b1adb97 | |
parent | 16e791b44ebbd288014d60fa009c974f7ee0178e (diff) | |
parent | 9d90ac18db6b868d4ff96a6cd10ff32f51adc48b (diff) | |
download | chef-fa32383e548b1aa282639aa64e1d96780c1f823d.tar.gz |
Merge pull request #8264 from chef/openssl_14
openssl_dhparam: allow changing file mode on subsequent runs
-rw-r--r-- | lib/chef/resource/openssl_dhparam.rb | 23 | ||||
-rw-r--r-- | spec/unit/resource/openssl_dhparam.rb | 5 |
2 files changed, 16 insertions, 12 deletions
diff --git a/lib/chef/resource/openssl_dhparam.rb b/lib/chef/resource/openssl_dhparam.rb index f2f3b679e4..f0e82ebfd4 100644 --- a/lib/chef/resource/openssl_dhparam.rb +++ b/lib/chef/resource/openssl_dhparam.rb @@ -57,20 +57,19 @@ class Chef action :create do description "Create the dhparam file." - + dhparam_content = nil unless dhparam_pem_valid?(new_resource.path) - converge_by("Create a dhparam file #{new_resource.path}") do - dhparam_content = gen_dhparam(new_resource.key_length, new_resource.generator).to_pem + dhparam_content = gen_dhparam(new_resource.key_length, new_resource.generator).to_pem + Chef::Log.debug("Valid dhparam content not found at #{new_resource.path}, creating new") + end - file new_resource.path do - action :create - owner new_resource.owner unless new_resource.owner.nil? - group new_resource.group unless new_resource.group.nil? - mode new_resource.mode - sensitive true - content dhparam_content - end - end + file new_resource.path do + action :create + owner new_resource.owner + group new_resource.group + mode new_resource.mode + sensitive true + content dhparam_content end end end diff --git a/spec/unit/resource/openssl_dhparam.rb b/spec/unit/resource/openssl_dhparam.rb index 10c5399c33..e225b0317c 100644 --- a/spec/unit/resource/openssl_dhparam.rb +++ b/spec/unit/resource/openssl_dhparam.rb @@ -53,4 +53,9 @@ describe Chef::Resource::OpensslDhparam do expect { resource.key_length 1234 }.to raise_error(ArgumentError) end + it "sets the mode which user provides for existing file" do + resource.mode "0600" + expect(resource.mode).to eql("0600") + end + end |