Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replace su with Puppet::Util::Execution.execute #106

Merged
merged 1 commit into from
Jan 14, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions lib/puppet/provider/rbenvgem/default.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
Puppet::Type.type(:rbenvgem).provide :default do
desc "Maintains gems inside an RBenv setup"

commands :su => 'su'

def install
args = ['install', '--no-rdoc', '--no-ri']
args << "-v#{resource[:ensure]}" if !resource[:ensure].kind_of?(Symbol)
Expand Down Expand Up @@ -30,8 +28,20 @@ def gem_name
end

def gem(*args)
exe = "RBENV_VERSION=#{resource[:ruby]} " + resource[:rbenv] + '/bin/gem'
su('-', resource[:user], '-c', [exe, *args].join(' '))
require 'etc'
user = resource[:user]
home = Etc.getpwnam(user)[:dir]

exe = "#{resource[:rbenv]}/bin/gem"

Puppet::Util::Execution.execute([exe, *args].join(' '),
:uid => user,
:failonfail => true,
:custom_environment => {
'HOME' => home,
'RBENV_VERSION' => resource[:ruby],
}
)
end

def list(where = :local)
Expand Down