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

[FEAT]: Set $HOME in postflight plist modification in salt cask #93

Closed
lmf-mx opened this issue Jan 9, 2024 · 4 comments · Fixed by #94
Closed

[FEAT]: Set $HOME in postflight plist modification in salt cask #93

lmf-mx opened this issue Jan 9, 2024 · 4 comments · Fixed by #94
Assignees
Labels
enhancement New feature or request

Comments

@lmf-mx
Copy link

lmf-mx commented Jan 9, 2024

Description

The process spawned by the minion plist has no HOME environment variable set for the root user it runs as. This is not seen when running from the minion with salt-call.

When running from the master, due to the change in brew in Homebrew/brew@4184546 pkg.installed fails with an error about missing HOME passed in from brew. The lack of a HOME variable can be seen by running salt 'minion' environ.items from a remote master.

I propose setting the HOME variable in the postflight task in addition to the HOMEBREW_PREFIX variable. On an M2 on Sonoma, this is /var/root for the root user. Alternatively, I manually set it to /opt/salt in the plist.

Additional Information

No response

@lmf-mx lmf-mx added the enhancement New feature or request label Jan 9, 2024
@cdalvaro
Copy link
Owner

Hi @lmf-mx, thank you for opening this issue. I know really well what are you talking about... I fixed this issue long time ago, but the fix was accepted recently saltstack/salt#64924

So, hopefully, salt 3007 won't have this issue.

In the meantime, I think I can add the environment variable as a workaround for this issue. I'll remove it once salt 3007 is available.

@lmf-mx
Copy link
Author

lmf-mx commented Jan 10, 2024

Hi @cdalvaro, I saw the PR you referenced. Maybe I'm missing something, but I don't see anything that sets the HOME variable in the spawned minions environment. The change in brew specifically tests for that now, aside from the HOMEBREW_PREFIX issue.

@cdalvaro
Copy link
Owner

Hi @cdalvaro, I saw the PR you referenced. Maybe I'm missing something, but I don't see anything that sets the HOME variable in the spawned minions environment. The change in brew specifically tests for that now, aside from the HOMEBREW_PREFIX issue.

The fix can be a bit obscure, but in the end, the main problem was here. In order to get the brew prefix, salt was asking brew for it, but running brew as root.

Now, the way to get the homebrew's prefix is a little more complex, looking first for the HOMEBREW_PREFIX env variable. Then, if it is not present, salt asks brew for its prefix, but this time running the command as brew's owner user (with is HOME directory defined) instead of running as root.

@lmf-mx
Copy link
Author

lmf-mx commented Jan 10, 2024

Thanks for the explanation. I follow now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants