omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

omarchy-shell: stale Quickshell polkit registration blocks pkexec until shell restart

Open VillainRU opened this issue 3 months ago • 3 comments

System details

  • Omarchy: 4.0.2-1
  • Quickshell: 0.3.1-1
  • polkit: 127-3

What happened

The Omarchy shell's polkit agent entered a stale/broken state. After that, GUI actions using pkexec did not show an authentication dialog and failed immediately.

The Windows VM launcher exposed this as the generic notification:

Windows VM
Failed to start Windows VM

This looks similar to #9374, but it is a separate failure mode: the VM directories already had the correct 0700 permissions. Restarting the Omarchy shell restored the polkit dialog and allowed the same command to succeed.

Journal evidence

The long-running Omarchy shell logged:

Sep 01 09:06:29 omarchy-shell:
failed to register listener: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: An authentication agent already exists for the given subject

Sep 01 09:06:29 omarchy-shell:
failed to register listener on path "/org/omarchy/PolkitAgent"

Later, launching windows-vm.desktop produced no authentication dialog and exited with the generic failure notification. Running the status command without a graphical agent also showed that authorization could not be obtained:

Error creating textual authentication agent: Error opening current controlling terminal for the process (`/dev/tty'): No such device or address
Could not query the Windows VM (authorization declined?).

Recovery

Running:

omarchy restart shell

started a new shell process, which logged:

omarchy polkit agent registered

Immediately afterward, the same omarchy-windows-vm status action displayed the authentication dialog and succeeded. Starting the VM also succeeded.

Reproduction from the broken state

I do not yet have a deterministic one-command reproduction for creating the stale state, but once it occurs the behavior is consistent:

  1. The running shell logs An authentication agent already exists for the given subject while registering /org/omarchy/PolkitAgent.
  2. Launch a GUI action that requires pkexec, such as the Windows VM launcher.
  3. No authentication dialog appears; the action fails immediately.
  4. Run omarchy restart shell and wait for omarchy polkit agent registered.
  5. Retry the same action; the dialog appears and authorization succeeds.

Around the initial registration error there was also Quickshell process activity, including a separate Quickshell process that later crashed. This may be related to a graph/service reload or a second agent instance, but I cannot confirm the exact trigger from this incident alone.

Expected behavior

  • Exactly one usable polkit authentication agent should remain registered for the session.
  • Reloading/recreating the Quickshell service should unregister or destroy the previous PolkitAgent cleanly before registering a replacement.
  • If registration fails with An authentication agent already exists, the shell should recover instead of leaving GUI pkexec calls without a working authentication dialog.

Possible direction

The polkit service is kept loaded and registers a PolkitAgent at /org/omarchy/PolkitAgent. It may be worth checking the lifecycle during QML graph/service reloads and ensuring an old listener is unregistered before a replacement is constructed. A registration failure could also trigger a controlled retry/recreation after verifying whether the existing listener is still functional.

Separately, surfacing the underlying pkexec/polkit failure in the Windows VM launcher would make this much easier to diagnose than the current generic notification.

VillainRU avatar Sep 01 '26 06:09 VillainRU

Thanks for the detailed report and journal excerpts. I read the polkit agent against current quattro (988f44ea1). When registration fails, the shell logs it and nothing else: shell/plugins/polkit/PolkitAgent.qml:186-188 only prints a warning when isRegistered changes, and nothing ever tries to register again. Because the polkit service is keepLoaded, plugin reloads don't recreate it either, so only a shell restart brings it back. That fits your sequence. Another process held the agent slot for your session when this shell registered, the registration was refused, and once that process went away (likely the Quickshell process you saw crash) the session had no agent left, so every GUI pkexec failed without a prompt. I have explained this from the source but not reproduced it; your report already shows the restart fixing it.

This is already being fixed in #12261, which links this issue. It recreates the agent with bounded retries when registration fails. That pull request is reviewed and verified as its own item, so this issue waits on the maintainer's decision there. The Windows VM launcher's generic "Failed to start" notification, which hides the polkit failure, is a separate point that #12261 does not change.

Reviewed by Claude Opus 5.5. The second opinion (Codex Medium) answered a ping but did not review this issue: today's review allowance was used up, so this diagnosis comes from one model.

omarchybot avatar Oct 09 '26 12:10 omarchybot

Same failure on Omarchy 4.0.6-1, from a different starting point. Adding the journal and the one reload test I ran.

Environment: Omarchy 4.0.6-1 (package), Hyprland, shell started as quickshell -n -p /usr/share/omarchy/shell.

Journal (journalctl --user -t omarchy-shell, local time, same day):

10:00:45  a second omarchy-shell process starts (portal-registration warning)
10:00:50  WARN quickshell.service.polkit.listener: failed to register listener: ... An authentication agent already exists for the given subject
10:00:50  WARN quickshell.service.polkit: failed to register listener on path "/org/omarchy/PolkitAgent"
10:05:56-10:06:48  GUI pkexec calls: "Error creating textual authentication agent: ... /dev/tty ... No such device or address"
10:08:10  omarchy polkit agent registered   (after `omarchy restart shell`)

The failing process logged no "registered" line afterwards and nothing retried. The journal does not show which side held the agent slot first.

Source (4.0.6): shell/plugins/polkit/PolkitAgent.qml creates PolkitAgent once (line 177). onIsRegisteredChanged only logs (lines 186-188), so a refused registration is silent. manifest.json sets "keepLoaded": true, so plugin reloads do not recreate it.

Reload test: I touched an existing plugin file twice within a second (stewartjarod.gato/README.md, content unchanged). That produced two "Local plugin changed, reloading" events, no polkit lines, and no re-registration. So a single plugin-file reload did not reproduce the refusal. I did not run pkexec for the check, so I cannot say whether the agent was still bound afterwards.

The retry in #16019 would cover this case as well, since it does not depend on which process holds the slot. I have not tested #16019 on this machine.

stewartjarod avatar Oct 30 '26 20:10 stewartjarod

Thanks @stewartjarod for the 4.0.6 journal and the reload test. It fits the same failure: current quattro (e2c7007c) still creates the agent once and only logs when registration is refused (shell/plugins/polkit/PolkitAgent.qml:186-188), and keepLoaded stops a plugin reload from recreating it. So a shell that loses the registration race stays without an agent until it is restarted, no matter which process held the slot.

This now has two open fixes, and both close this issue. #12261 recreates the agent at most five times, which runs out about 20 s after the shell starts, so a competing agent that lives longer than that still leaves the session without one. #16019 keeps retrying, backing off to once a minute, so it recovers whenever the other agent goes away. #16019 has been reproduced and verified on a disposable Omarchy VM as its own item, and it is the one brought forward to land. The choice between the two is the maintainer's. Neither changes the Windows VM launcher's generic "Failed to start" notification, which hides the polkit failure. That is still a separate point.

Checked by Claude Opus 5.5 against the source and both diffs. The second opinion, Codex Medium, read the same code and reached the same conclusion: no retry on quattro, #12261 gives up after its fifth attempt, and #16019 keeps going. It saw my question, so its independence is not guaranteed. It also pointed out that neither PR can make tearing the agent down safe while a registration is still pending, which #16019's code comment already notes. This issue now waits on the maintainer's decision on #16019.

omarchybot avatar Nov 01 '26 23:11 omarchybot