Skip to content

Commit

Permalink
package: hard-code cwd to /tmp to execute brew
Browse files Browse the repository at this point in the history
If cwd is a directory the brew user can't write to
(e.g. if running with bolt as root where the working
directory is a private subdirectory under /tmp) brew
fails to run.

Resolves TheKevJames#101

Signed-off-by: Frank Lichtenheld <[email protected]>
  • Loading branch information
flichtenheld committed Jul 14, 2022
1 parent 53a5631 commit 48dbf54
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
8 changes: 6 additions & 2 deletions lib/puppet/provider/package/brew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ def self.execute(cmd, failonfail = false, combine = false)
if Puppet.features.bundled_environment?
Bundler.with_clean_env do
super(cmd, :uid => uid, :gid => gid, :combine => combine,
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
:custom_environment => { 'HOME' => home },
:cwd => '/tmp',
:failonfail => failonfail)
end
else
super(cmd, :uid => uid, :gid => gid, :combine => combine,
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
:custom_environment => { 'HOME' => home },
:cwd => '/tmp',
:failonfail => failonfail)
end
end

Expand Down
8 changes: 6 additions & 2 deletions lib/puppet/provider/package/brewcask.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ def self.execute(cmd, failonfail = false, combine = false)
if Puppet.features.bundled_environment?
Bundler.with_clean_env do
super(cmd, :uid => uid, :gid => gid, :combine => combine,
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
:custom_environment => { 'HOME' => home },
:cwd => '/tmp',
:failonfail => failonfail)
end
else
super(cmd, :uid => uid, :gid => gid, :combine => combine,
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
:custom_environment => { 'HOME' => home },
:cwd => '/tmp',
:failonfail => failonfail)
end
end

Expand Down
8 changes: 6 additions & 2 deletions lib/puppet/provider/package/homebrew.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,15 @@ def self.execute(cmd, failonfail = false, combine = false)
if Puppet.features.bundled_environment?
Bundler.with_clean_env do
super(cmd, :uid => uid, :gid => gid, :combine => combine,
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
:custom_environment => { 'HOME' => home },
:cwd => '/tmp',
:failonfail => failonfail)
end
else
super(cmd, :uid => uid, :gid => gid, :combine => combine,
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
:custom_environment => { 'HOME' => home },
:cwd => '/tmp',
:failonfail => failonfail)
end
end

Expand Down
8 changes: 6 additions & 2 deletions lib/puppet/provider/package/tap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,15 @@ def self.execute(cmd, failonfail = false, combine = false)
if Puppet.features.bundled_environment?
Bundler.with_clean_env do
super(cmd, :uid => uid, :gid => gid, :combine => combine,
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
:custom_environment => { 'HOME' => home },
:cwd => '/tmp',
:failonfail => failonfail)
end
else
super(cmd, :uid => uid, :gid => gid, :combine => combine,
:custom_environment => { 'HOME' => home }, :failonfail => failonfail)
:custom_environment => { 'HOME' => home },
:cwd => '/tmp',
:failonfail => failonfail)
end
end

Expand Down

0 comments on commit 48dbf54

Please sign in to comment.