Skip to content

Ensure MacOS desktop app launched as correct user#27296

Merged
sgress454 merged 4 commits intomainfrom
sgress454/25924-ensure-correct-user-before-launching-desktop
Mar 20, 2025
Merged

Ensure MacOS desktop app launched as correct user#27296
sgress454 merged 4 commits intomainfrom
sgress454/25924-ensure-correct-user-before-launching-desktop

Conversation

@sgress454
Copy link
Copy Markdown
Contributor

@sgress454 sgress454 commented Mar 19, 2025

For #25924

This PR attempts to fix the issue where the Fleet desktop icon sometimes fails to appear on MacOS hosts until the hosts are rebooted. Anecdotal evidence points to this being an issue when system setup is happening, leading to the theory that Orbit is attempting to launch the app as _mbsetupuser rather than the real logged-in user. The fix here is to use a different command to get the name of the logged-in user (ignoring _mbsetupuser if it appears), and to launch the desktop app as that user using sudo.

I have tested this on MacOS and Ubuntu hosts, and verified that the desktop app launches as expected on both.

We don't have a solid reproduction scenario for the issue, but we do have some ways to look for relevant errors, so we can try this out and see if those errors cease.

Comment on lines +29 to +31
if len(match) > 1 && match[1] != "" && match[1] != "_mbsetupuser" {
return &match[1], nil
}
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

since root is not a GUI user, we don't have to filter for that here.

@sgress454 sgress454 changed the title Ensure desktop app is not launched as _mbsetupuser Ensure MacOS desktop app launched as correct user Mar 19, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Project coverage is 63.88%. Comparing base (672f369) to head (d4ae24e).
Report is 21 commits behind head on main.

Files with missing lines Patch % Lines
orbit/cmd/orbit/orbit.go 0.00% 5 Missing ⚠️
orbit/pkg/execuser/execuser.go 0.00% 4 Missing ⚠️
orbit/pkg/user/user_notdarwin.go 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #27296      +/-   ##
==========================================
- Coverage   63.89%   63.88%   -0.02%     
==========================================
  Files        1731     1731              
  Lines      164611   164896     +285     
  Branches     4507     4507              
==========================================
+ Hits       105176   105339     +163     
- Misses      51267    51360      +93     
- Partials     8168     8197      +29     
Flag Coverage Δ
backend 64.71% <0.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

getvictor
getvictor previously approved these changes Mar 19, 2025
Copy link
Copy Markdown
Member

@getvictor getvictor left a comment

Choose a reason for hiding this comment

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

The code looks good.

We've seen the issue with Fleet Desktop launching for users who have installed Fleet for the first time, like prospects trying out Fleet. So, I don't understand how this change would fix that use case.

For QA, please test on a Mac with 2 users -- 1 logs out and another one logs in, and Fleet Desktop should work for both.

@sgress454
Copy link
Copy Markdown
Contributor Author

We've seen the issue with Fleet Desktop launching for users who have installed Fleet for the first time, like prospects trying out Fleet. So, I don't understand how this change would fix that use case.

There are anecdotal reports of _mbsetupuser hanging around after an update, so it's possible that even if someone is just running the installer, they could encounter this problem if they haven't rebooted their system since their last update. It's definitely a reach though.

For QA, please test on a Mac with 2 users -- 1 logs out and another one logs in, and Fleet Desktop should work for both.

Will do!

Copy link
Copy Markdown
Member

@lucasmrod lucasmrod left a comment

Choose a reason for hiding this comment

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

LGTM!

Great finding!

  • Left a comment/question.
  • Pending orbit/changes/.

@sgress454
Copy link
Copy Markdown
Contributor Author

Updated code from PR review and added changelog 👍

Copy link
Copy Markdown
Member

@getvictor getvictor left a comment

Choose a reason for hiding this comment

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

LGTM

@sgress454 sgress454 merged commit 866d8bc into main Mar 20, 2025
46 checks passed
@sgress454 sgress454 deleted the sgress454/25924-ensure-correct-user-before-launching-desktop branch March 20, 2025 14:49
@lucasmrod
Copy link
Copy Markdown
Member

@sgress454 @getvictor I reproduced this issue after updating to the latest macOS (15.3.2)

15821:The application cannot be opened for an unexpected reason, error=Error Domain=RBSRequestErrorDomain Code=5 "Launch failed." UserInfo={NSLocalizedFailureReason=Launch failed., NSUnderlyingError=0x60000200eee0 {Error Domain=OSLaunchdErrorDomain Code=112 "Could not find specified domain" UserInfo={NSLocalizedFailureReason=Could not find specified domain}}}

And then I pushed main which contains this fix and now the Fleet Desktop icon showed up without requiring restart (AFAICS using sudo with open was the fix)

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