Skip to content

fix: always open app as logged-in user in postinstall script #216

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

Merged
merged 1 commit into from
Aug 6, 2025

Conversation

ethanndickson
Copy link
Member

@ethanndickson ethanndickson commented Aug 5, 2025

This PR prevents issues like:

Screenshot 2025-07-30 at 3 57 07 pm

which occur when the app is launched as root. This can happen when the installer scripts are run as root, which is the case when deploying Coder Desktop over MDM. (As a convenience, we re-open the app if it was open before the installer was ran.)

Of note is that on macOS, it is not sufficient to just run open with sudo -u, as that does not use the execution context of the user. See https://developer.apple.com/forums/thread/78332

Reports of the bug in other programs:
(with an incorrect solution) https://community.zoom.com/t5/Zoom-Meetings/A-keychain-cannot-be-found-to-stoer-quot-Zoom-quot/m-p/51059
https://displaylink.org/forum/showthread.php?p=97176

@ethanndickson ethanndickson force-pushed the ethan/run-reopened-gui-app-as-user branch 2 times, most recently from 5e2a549 to 2794fe6 Compare August 5, 2025 06:52
@ethanndickson ethanndickson self-assigned this Aug 5, 2025
@ethanndickson ethanndickson marked this pull request as ready for review August 5, 2025 07:28
@ethanndickson ethanndickson changed the title fix: always run postinstall app open as logged-in user fix: always open app as logged-in user in postinstall script Aug 5, 2025
@ethanndickson ethanndickson force-pushed the ethan/progress-auto-start branch from f3468db to d04e73f Compare August 6, 2025 02:24
@ethanndickson ethanndickson force-pushed the ethan/run-reopened-gui-app-as-user branch from 2794fe6 to f404c56 Compare August 6, 2025 02:24
@ethanndickson ethanndickson requested a review from Copilot August 6, 2025 03:28
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where the Coder Desktop app would launch as root when installed via MDM, causing keychain access problems. The fix ensures the app always launches under the logged-in user's context in the postinstall script.

Key changes:

  • Replaces simple open -a command with user-specific launch command
  • Adds logic to detect the current console user and launch the app under their context
  • Includes explanatory comments about the MDM deployment scenario

@ethanndickson ethanndickson force-pushed the ethan/progress-auto-start branch from d04e73f to 0dc424c Compare August 6, 2025 03:37
@ethanndickson ethanndickson force-pushed the ethan/run-reopened-gui-app-as-user branch from f404c56 to 0d77ec3 Compare August 6, 2025 03:38
Copy link
Member Author

ethanndickson commented Aug 6, 2025

Merge activity

  • Aug 6, 3:39 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Aug 6, 3:57 AM UTC: Graphite rebased this pull request as part of a merge.
  • Aug 6, 3:59 AM UTC: @ethanndickson merged this pull request with Graphite.

@ethanndickson ethanndickson changed the base branch from ethan/progress-auto-start to graphite-base/216 August 6, 2025 03:54
@ethanndickson ethanndickson changed the base branch from graphite-base/216 to main August 6, 2025 03:56
@ethanndickson ethanndickson force-pushed the ethan/run-reopened-gui-app-as-user branch from 0d77ec3 to e51c8a7 Compare August 6, 2025 03:57
@ethanndickson ethanndickson merged commit 4ba6ca3 into main Aug 6, 2025
4 checks passed
@ethanndickson ethanndickson deleted the ethan/run-reopened-gui-app-as-user branch August 6, 2025 03:59
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