Skip to content

Conversation

@OJFord
Copy link

@OJFord OJFord commented Jan 19, 2026

necessary for example for soteria polkit agent:
https://github.com/imvaskel/soteria?tab=readme-ov-file#installation

Closes #40.

Copilot AI review requested due to automatic review settings January 19, 2026 14:09
Copy link

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 pull request adds XDG_SESSION_ID to the list of environment variables that are propagated to systemd and dbus activation environments. This is necessary for tools like the soteria polkit agent that require this variable to function properly.

Changes:

  • Added XDG_SESSION_ID to the VARIABLES list in src/session.sh

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@alebastr
Copy link
Owner

Hm... GNOME developers believe that it's not safe to pass vars like XDG_SESSION_ID or XDG_VTNR, because it may break other desktop environments, or even the same DE after relogin: https://gitlab.gnome.org/GNOME/gnome-session/-/commit/646b9bc0584d02033ab9600c39b77d6f99bfc4a6.
I tend to trust GNOME in such things, because they had more users and years to encounter all kinds of interesting bugs.

I'm curious though, why soteria insists on requiring XDG_SESSION_ID? Pretty sure that no other polkit agent has such requirement, and the agents I was able to check were using polkit_unix_session_new_for_process instead.

@OJFord
Copy link
Author

OJFord commented Jan 20, 2026

That doesn't seem right to me - if it's wrong on re-login then surely it means it wasn't correctly passed through again on the second login? Or linger is enabled, so it was already set and did nothing, as here:

echo "Another session found; refusing to overwrite the variables"

More interesting case would be two concurrent logins of the same user in different ttys - i.e. two seats, two sessions, one user - this would fail the same check since it's already set in the first session, and neither's more correct than the other. Proper multi-seat handling would be a different beast though, and afaik it's usual to have the greeter/dm launch sway only in the tty, to avoid exactly this sort of collision (as well as an escape to fix wm startup issues), like:

if [ -z "$WAYLAND_DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ] ; then
    exec sway
fi

(https://wiki.archlinux.org/title/Sway#Automatically_on_TTY_login) or as I have for greetd:

[terminal]
vt = 1

[default_session]
command = "agreety --cmd=/bin/sh"
user = "greeter"

[initial_session]
command = "systemd-cat --identifier=sway sway"
user = "ojford"

To me, we have a session target, if setting the session ID in it causes a problem in some case; the problem is not that we set it, the problem is it not being correct.

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.

Missing XDG_SESSION_ID

2 participants