summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2019-01-24 13:27:01 -0800
committerGitHub <noreply@github.com>2019-01-24 13:27:01 -0800
commit53a921b20b11cf58d9eb8445ba172c90474d17d7 (patch)
treef9b3d27caacaf6f982219bdc77419e2754617643
parent092b56896d573aacfb70ce010d34ef386f4ca4b8 (diff)
parentd596064039ab1992295f667b9c3a96802e84e881 (diff)
downloadchef-53a921b20b11cf58d9eb8445ba172c90474d17d7.tar.gz
Merge pull request #8104 from MsysTechnologiesllc/Vijay/MSYS-945_Fix_for_apt_repository_is_creating_temporary_files_as_root_in_running_user_home_directory
Fix for apt_repository creating temporary files as root in running user home directory
-rw-r--r--lib/chef/provider/apt_repository.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb
index 96ffb5831f..75c7112fb8 100644
--- a/lib/chef/provider/apt_repository.rb
+++ b/lib/chef/provider/apt_repository.rb
@@ -21,6 +21,7 @@ require "chef/dsl/declare_resource"
require "chef/mixin/shell_out"
require "chef/http/simple"
require "chef/provider/noop"
+require "tmpdir"
class Chef
class Provider
@@ -200,13 +201,15 @@ class Chef
def install_key_from_uri(key)
key_name = key.gsub(/[^0-9A-Za-z\-]/, "_")
cached_keyfile = ::File.join(Chef::Config[:file_cache_path], key_name)
+ tmp_dir = Dir.mktmpdir(".gpg")
+ at_exit { FileUtils.remove_entry(tmp_dir) }
declare_resource(key_type(key), cached_keyfile) do
source key
mode "0644"
sensitive new_resource.sensitive
action :create
- verify "gpg %{path}"
+ verify "gpg --homedir #{tmp_dir} %{path}"
end
declare_resource(:execute, "apt-key add #{cached_keyfile}") do