[Pkg-utopia-maintainers] Bug#774626: Xsession.d/75dbus_dbus-launch could export latest environment variables like 90gpg-agent

Simon McVittie smcv at debian.org
Tue Jan 6 22:36:30 UTC 2015


On Mon, 05 Jan 2015 at 15:00:28 +0100, chrysn wrote:
> the current behavior of the Xsession launched session dbus is to spawn a
> session dbus per X session, and announce the connecting address via
> environment variables to the session.

Yes. This is the way the D-Bus session bus was designed to work, more
than a decade ago: there is one session bus per "login session"
(roughly per X11 session in practice, because dbus-launch used to try
to track the lifetime of tty sessions, but that doesn't actually work
because Unix).

One of the big use cases for the session bus, particularly early on,
was so that misc daemons in a desktop environment would reliably
die at the end of the desktop session, rather than hanging around
taking up memory and a pid forever. That's why the controversial
"exit on disconnection" feature is on by default.

> therefore, users of session multiplexers like tmux or screen can't use
> dbus in multiplexer sessions that have outlived their initial x session
> any more.

Yes, that is a consequence of these multiplexers not fitting that model
at all.

The only other consistent model that has had reasonable momentum is the
one advocated by the systemd developers, which is to have one bus
per uid that is logged in, and share it across all of their concurrent
X11 and tty sessions. (The "user bus".) With systemd-logind, making
this happen is relatively straightforward, and it can even be
configured so that the bus dies at the end of the user's last
concurrent login.

This is not without its problems: the other stuff in Xsession.d
expects to be able to set random environment variables and have them
propagate through all the user's processes, but if the D-Bus session
is left over from an older session, it'll have that session's
environment variables at all. The solution recommended by the
systemd developers is to use XDG_RUNTIME_DIR instead of relying on
individual environment variables.

> i'd like to suggest taking over the mechanism employed by
> Xsession/90gpg-agent: it starts a gpg-agent if none is present by
> prefixing it to STARTUP (as does dbus), but then stores the environment
> variables in ~/.gnupg/gpg-agent-info-${hostname}. gpg-agent has an
> option for that, but that could either be added to dbus-launch or
> crafted into the STARTUP line.

This is essentially a complicated way to get an optional user bus,
I think. For jessie, sorry, no, this is not going to happen.

Post-jessie, I intend to look into making dbus at least optionally
work as a user bus under "systemd --user", if it isn't entirely
superseded for Linux/systemd users by kdbus.

Nobody really understands dbus-launch and in the long term I would
like it to go away entirely, or at least be something deprecated
that people who NFS-share their home directories and TCP-share
their X11 displays get to deal with (and they can keep both
pieces). Sadly, that is a use case that dbus-launch is intended
to support, but nobody is quite sure how the details work,
and I suspect it actually doesn't work in practice.

There are unsolved issues around propagating environment variables
from Xsession.d; if it's optional, there is the possibility of
just punting those unsolved issues to "choose which of our
two imperfect worlds you want to live in, the one with dbus-launch
from circa 2002 or the one with systemd from 2015", which is
looking increasingly appealing. Eventually I hope that the user
bus can be the actively supported configuration, and dbus-launch
can be something for @1990sLinuxUser.

> ps. i've found a reference to ~/.dbus/session-bus/ in the dbus-launch
> man page, but the files there on my workstation are all stale. is that
> mechanism stil in place?

That's part of some sort of half-baked supplement to the X11
autolaunching protocol for implementations that don't
run "dbus-launch --autolaunch ..." in the same undocumented way
as libdbus. Such implementations may or may not actually exist,
and nobody dares to look at it too hard in case it catches fire.
Yay dbus-launch...

Regards,
    S



More information about the Pkg-utopia-maintainers mailing list