[PR #6962] [MERGED] [client] launch macOS GUI as the logged-in user after install/update #30055

Closed
opened 2026-08-05 08:09:55 -04:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/netbirdio/netbird/pull/6962
Author: @riccardomanfrin
Created: 7/29/2026
Status: Merged
Merged: 8/3/2026
Merged by: @riccardomanfrin

Base: mainHead: fix-macos-update-inherits-root-home


📝 Commits (6)

  • 451fa42 Start the UI only on behalf of a valid logged user or avoid running it
  • a5e71db Logs on fallback ui preferences
  • 53933f9 [client] validate console user uid/home and set HOME on macOS UI launch
  • 4bba5b5 Remove comments
  • 4b5a8c3 [client] launch macOS UI via sudo -u -H for full user env (HOME/USER/LOGNAME)
  • b09c808 [client] wait for macOS UI launch and propagate its error

📊 Changes

3 files changed (+41 additions, -27 deletions)

View changed files

📝 client/internal/updater/installer/installer_run_darwin.go (+23 -26)
📝 client/ui/preferences/store.go (+1 -0)
📝 release_files/darwin_pkg/postinstall (+17 -1)

📄 Description

Describe your changes

In unattended installs/updates there may be no logged-in user, so there's no context to start the GUI (nor anyone to see it).

The bug is the GUI being started in the wrong user context / inheriting the wrong $HOME (OS mechanics aside).

Today the GUI is started by a per-user LaunchAgent, i.e. on behalf of the user who logs in — no login ⇒ no GUI.

The patch aligns to this: it launches the GUI on behalf of the logged-in console user if one exists, otherwise it delegates the launch to the per-user LaunchAgent at next login.

Additionally it logs when default UI settings are applied.

Note (small caveat): the LaunchAgent auto-starts the GUI at login only once it's been registered — which happens on the first GUI launch in the user's context. On an MDM/unattended fresh install done with no user logged in (where the user has never run the GUI before), they may need to start it manually once; it self-registers from then on.

No public issue — reported internally (community report on Slack: macOS advanced-view + onboarding reset on every update, esp. via MDM/Munki). Buggy line on main: dd2bdc0de3/release_files/darwin_pkg/postinstall (L33)

Stack

Checklist

  • Is it a bug fix
  • Is a typo/documentation fix
  • Is a feature enhancement
  • It is a refactor
  • Created tests that fail without the change (if possible)

By submitting this pull request, you confirm that you have read and agree to the terms of the Contributor License Agreement.

Documentation

Select exactly one:

  • I added/updated documentation for this change
  • Documentation is not needed for this change (explain why)

Internal macOS installer / GUI-launch behavior. No public API, CLI, or configuration change: the fix only changes the user context the desktop GUI is launched in after a pkg install/update.

Docs PR URL (required if "docs added" is checked)

Paste the PR link from https://github.com/netbirdio/docs here:

N/A


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

Summary by CodeRabbit

  • Bug Fixes

    • Improved macOS installation and updater UI launching to occur only when an active, valid GUI console session is detected.
    • Prevented UI launches during unattended/system, root, or login-window-related installs.
    • Ensured the app is launched in the correct console-user context, and skips cleanly when username/UID resolution fails.
  • Improvements

    • Added clearer informational logging when the UI preferences file is not found and default preferences are used.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/netbirdio/netbird/pull/6962 **Author:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Created:** 7/29/2026 **Status:** ✅ Merged **Merged:** 8/3/2026 **Merged by:** [@riccardomanfrin](https://github.com/riccardomanfrin) **Base:** `main` ← **Head:** `fix-macos-update-inherits-root-home` --- ### 📝 Commits (6) - [`451fa42`](https://github.com/netbirdio/netbird/commit/451fa42fbd054d804016e765486740c1139b5ddb) Start the UI only on behalf of a valid logged user or avoid running it - [`a5e71db`](https://github.com/netbirdio/netbird/commit/a5e71db5777ee0ae2428c1535edc077d8e2e87f7) Logs on fallback ui preferences - [`53933f9`](https://github.com/netbirdio/netbird/commit/53933f9612cca81511231e3edc2a276101fac78e) [client] validate console user uid/home and set HOME on macOS UI launch - [`4bba5b5`](https://github.com/netbirdio/netbird/commit/4bba5b5f9bb6e81bff3adebdeab4f8235228b37d) Remove comments - [`4b5a8c3`](https://github.com/netbirdio/netbird/commit/4b5a8c3af3967ad705f9985d95623d8d1c0a5510) [client] launch macOS UI via sudo -u -H for full user env (HOME/USER/LOGNAME) - [`b09c808`](https://github.com/netbirdio/netbird/commit/b09c80897177c9aa3c04f029c5afa4ab52464b40) [client] wait for macOS UI launch and propagate its error ### 📊 Changes **3 files changed** (+41 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `client/internal/updater/installer/installer_run_darwin.go` (+23 -26) 📝 `client/ui/preferences/store.go` (+1 -0) 📝 `release_files/darwin_pkg/postinstall` (+17 -1) </details> ### 📄 Description ## Describe your changes In unattended installs/updates there may be no logged-in user, so there's no context to start the GUI (nor anyone to see it). The bug is the GUI being started in the wrong user context / inheriting the wrong `$HOME` (OS mechanics aside). Today the GUI is started by a per-user LaunchAgent, i.e. on behalf of the user who logs in — no login ⇒ no GUI. The patch aligns to this: it launches the GUI on behalf of the logged-in console user if one exists, otherwise it delegates the launch to the per-user LaunchAgent at next login. Additionally it logs when default UI settings are applied. Note (small caveat): the LaunchAgent auto-starts the GUI at login only once it's been registered — which happens on the first GUI launch in the user's context. On an MDM/unattended fresh install done with no user logged in (where the user has never run the GUI before), they may need to start it manually once; it self-registers from then on. ## Issue ticket number and link No public issue — reported internally (community report on Slack: macOS advanced-view + onboarding reset on every update, esp. via MDM/Munki). Buggy line on main: https://github.com/netbirdio/netbird/blob/dd2bdc0de3aa14dd14dc90611c69c420bb3d3eb2/release_files/darwin_pkg/postinstall#L33 ## Stack <!-- branch-stack --> ### Checklist - [x] Is it a bug fix - [ ] Is a typo/documentation fix - [ ] Is a feature enhancement - [ ] It is a refactor - [ ] Created tests that fail without the change (if possible) > By submitting this pull request, you confirm that you have read and agree to the terms of the [Contributor License Agreement](https://github.com/netbirdio/netbird/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT.md). ## Documentation Select exactly one: - [ ] I added/updated documentation for this change - [x] Documentation is **not needed** for this change (explain why) Internal macOS installer / GUI-launch behavior. No public API, CLI, or configuration change: the fix only changes the user context the desktop GUI is launched in after a pkg install/update. ### Docs PR URL (required if "docs added" is checked) Paste the PR link from https://github.com/netbirdio/docs here: N/A <!-- codesmith:footer --> --- <a href="https://app.blacksmith.sh/netbirdio/codesmith/netbird/pr/6962"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-light-v2.svg"><img alt="View with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/view-with-codesmith-dark-v2.svg"></picture></a> <a href="https://backend.blacksmith.sh/track/enable-autofix?expires=1787923973&installation_model_id=427504&pr_number=6962&repository=netbirdio%2Fnetbird&return_to=https%3A%2F%2Fgithub.com%2Fnetbirdio%2Fnetbird%2Fpull%2F6962&signature=5226bbc7986fc60eb8b4ab77e98ac17a6534864763fc6407048bcbbb1550394b"><picture><source media="(prefers-color-scheme: dark)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-light.svg"><img alt="Autofix with [code]smith" src="https://pr-comments-assets.blacksmith.sh/codesmith/autofix-with-codesmith-dark.svg"></picture></a> <sup>Need help on this PR? Tag <code>@codesmith-bot</code> with what you need. Autofix is disabled.</sup> <!-- codesmith:autofix:disabled --> <!-- /codesmith:footer --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved macOS installation and updater UI launching to occur only when an active, valid GUI console session is detected. - Prevented UI launches during unattended/system, root, or login-window-related installs. - Ensured the app is launched in the correct console-user context, and skips cleanly when username/UID resolution fails. - **Improvements** - Added clearer informational logging when the UI preferences file is not found and default preferences are used. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2026-08-05 08:09:55 -04:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: DYNR/netbird#30055