services/polkit: register agent using XDG_SESSION_ID when available#875
Open
Kitty-Hivens wants to merge 1 commit into
Open
services/polkit: register agent using XDG_SESSION_ID when available#875Kitty-Hivens wants to merge 1 commit into
Kitty-Hivens wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
qs_polkit_agent_register builds the agent subject with polkit_unix_session_new_for_process(getpid()), which resolves the logind session from the calling process's cgroup. When Quickshell runs outside a session-scope cgroup -- for example as a systemd user service -- there is no such session, subject creation fails, and the listener never registers ("failed to create subject for listener: No session for pid"). With no agent registered, polkit falls back to a text agent and authentication does not work for that session.
This prefers the session id from XDG_SESSION_ID and registers the listener for it, falling back to the existing pid-based path when the variable is unset. When the cgroup lookup fails, polkitd resolves the caller's session through sd_uid_get_display, so registration is accepted as long as XDG_SESSION_ID is the user's display session. This is the same approach hyprpolkitagent uses.
Tested on a session where the compositor and agent run as systemd user services: before, the agent failed to register and polkit fell back to the text agent; after, it registers and both GUI and pkexec authentication work.