Help: connect to different dbus session addresses

Joan Torres <joan.torres-IBi9RG/[email protected]> Mon, 28 Nov 2022 16:46:51 +0100
Newsgroups gmane.comp.freedesktop.dbus
Message-ID <[email protected]>
Hello!

I'm working on a GNOME project and I'm in a situation where I have a
dbus related question.

I'm running a system level daemon (should be running as gdm) which
connects to different gdm dbus sessions to connect their respective
org.gnome.Mutter and use RemoteDesktop and ScreenCast interfaces to
display the virtual monitor of each session.
Everything fine on this part.

This daemon has to connect also to different dbus sessions of different
users to use org.freedestkop.systemd1.Manager interface to start a unit
service on each session. Here I am in the trouble because the daemon
can't connect to other user dbus sessions if it is running as gdm user.

I found a workaround making the daemon run as root and add a session
dbus rule:

<policy context="default>
  <allow user="root"/>
</policy>

But this is undesirable because we don't want it to be run as root.
How can I make a system daemon running as gdm user connect to any user
dbus session to start a unit service using systemd1 dbus API? Is there a
way using dbus rules?

Here you can find more information about the project I'm working on:
<https://gitlab.gnome.org/GNOME/gnome-remote-desktop/-/merge_requests/139>

Thank you in advance.