salt icon indicating copy to clipboard operation
salt copied to clipboard

modules.mac_brew_pkg: don't use sudo -i

Open rvandegrift opened this issue 3 years ago • 0 comments
trafficstars

What does this PR do?

sudo -i is used for starting interactive sessions. It causes sudo to tell the shell to run a login session, which triggers reading e.g. ~/.bash_profile.

Since that's intended for interactive use cases, it may produce output. But any output on stdout will be read as brew's json output - breaking states.pkg.

What issues does this PR fix or reference?

Fixes: https://github.com/saltstack/salt/issues/62394

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

  • [ ] Docs
  • [ ] Changelog - https://docs.saltproject.io/en/master/topics/development/changelog.html
  • [ ] Tests written/updated

Commits signed with GPG?

Yes/No

Please review Salt's Contributing Guide for best practices.

See GitHub's page on GPG signing for more information about signing commits with GPG.

rvandegrift avatar Jul 28 '22 19:07 rvandegrift

@rvandegrift Are you able to add a changelog file and a test for this?

MKLeb avatar Sep 13 '22 22:09 MKLeb

I expect this to break for any host on Apple Silicon since brew is not in PATH by default there. The only way I see around that is --preserve-env=PATH and telling users to add brew to PATH for root.

From [1], it sounds like they plan to move brew to /opt/homebrew on all platforms eventually. Seems like salt should hardcode that path (or at least check it first - though admittedly, it's annoying to have to re-implement PATH).

[1] - https://github.com/Homebrew/brew/issues/7857

rvandegrift avatar Sep 14 '22 02:09 rvandegrift

@rvandegrift Are you able to add a changelog file and a test for this?

Sorry I'm not too keen on doing release management work, especially with the specific requests about changelog format.

rvandegrift avatar Sep 14 '22 02:09 rvandegrift

As a homebrew maintainer I can assure you, there are no plans to move the install location on x86 macs. Eventually all macs will be ARM and therefore /opt/Homebrew by default though. But that doesn't account for systems where homebrew is installed in a custom location (like in a lot of big companies).

Essentially this change is a big regression in favor of a niche bugfix from my point of view.

SMillerDev avatar Sep 14 '22 05:09 SMillerDev

@rvandegrift, given @SMillerDev 's comments, I do think we should allow this as an option to the mac pkg commands. Something like interactive=True by default.

MKLeb avatar Sep 14 '22 19:09 MKLeb