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

brew.sh: allow --prefix to be run as root without warning #1255

Merged
merged 1 commit into from
Oct 10, 2016

Conversation

akirk
Copy link
Contributor

@akirk akirk commented Oct 10, 2016

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you successfully run brew tests with your changes locally?

In the files .bashrc or .zshrc the command brew --prefix xyz is often used to set the correct $PATH for executables. For example: export PATH="$(brew --prefix php70)/bin:$PATH"

When the *rc files are executed as root (e.g. via sudo -s) then --prefix should be considered a legitimate use of the brew command while under uid 0.

Old behavior:

$ brew --prefix gcc
Error: Running Homebrew as root is extremely dangerous. As Homebrew does not
drop privileges on installation you are giving all build scripts full access
to your system. As a result of the macOS sandbox not handling the root user
correctly HOMEBREW_NO_SANDBOX has been set so the sandbox will not be used. If
we have not merged a pull request to add privilege dropping by November 1st
2016 running Homebrew as root will be disabled. No Homebrew maintainers plan
to work on this functionality.
/usr/local/Cellar/gcc/6.2.0
$ brew --prefix gcc 2>/dev/null
/usr/local/Cellar/gcc/6.2.0

New behavior:

$ brew --prefix gcc
/usr/local/Cellar/gcc/6.2.0

@MikeMcQuaid
Copy link
Member

Seems reasonable. Can you also add --repository in there too? Thanks!

@akirk
Copy link
Contributor Author

akirk commented Oct 10, 2016

@MikeMcQuaid that's already handled in https://github.com/Homebrew/brew/blob/master/Library/Homebrew/brew.sh#L63, also --prefix without arguments is covered by that case block.

This PR is about the case when --prefix has an argument.

@MikeMcQuaid
Copy link
Member

Thanks for the quick response!

@MikeMcQuaid MikeMcQuaid merged commit bb96fd7 into Homebrew:master Oct 10, 2016
@Homebrew Homebrew locked and limited conversation to collaborators May 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants