Skip to content

Explain root command and service ownership trust - #24457

Merged
MikeMcQuaid merged 1 commit into
mainfrom
services-privileges
Nov 3, 2026
Merged

MikeMcQuaid merged 1 commit into
mainfrom
services-privileges

Conversation

@MikeMcQuaid

Copy link
Copy Markdown
Member
  • Document that sudo brew trusts the prefix owner and anyone able to modify Homebrew's code to execute arbitrary commands as root.
  • Describe edits to bin/brew and loaded code taking effect before command-specific checks or switching to another account.
  • Include this guidance in services, as-brew-user, as-console-user and --prefix help, plus the shared manual description.
  • State that services started with sudo run as root by default unless another service user is configured.
  • Describe ownership transfer as changing selected service paths and retain the warning about manual removal during package maintenance.
  • Explain that ownership changes to selected paths retain trust in accounts that can still modify the Homebrew installation.
  • Expand docs/FAQ.md, docs/Formula-Cookbook.md and docs/Installation.md with the prefix owner trust model and an example of modifying the brew entry point.

  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

Codex with GPT 6.1 Sol at Extra High effort, with local review and testing.


@coderabbitai

coderabbitai Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: e8b5b6f0-4531-470c-b142-b2599fc246be
Commits

Reviewing files that changed from the base of the PR and between 3e00149 and 4354d12.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Documentation
    • Expanded warnings across Homebrew commands and documentation to clarify that running brew with sudo trusts the Homebrew prefix owner and anyone able to modify Homebrew’s code to execute code as root.
    • Clarified that services started with sudo run as root unless configured otherwise, and that service software must also be trusted.
    • Added guidance on using brew services without sudo when root privileges are unnecessary.

The change adds sudo trust warnings to Homebrew command descriptions and documentation. It also expands root-service warnings and updates tests to check the service messages.

Changes: sudo and root-service warnings

Layer / File(s) Summary
General sudo trust warning
Library/Homebrew/manpages/brew.1.md.erb, docs/Manpage.md, manpages/brew.1, docs/FAQ.md, docs/Installation.md
The general brew documentation and FAQ state that sudo brew can run code as root before command checks or account switches.
Command-specific sudo warnings
Library/Homebrew/cmd/--prefix.rb, Library/Homebrew/cmd/as-brew-user.rb, Library/Homebrew/cmd/as-console-user.rb, docs/Manpage.md, manpages/brew.1
The --prefix, as-brew-user, and as-console-user descriptions and manpage entries explain the prefix-owner trust associated with sudo.
Root-service warnings and validation
Library/Homebrew/cmd/services.rb, Library/Homebrew/services/cli.rb, Library/Homebrew/test/services/cli_spec.rb, docs/Formula-Cookbook.md, docs/Manpage.md, manpages/brew.1
Service command text and documentation describe root execution and the trust required when Homebrew services run as root. Tests check the updated warnings.
Merge Risk: Minimal · previous review 3e001

The PR adds consistent sudo and root-service trust warnings without an evidenced behavioral regression.

Pre-merge checks: Passed 4
Check name Status Explanation
Title check Passed The title "Explain root command and service ownership trust" matches the changeset. The PR adds warnings to help text, manpages and docs that running brew with sudo trusts the prefix owner to run code…
Description check Passed The description is related to the changeset. It lists the sudo trust warning, the affected commands (services, as-brew-user, as-console-user, --prefix), the manual and FAQ updates, and the service roo…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "Explain root command and service ownership trust" matches the changeset. The PR adds warnings to help text, manpages and docs that running brew with sudo trusts the prefix owner to run code as root, and it covers service root ownership. The title names the main theme, though it does not name the specific docs and help text changes.

Full details: Description check

Explanation

The description is related to the changeset. It lists the sudo trust warning, the affected commands (services, as-brew-user, as-console-user, --prefix), the manual and FAQ updates, and the service root-ownership behaviour. It is detailed and on-topic. Some bullets repeat each other, but this does not make it off-topic.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: aa6d4593-b5b5-44c2-bca9-51dbeca8d2e5
Commits

Reviewing files that changed from the base of the PR and between fad7cba and 3e00149.

Files selected for processing: 12
  • Library/Homebrew/cmd/--prefix.rb
  • Library/Homebrew/cmd/as-brew-user.rb
  • Library/Homebrew/cmd/as-console-user.rb
  • Library/Homebrew/cmd/services.rb
  • Library/Homebrew/manpages/brew.1.md.erb
  • Library/Homebrew/services/cli.rb
  • Library/Homebrew/test/services/cli_spec.rb
  • docs/FAQ.md
  • docs/Formula-Cookbook.md
  • docs/Installation.md
  • docs/Manpage.md
  • manpages/brew.1

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

- Document that `sudo brew` trusts the prefix owner and anyone able to
  modify Homebrew's code to execute arbitrary commands as root.
- Describe edits to `bin/brew` and loaded code taking effect before
  command-specific checks or switching to another account.
- Include this guidance in `services`, `as-brew-user`, `as-console-user`
  and `--prefix` help, plus the shared manual description.
- State that services started with `sudo` run as root by default unless
  another service user is configured.
- Describe ownership transfer as changing selected service paths and
  retain the warning about manual removal during package maintenance.
- Explain that ownership changes to selected paths retain trust in
  accounts that can still modify the Homebrew installation.
- Expand `docs/FAQ.md`, `docs/Formula-Cookbook.md` and
  `docs/Installation.md` with the prefix owner trust model and an
  example of modifying the `brew` entry point.
- Regenerate the Markdown and roff manuals from their sources.
- Extend service message coverage and run command and manpage tests
  alongside type, style and documentation checks.
@MikeMcQuaid
MikeMcQuaid disabled auto-merge November 3, 2026 12:40
@MikeMcQuaid
MikeMcQuaid added this pull request to the merge queue Nov 3, 2026
Merged via the queue into main with commit 3c6ce58 Nov 3, 2026
55 checks passed
@MikeMcQuaid
MikeMcQuaid deleted the services-privileges branch November 3, 2026 12:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

⌂ 换网址