Skip to content

services: resolve owner from the registered service file - #23781

Merged
p-linnane merged 1 commit into
mainfrom
services-owner-registered-destination
Sep 4, 2026
Merged

services: resolve owner from the registered service file#23781
p-linnane merged 1 commit into
mainfrom
services-owner-registered-destination

Conversation

@p-linnane

Copy link
Copy Markdown
Contributor

Follow-up to #23750. FormulaWrapper#owner fell through to the boot-path presence check whenever the registered plist had no UserName, so a user whose own sh.brew.<formula> agent is registered under ~/Library/LaunchAgents was reported as root as soon as a legacy homebrew.mxcl.<formula> daemon also existed under /Library/LaunchDaemons. That wrong owner shows up in brew services list and info and in the root-skipping filter behind stop --all and restart --all.

The owner now follows the registered service file: in the boot path it is root, in the user path it is the current user, and only then does the presence-based fallback run. This also fixes a nil owner for package-provided plists whose label is not one of the formula's generated names, since the presence checks only look at those names. Linux and systemd behavior is unchanged.


  • 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.

Claude Code (Fable 5.1) drafted the implementation and tests; I reviewed the diff, verified the new tests fail without the change and pass with it, and ran brew lgtm.


Signed-off-by: Patrick Linnane <patrick@linnane.io>
Copilot AI balanced review requested due to automatic review settings September 4, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

馃煝 Approval recommended

The ownership fix is covered by regression tests with no unresolved issues.

Pull request overview

Resolves macOS service ownership from the registered service file鈥檚 location before using legacy fallbacks.

Changes:

  • Maps boot-path services to root and user-path services to the current user.
  • Adds regression tests for conflicting registrations.
File summaries
File Description
Library/Homebrew/test/services/formula_wrapper_spec.rb Tests user and root ownership precedence.
Library/Homebrew/services/formula_wrapper.rb Resolves ownership from the registered service path.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

馃挕 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@p-linnane
p-linnane added this pull request to the merge queue Sep 4, 2026
Merged via the queue into main with commit 7b8d758 Sep 4, 2026
59 checks passed
@p-linnane
p-linnane deleted the services-owner-registered-destination branch September 4, 2026 17:18
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.

3 participants