Skip to content

fix(elevation): share config and fix paste when relaunched as admin#75

Merged
dbfx merged 1 commit intomainfrom
dbfx/mac-admin-paste-config
Mar 25, 2026
Merged

fix(elevation): share config and fix paste when relaunched as admin#75
dbfx merged 1 commit intomainfrom
dbfx/mac-admin-paste-config

Conversation

@dbfx
Copy link
Contributor

@dbfx dbfx commented Mar 25, 2026

What does this PR do?

Fixes two bugs when relaunching as admin on macOS (and Linux):

  1. Broken paste: Extends the --no-sandbox Chromium flag from Linux-only to also cover macOS root, restoring clipboard/Cmd+V functionality in the elevated process.
  2. Two separate configs: Passes --kudu-data-dir=<path> to the elevated process so it calls app.setPath('userData', ...) on startup, ensuring it reads/writes the original user's config instead of /var/root/....
  3. Logger eagerly resolved paths: Converts LOG_DIR and related constants in logger.ts from eager top-level evaluation to lazy getters, so the userData override takes effect before any path is resolved.

Why?

When the app relaunches as root via osascript (macOS) or pkexec (Linux), app.getPath('userData') resolves to root's home directory. This causes a fresh config to be used and, on macOS, Chromium's sandbox prevents clipboard access.

How to test

  1. Launch the app on macOS
  2. Configure some settings (e.g. change theme)
  3. Click "Relaunch as Admin" and enter password
  4. Verify settings persist after elevation
  5. Verify Cmd+V (paste) works in text fields

Checklist

  • Tested on my platform (Windows / macOS / Linux)
  • npm test passes
  • npm run build succeeds
  • Commit messages follow Conventional Commits

…n macOS/Linux

When the app relaunches as root via osascript (macOS) or pkexec (Linux),
app.getPath('userData') resolves to root's home directory, causing a
separate config to be used. Pass --kudu-data-dir to the elevated process
so it shares the original user's config. Also extend --no-sandbox to
macOS root to fix broken clipboard/paste shortcuts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dbfx dbfx merged commit 0316aa5 into main Mar 25, 2026
8 checks passed
@dbfx dbfx deleted the dbfx/mac-admin-paste-config branch March 25, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant