Permalink
Browse files

Explicitly set random file for OpenSSL. Fails otherwise. Grrrr.

Conflicts:

	lib/puppet/provider/java_ks/keytool.rb

Merged by: Reid Vandewiele <reid@puppetlabs.com>

Note: during the merge I took the liberty of modifying the means by which
RANDFILE was set for code execution, so as to avoid leaving the env
variable set in the Puppet process proper
  • Loading branch information...
1 parent 823833d commit 8866ef33640c22ba07531544b1e59749db8b99d9 Jens Braeuer committed with reidmv Jan 19, 2013
Showing with 14 additions and 1 deletion.
  1. +14 −1 lib/puppet/provider/java_ks/keytool.rb
View
15 lib/puppet/provider/java_ks/keytool.rb
@@ -20,8 +20,21 @@ def to_pkcs12
tmpfile = Tempfile.new("#{@resource[:name]}.")
tmpfile.write(@resource[:password])
tmpfile.flush
- output = run_command(cmd, false, tmpfile)
+
+ # To maintain backwards compatibility with Puppet 2.7.x, resort to ugly
+ # code to make sure RANDFILE is passed as an environment variable to the
+ # openssl command but not retained in the Puppet process environment.
+ randfile = Tempfile.new("#{@resource[:name]}.")
+ if Puppet::Util::Execution.respond_to?(:withenv)
+ withenv = Puppet::Util::Execution.method(:withenv)
+ else
+ withenv = Puppet::Util.method(:withenv)
+ end
+ output = withenv.call('RANDFILE' => randfile.path) do
+ run_command(cmd, false, tmpfile)
+ end
tmpfile.close!
+ randfile.close!
return output
end

0 comments on commit 8866ef3

Please sign in to comment.