summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCrae <john.mccrae@progress.com>2022-10-02 09:33:38 +0000
committerJohn McCrae <john.mccrae@progress.com>2022-10-02 09:33:38 +0000
commit77649eaef374824630b2c0837c913f9c37820fdc (patch)
tree2481d3e9c2c0ef0da27df08d07a4e3babc3fd001
parentce22cd0f37e2dd550656cbda409f1c00656da980 (diff)
downloadchef-77649eaef374824630b2c0837c913f9c37820fdc.tar.gz
replacing Tempfile.new with Tempfile.create
Signed-off-by: John McCrae <john.mccrae@progress.com>
-rw-r--r--knife/lib/chef/knife/bootstrap/train_connector.rb2
-rw-r--r--knife/spec/unit/knife/data_bag_secret_options_spec.rb2
-rw-r--r--lib/chef/client.rb2
-rw-r--r--lib/chef/provider/file.rb2
-rw-r--r--lib/chef/provider/remote_file/http.rb2
-rw-r--r--lib/chef/resource/habitat_config.rb2
-rw-r--r--lib/chef/resource/windows_security_policy.rb2
-rw-r--r--lib/chef/util/diff.rb2
-rw-r--r--spec/functional/resource/powershell_script_spec.rb4
-rw-r--r--spec/integration/recipes/accumulator_spec.rb2
-rw-r--r--spec/unit/application_spec.rb3
-rw-r--r--spec/unit/client_spec.rb3
-rw-r--r--spec/unit/file_content_management/deploy/mv_unix_spec.rb6
-rw-r--r--spec/unit/mixin/openssl_helper_spec.rb9
-rw-r--r--spec/unit/provider/user/solaris_spec.rb3
-rw-r--r--spec/unit/util/diff_spec.rb4
16 files changed, 29 insertions, 21 deletions
diff --git a/knife/lib/chef/knife/bootstrap/train_connector.rb b/knife/lib/chef/knife/bootstrap/train_connector.rb
index ef654a05b9..de70153a66 100644
--- a/knife/lib/chef/knife/bootstrap/train_connector.rb
+++ b/knife/lib/chef/knife/bootstrap/train_connector.rb
@@ -159,7 +159,7 @@ class Chef
nil
ensure
t.close
- t.unlink
+ # t.unlink
end
#
diff --git a/knife/spec/unit/knife/data_bag_secret_options_spec.rb b/knife/spec/unit/knife/data_bag_secret_options_spec.rb
index 225a894d5d..16beb4ae4e 100644
--- a/knife/spec/unit/knife/data_bag_secret_options_spec.rb
+++ b/knife/spec/unit/knife/data_bag_secret_options_spec.rb
@@ -44,7 +44,7 @@ describe Chef::Knife::DataBagSecretOptions do
after do
secret_file.close
- secret_file.unlink
+ # secret_file.unlink
end
describe "#validate_secrets" do
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index 1aea8e68f6..9a23d5de3c 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -822,7 +822,7 @@ class Chef
store = ::Win32::Certstore.open("MY")
store.add_pfx(tempfile, password, CRYPT_EXPORTABLE)
- tempfile.unlink
+ tempfile.close
end
#
diff --git a/lib/chef/provider/file.rb b/lib/chef/provider/file.rb
index 4ac86a6c8a..c1ff3e7346 100644
--- a/lib/chef/provider/file.rb
+++ b/lib/chef/provider/file.rb
@@ -421,7 +421,7 @@ class Chef
# unlink necessary to clean up in why-run mode
tempfile.close
- tempfile.unlink
+ # tempfile.unlink
end
# This logic ideally will be made into some kind of generic
diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb
index 40f64a0e85..40d95ea6e1 100644
--- a/lib/chef/provider/remote_file/http.rb
+++ b/lib/chef/provider/remote_file/http.rb
@@ -78,7 +78,7 @@ class Chef
# cache_control shows the file is unchanged, so we got back nil from the streaming_request above, and it is
# now our responsibility to unlink the tempfile we created
orig_tempfile.close
- orig_tempfile.unlink
+ # orig_tempfile.unlink
end
tempfile
end
diff --git a/lib/chef/resource/habitat_config.rb b/lib/chef/resource/habitat_config.rb
index bad5f458f9..f9f7a137cd 100644
--- a/lib/chef/resource/habitat_config.rb
+++ b/lib/chef/resource/habitat_config.rb
@@ -94,7 +94,7 @@ class Chef
hab("config", "apply", opts, new_resource.service_group, incarnation, tempfile.path)
ensure
tempfile.close
- tempfile.unlink
+ # tempfile.unlink
end
end
end
diff --git a/lib/chef/resource/windows_security_policy.rb b/lib/chef/resource/windows_security_policy.rb
index 679a7de88f..8987c290e4 100644
--- a/lib/chef/resource/windows_security_policy.rb
+++ b/lib/chef/resource/windows_security_policy.rb
@@ -127,7 +127,7 @@ class Chef
cmd = "C:\\Windows\\System32\\secedit /configure /db C:\\windows\\security\\new.sdb /cfg #{file_path} /areas SECURITYPOLICY"
end
shell_out!(cmd)
- file.unlink
+ file.close
end
end
diff --git a/lib/chef/util/diff.rb b/lib/chef/util/diff.rb
index 1927883333..edf04b3b25 100644
--- a/lib/chef/util/diff.rb
+++ b/lib/chef/util/diff.rb
@@ -70,7 +70,7 @@ class Chef
yield file
unless tempfile.nil?
tempfile.close
- tempfile.unlink
+ # tempfile.unlink
end
end
diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb
index b6643c6cf6..5d9e0e1adc 100644
--- a/spec/functional/resource/powershell_script_spec.rb
+++ b/spec/functional/resource/powershell_script_spec.rb
@@ -65,7 +65,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
resource.run_action(:run)
ensure
file.close
- file.unlink
+ # file.unlink
end
end
@@ -91,7 +91,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
expect { resource.run_action(:run) }.not_to raise_error
ensure
file.close
- file.unlink
+ # file.unlink
end
end
diff --git a/spec/integration/recipes/accumulator_spec.rb b/spec/integration/recipes/accumulator_spec.rb
index 2667a83cf6..374f490229 100644
--- a/spec/integration/recipes/accumulator_spec.rb
+++ b/spec/integration/recipes/accumulator_spec.rb
@@ -24,7 +24,7 @@ describe "Accumulators" do
t = Tempfile.create("chef_accumulator_test")
path = t.path
t.close
- t.unlink
+ # t.unlink
path
end
diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb
index ba63c53aed..9e66f3b16c 100644
--- a/spec/unit/application_spec.rb
+++ b/spec/unit/application_spec.rb
@@ -512,7 +512,8 @@ describe Chef::Application do
end
after(:each) do
- @config_file.unlink
+ # @config_file.unlink
+ @config_file.close
end
it "should raise informative fatals for badly written config" do
diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb
index 7f02eacb39..7f74a19ab5 100644
--- a/spec/unit/client_spec.rb
+++ b/spec/unit/client_spec.rb
@@ -465,7 +465,8 @@ describe Chef::Client do
after do
@tmpout.close unless @tmpout.closed?
- @tmpout.unlink
+ # @tmpout.unlink
+ @tmpout.close
end
it "configures the formatter for the file path" do
diff --git a/spec/unit/file_content_management/deploy/mv_unix_spec.rb b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
index 7e730f8362..ec12fe96df 100644
--- a/spec/unit/file_content_management/deploy/mv_unix_spec.rb
+++ b/spec/unit/file_content_management/deploy/mv_unix_spec.rb
@@ -107,8 +107,10 @@ describe Chef::FileContentManagement::Deploy::MvUnix do
File.chmod(04755, target_file.path)
content_deployer.deploy(staging_file.path, target_file.path)
expect(::File.stat(target_file.path).mode & 07777).to eql(04755)
- staging_file.unlink
- target_file.unlink
+ # staging_file.unlink
+ # target_file.unlink
+ staging_file.close
+ target_file.close
end
end
end
diff --git a/spec/unit/mixin/openssl_helper_spec.rb b/spec/unit/mixin/openssl_helper_spec.rb
index 3a974f032f..3116651e43 100644
--- a/spec/unit/mixin/openssl_helper_spec.rb
+++ b/spec/unit/mixin/openssl_helper_spec.rb
@@ -100,7 +100,8 @@ describe Chef::Mixin::OpenSSLHelper do
end
after(:each) do
- @dhparam_file.unlink
+ # @dhparam_file.unlink
+ @dhparam_file.close
end
end
@@ -211,7 +212,8 @@ describe Chef::Mixin::OpenSSLHelper do
end
after(:each) do
- @crlfile.unlink
+ # @crlfile.unlink
+ @crlfile.close
end
end
@@ -887,7 +889,8 @@ describe Chef::Mixin::OpenSSLHelper do
end
after(:each) do
- @certfile.unlink
+ # @certfile.unlink
+ @certfile.close
end
end
end
diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb
index 4d446e0b5b..799af75d5e 100644
--- a/spec/unit/provider/user/solaris_spec.rb
+++ b/spec/unit/provider/user/solaris_spec.rb
@@ -76,7 +76,8 @@ describe Chef::Provider::User::Solaris do
new_resource.password "verysecurepassword"
provider.manage_user
expect(::File.read(password_file.path)).to match(/adam:verysecurepassword:/)
- password_file.unlink
+ # password_file.unlink
+ password_file.close
end
end
diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb
index 384f0be503..b36ffd8bf0 100644
--- a/spec/unit/util/diff_spec.rb
+++ b/spec/unit/util/diff_spec.rb
@@ -37,13 +37,13 @@ shared_examples_for "a diff util" do
it "produces a diff even if the old_file does not exist" do
old_tempfile.close
- old_tempfile.unlink
+ # old_tempfile.unlink
expect(differ.for_output).to eql(["(no diff)"])
end
it "produces a diff even if the new_file does not exist" do
new_tempfile.close
- new_tempfile.unlink
+ # new_tempfile.unlink
expect(differ.for_output).to eql(["(no diff)"])
end