Skip to content

services/polkit: register agent using XDG_SESSION_ID when available#875

Open
Kitty-Hivens wants to merge 1 commit into
quickshell-mirror:masterfrom
Kitty-Hivens:master
Open

services/polkit: register agent using XDG_SESSION_ID when available#875
Kitty-Hivens wants to merge 1 commit into
quickshell-mirror:masterfrom
Kitty-Hivens:master

Conversation

@Kitty-Hivens

Copy link
Copy Markdown

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.

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.

1 participant