summaryrefslogtreecommitdiff
path: root/lib/chef
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef')
-rw-r--r--lib/chef/chef_fs/command_line.rb4
-rw-r--r--lib/chef/client.rb2
-rw-r--r--lib/chef/cookbook/cookbook_version_loader.rb4
-rw-r--r--lib/chef/file_content_management/tempfile.rb2
-rw-r--r--lib/chef/provider/cookbook_file/content.rb2
-rw-r--r--lib/chef/provider/cron/unix.rb2
-rw-r--r--lib/chef/provider/file/content.rb2
-rw-r--r--lib/chef/provider/remote_file/ftp.rb2
-rw-r--r--lib/chef/provider/remote_file/http.rb2
-rw-r--r--lib/chef/provider/remote_file/local_file.rb2
-rw-r--r--lib/chef/provider/remote_file/network_file.rb2
-rw-r--r--lib/chef/provider/remote_file/sftp.rb2
-rw-r--r--lib/chef/provider/template/content.rb2
-rw-r--r--lib/chef/provider/user/solaris.rb2
-rw-r--r--lib/chef/resource/habitat_config.rb2
-rw-r--r--lib/chef/resource/osx_profile.rb2
-rw-r--r--lib/chef/resource/windows_security_policy.rb2
-rw-r--r--lib/chef/util/diff.rb2
-rw-r--r--lib/chef/win32/handle.rb3
19 files changed, 22 insertions, 21 deletions
diff --git a/lib/chef/chef_fs/command_line.rb b/lib/chef/chef_fs/command_line.rb
index 16d9bd93f4..123ddd2427 100644
--- a/lib/chef/chef_fs/command_line.rb
+++ b/lib/chef/chef_fs/command_line.rb
@@ -275,11 +275,11 @@ class Chef
# Copy to tempfiles before diffing
# TODO don't copy things that are already in files! Or find an in-memory diff algorithm
- new_tempfile = Tempfile.new("new")
+ new_tempfile = Tempfile.create("new")
new_tempfile.write(new_value)
new_tempfile.close
- old_tempfile = Tempfile.new("old")
+ old_tempfile = Tempfile.create("old")
old_tempfile.write(old_value)
old_tempfile.close
diff --git a/lib/chef/client.rb b/lib/chef/client.rb
index e5fcd56eb0..3fc4219110 100644
--- a/lib/chef/client.rb
+++ b/lib/chef/client.rb
@@ -816,7 +816,7 @@ class Chef
def self.import_pfx_to_store(new_pfx)
password = ::Chef::HTTP::Authenticator.get_cert_password
require "win32-certstore"
- tempfile = Tempfile.new("#{Chef::Config[:node_name]}.pfx")
+ tempfile = Tempfile.create("#{Chef::Config[:node_name]}.pfx")
File.open(tempfile, "wb") { |f| f.print new_pfx.to_der }
store = ::Win32::Certstore.open("MY")
diff --git a/lib/chef/cookbook/cookbook_version_loader.rb b/lib/chef/cookbook/cookbook_version_loader.rb
index 00cf22e6da..6a559bcba1 100644
--- a/lib/chef/cookbook/cookbook_version_loader.rb
+++ b/lib/chef/cookbook/cookbook_version_loader.rb
@@ -64,7 +64,7 @@ class Chef
# Load the cookbook. Raises an error if the cookbook_path given to the
# constructor doesn't point to a valid cookbook.
- def load!
+ def load!
metadata # force lazy evaluation to occur
# re-raise any exception that occurred when reading the metadata
@@ -138,7 +138,7 @@ class Chef
# their metadata. We only rescue StandardError because you have to be
# doing something *really* terrible to raise an exception that inherits
# directly from Exception in your metadata.rb file.
- rescue StandardError => e
+ rescue StandardError => e
@metadata_error = e
@metadata
end
diff --git a/lib/chef/file_content_management/tempfile.rb b/lib/chef/file_content_management/tempfile.rb
index 27efe34191..371ace600e 100644
--- a/lib/chef/file_content_management/tempfile.rb
+++ b/lib/chef/file_content_management/tempfile.rb
@@ -61,7 +61,7 @@ class Chef
#
# These are important for windows to get permissions right, and may
# be useful for SELinux and other ACL approaches. Please use them
- # as the arguments to Tempfile.new() consistently.
+ # as the arguments to Tempfile.create() consistently.
#
def tempfile_basename
basename = ::File.basename(@new_resource.path, tempfile_extension)
diff --git a/lib/chef/provider/cookbook_file/content.rb b/lib/chef/provider/cookbook_file/content.rb
index 6cc2f33f34..50676a154d 100644
--- a/lib/chef/provider/cookbook_file/content.rb
+++ b/lib/chef/provider/cookbook_file/content.rb
@@ -32,7 +32,7 @@ class Chef
if file_cache_location.nil?
nil
else
- tempfile = Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile
+ tempfile = Chef::FileContentManagement::Tempfile.create(@new_resource).tempfile
tempfile.close
logger.trace("#{@new_resource} staging #{file_cache_location} to #{tempfile.path}")
FileUtils.cp(file_cache_location, tempfile.path)
diff --git a/lib/chef/provider/cron/unix.rb b/lib/chef/provider/cron/unix.rb
index cb3a2f9a61..2fec7455e1 100644
--- a/lib/chef/provider/cron/unix.rb
+++ b/lib/chef/provider/cron/unix.rb
@@ -45,7 +45,7 @@ class Chef
end
def write_crontab(crontab)
- tempcron = Tempfile.new("chef-cron")
+ tempcron = Tempfile.create("chef-cron")
tempcron << crontab
tempcron.flush
tempcron.chmod(0644)
diff --git a/lib/chef/provider/file/content.rb b/lib/chef/provider/file/content.rb
index 30ca38d3b6..0383c54df5 100644
--- a/lib/chef/provider/file/content.rb
+++ b/lib/chef/provider/file/content.rb
@@ -25,7 +25,7 @@ class Chef
class Content < Chef::FileContentManagement::ContentBase
def file_for_provider
if @new_resource.content
- tempfile = Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile
+ tempfile = Chef::FileContentManagement::Tempfile.create(@new_resource).tempfile
tempfile.write(@new_resource.content)
tempfile.close
tempfile
diff --git a/lib/chef/provider/remote_file/ftp.rb b/lib/chef/provider/remote_file/ftp.rb
index 44a6d1c6e8..d2d9ed7881 100644
--- a/lib/chef/provider/remote_file/ftp.rb
+++ b/lib/chef/provider/remote_file/ftp.rb
@@ -140,7 +140,7 @@ class Chef
# Fetches using Net::FTP, returns a Tempfile with the content
def get
- tempfile = Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile
+ tempfile = Chef::FileContentManagement::Tempfile.create(@new_resource).tempfile
if typecode
ftp.voidcmd("TYPE #{typecode.upcase}")
end
diff --git a/lib/chef/provider/remote_file/http.rb b/lib/chef/provider/remote_file/http.rb
index 40f64a0e85..3ee3cec00f 100644
--- a/lib/chef/provider/remote_file/http.rb
+++ b/lib/chef/provider/remote_file/http.rb
@@ -63,7 +63,7 @@ class Chef
def fetch
http = Chef::HTTP::Simple.new(uri, http_client_opts)
- orig_tempfile = Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile
+ orig_tempfile = Chef::FileContentManagement::Tempfile.create(@new_resource).tempfile
if want_progress?
tempfile = http.streaming_request_with_progress(uri, headers, orig_tempfile) do |size, total|
events.resource_update_progress(new_resource, size, total, progress_interval)
diff --git a/lib/chef/provider/remote_file/local_file.rb b/lib/chef/provider/remote_file/local_file.rb
index c68c4eecd5..345607e4d8 100644
--- a/lib/chef/provider/remote_file/local_file.rb
+++ b/lib/chef/provider/remote_file/local_file.rb
@@ -48,7 +48,7 @@ class Chef
# Fetches the file at uri, returning a Tempfile-like File handle
def fetch
- tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile
+ tempfile = Chef::FileContentManagement::Tempfile.create(new_resource).tempfile
Chef::Log.trace("#{new_resource} staging #{source_path} to #{tempfile.path}")
FileUtils.cp(source_path, tempfile.path)
tempfile.close if tempfile
diff --git a/lib/chef/provider/remote_file/network_file.rb b/lib/chef/provider/remote_file/network_file.rb
index b08aeb55cc..2d3522e8cb 100644
--- a/lib/chef/provider/remote_file/network_file.rb
+++ b/lib/chef/provider/remote_file/network_file.rb
@@ -40,7 +40,7 @@ class Chef
# windows only
def fetch
begin
- tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile
+ tempfile = Chef::FileContentManagement::Tempfile.create(new_resource).tempfile
Chef::Log.trace("#{new_resource} staging #{@source} to #{tempfile.path}")
with_user_context(new_resource.remote_user, new_resource.remote_password, new_resource.remote_domain, new_resource.authentication) do
diff --git a/lib/chef/provider/remote_file/sftp.rb b/lib/chef/provider/remote_file/sftp.rb
index be2a34fc54..3a788b6304 100644
--- a/lib/chef/provider/remote_file/sftp.rb
+++ b/lib/chef/provider/remote_file/sftp.rb
@@ -97,7 +97,7 @@ class Chef
def get
tempfile =
- Chef::FileContentManagement::Tempfile.new(@new_resource).tempfile
+ Chef::FileContentManagement::Tempfile.create(@new_resource).tempfile
sftp.download!(uri.path, tempfile.path)
tempfile.close if tempfile
tempfile
diff --git a/lib/chef/provider/template/content.rb b/lib/chef/provider/template/content.rb
index 00a82fea79..338b9a990d 100644
--- a/lib/chef/provider/template/content.rb
+++ b/lib/chef/provider/template/content.rb
@@ -74,7 +74,7 @@ class Chef
context._extend_modules(new_resource.helper_modules)
output = context.render_template(template_location)
- tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile
+ tempfile = Chef::FileContentManagement::Tempfile.create(new_resource).tempfile
tempfile.binmode
tempfile.write(output)
tempfile.close
diff --git a/lib/chef/provider/user/solaris.rb b/lib/chef/provider/user/solaris.rb
index abf6cd94c8..333a9f7184 100644
--- a/lib/chef/provider/user/solaris.rb
+++ b/lib/chef/provider/user/solaris.rb
@@ -121,7 +121,7 @@ class Chef
# XXX: this was straight copypasta'd back in 2013 and I don't think we've ever evaluated using
# a pipe to passwd(1) or evaluating modern ruby-shadow. See https://github.com/chef/chef/pull/721
def write_shadow_file
- buffer = Tempfile.new("shadow", "/etc")
+ buffer = Tempfile.create("shadow", "/etc")
::File.open(PASSWORD_FILE) do |shadow_file|
shadow_file.each do |entry|
user = entry.split(":").first
diff --git a/lib/chef/resource/habitat_config.rb b/lib/chef/resource/habitat_config.rb
index 5c06fa43f5..d4a3c2c582 100644
--- a/lib/chef/resource/habitat_config.rb
+++ b/lib/chef/resource/habitat_config.rb
@@ -85,7 +85,7 @@ class Chef
opts << ["--remote-sup", new_resource.remote_sup] if new_resource.remote_sup
opts << ["--user", new_resource.user] if new_resource.user
- tempfile = Tempfile.new(["habitat_config", ".toml"])
+ tempfile = Tempfile.create(["habitat_config", ".toml"])
begin
tempfile.write(render_toml(new_resource.config))
tempfile.close
diff --git a/lib/chef/resource/osx_profile.rb b/lib/chef/resource/osx_profile.rb
index f962e91636..f8ca205b56 100644
--- a/lib/chef/resource/osx_profile.rb
+++ b/lib/chef/resource/osx_profile.rb
@@ -282,7 +282,7 @@ class Chef
# command rather than deploying the file to somewhere on disk. There's some
# better API that needs extracting here.
new_resource.path(Chef::FileCache.create_cache_path("profiles"))
- tempfile = Chef::FileContentManagement::Tempfile.new(new_resource).tempfile
+ tempfile = Chef::FileContentManagement::Tempfile.create(new_resource).tempfile
tempfile.write(new_profile_hash.to_plist)
tempfile.close
tempfile.path
diff --git a/lib/chef/resource/windows_security_policy.rb b/lib/chef/resource/windows_security_policy.rb
index ff3597eeee..679a7de88f 100644
--- a/lib/chef/resource/windows_security_policy.rb
+++ b/lib/chef/resource/windows_security_policy.rb
@@ -105,7 +105,7 @@ class Chef
security_option = new_resource.secoption
security_value = new_resource.secvalue
- file = Tempfile.new(["#{security_option}", ".inf"])
+ file = Tempfile.create(["#{security_option}", ".inf"])
case security_option
when "LockoutBadCount"
cmd = "net accounts /LockoutThreshold:#{security_value}"
diff --git a/lib/chef/util/diff.rb b/lib/chef/util/diff.rb
index 0774dea813..9db91a94f3 100644
--- a/lib/chef/util/diff.rb
+++ b/lib/chef/util/diff.rb
@@ -62,7 +62,7 @@ class Chef
tempfile = nil
unless File.exist?(file)
Chef::Log.trace("File #{file} does not exist to diff against, using empty tempfile")
- tempfile = Tempfile.new("chef-diff")
+ tempfile = Tempfile.create("chef-diff")
file = tempfile.path
end
yield file
diff --git a/lib/chef/win32/handle.rb b/lib/chef/win32/handle.rb
index 1b0257ed68..5c97ed3b14 100644
--- a/lib/chef/win32/handle.rb
+++ b/lib/chef/win32/handle.rb
@@ -41,7 +41,8 @@ class Chef
# According to http://msdn.microsoft.com/en-us/library/windows/desktop/ms683179(v=vs.85).aspx, it is not necessary
# to close the pseudo handle returned by the GetCurrentProcess function. The docs also say that it doesn't hurt to call
# CloseHandle on it. However, doing so from inside of Ruby always seems to produce an invalid handle error.
- proc { close_handle(handle) unless handle == CURRENT_PROCESS_HANDLE }
+ # jfm - getting the errors noted just above but only on Server 2012. So Strange. So maybe a Windows bug that got fixed?
+ # proc { close_handle(handle) unless handle == CURRENT_PROCESS_HANDLE }
end
def self.close_handle(handle)