Skip to content

Commit 6c0a2e4

Browse files
Dominic Clealbmjen
Dominic Cleal
authored andcommitted
(MODULES-2185) Fix withenv execution under Puppet 2.7
When executing a command with environment variables, the withenv helper under Puppet 2.7 is on Puppet::Util::Execution and on 3.0 to 3.3, it's on Puppet::Util.
1 parent 9063dd5 commit 6c0a2e4

File tree

1 file changed

+6
-1
lines changed
  • lib/puppet/provider/postgresql_psql

1 file changed

+6
-1
lines changed

lib/puppet/provider/postgresql_psql/ruby.rb

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ def get_environment
5050
def run_command(command, user, group)
5151
command = command.join ' '
5252
environment = get_environment
53-
if Puppet::PUPPETVERSION.to_f < 3.4
53+
if Puppet::PUPPETVERSION.to_f < 3.0
54+
require 'puppet/util/execution'
55+
Puppet::Util::Execution.withenv environment do
56+
Puppet::Util::SUIDManager.run_and_capture(command, user, group)
57+
end
58+
elsif Puppet::PUPPETVERSION.to_f < 3.4
5459
Puppet::Util.withenv environment do
5560
Puppet::Util::SUIDManager.run_and_capture(command, user, group)
5661
end

0 commit comments

Comments
 (0)