New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support user buses? software like mako and anbox use them #87

Closed
CameronNemo opened this Issue Oct 21, 2018 · 12 comments

Comments

Projects
None yet
5 participants
@CameronNemo
Copy link
Contributor

CameronNemo commented Oct 21, 2018

#if 0 /// elogind does not support user buses

CameronNemo referenced this issue in emersion/mako Oct 21, 2018

Merge pull request #77 from DanySpin97/elogind
[WIP] Add support for elogind
@CameronNemo

This comment has been minimized.

Copy link
Contributor Author

CameronNemo commented Oct 21, 2018

@morphis would you add support to anbox for elogind if it exposed the sd-bus API for user sessions?

@udeved

This comment has been minimized.

Copy link

udeved commented Oct 21, 2018

I would think the problem with supporting dbus user sessions, it required a common interface to consume by various init systems, which had to start the service from basically the user's home dir.

@CameronNemo

This comment has been minimized.

Copy link
Contributor Author

CameronNemo commented Oct 21, 2018

Can you elaborate? It seems that sd_bus_open_user() and friends obey the environment variable DBUS_SESSION_BUS_ADDRESS. In my desktop session this is set to unix:path=/run/user/1000/sessions/1/bus, but I am sure other options would work fine.

@Yamakuzure

This comment has been minimized.

Copy link
Collaborator

Yamakuzure commented Oct 22, 2018

The user buses you can see in the source are present if a user instance of systemd is started.

elogind can not support dbus user buses, because they require systemd to run the system. Which defeats the purpose of elogind as a systemd-login drop-in replacement.

However, if at least one other init system allows to spawn itself under a users authority, there might be a point. Or, if there is purpose in users starting dbus all by themselves. Although I do not know why someone would like to start an application that is cut off from the system like this. To me it sounds like crippling the purpose of dbus itself.

Or maybe I do not know enough about this particular use case... Why does software like the ones you mentioned need that?

@CameronNemo

This comment has been minimized.

Copy link
Contributor Author

CameronNemo commented Oct 22, 2018

The software typically connects to the user bus you mentioned. But in the absence of systemd and the user bus it starts, I understand that it will connect to the session bus -- something that is commonly found on non systemd login sessions. There will have to be a mechanism for the session bus to start, but such mechanisms do exist. They include Xsession dropins, xdg autostart files, or session process managers like gnome session, kautostart, and upstart.

@CameronNemo CameronNemo reopened this Oct 22, 2018

@emersion

This comment has been minimized.

Copy link
Contributor

emersion commented Oct 22, 2018

The session bus is used for instance by notification daemons. logind doesn't need to care about starting the session bus -- this isn't its job. Instead, the dbus session bus can be started e.g. with the compositor/window manager.

Some applications link with libelogind to use the sd-bus library. They just want to use sd-bus to connect to the session bus.

@Yamakuzure

This comment has been minimized.

Copy link
Collaborator

Yamakuzure commented Oct 23, 2018

Yes, but if a user bus is started, no matter how, and there is software that uses/needs that, supporting it would be logical.

PR #89 doesn't make it look overly complicated, so I think we can do this.

To recap:

  1. elogind can not start a user bus, as it is not a service manager.
  2. A user bus might be started by other means than a user instance of systemd.
  3. elogind uses what is there.
  4. Software exists that needs/benefits from a running user bus.

The logical consequence is to add support the requested support.

P.S Sorry for not spotting this earlier.

@Yamakuzure Yamakuzure self-assigned this Oct 23, 2018

@udeved

This comment has been minimized.

Copy link

udeved commented Oct 23, 2018

@Yamakuzure

I just checked, for example at-spi-core comes with unit files that are installed on arch linux in /usr/lib/systemd/user

@CameronNemo

This comment has been minimized.

Copy link
Contributor Author

CameronNemo commented Oct 24, 2018

Your recap is correct. I would only specify that from the perspective of sd-bus, a user bus and a session bus are nearly indistinguishable. They are both unprivileged, and their address is specified in the environment variable DBUS_SESSION_BUS_ADDRESS (even for user buses they use that env var).

@emersion

This comment has been minimized.

Copy link
Contributor

emersion commented Oct 24, 2018

Thanks!

emersion added a commit to emersion/mako that referenced this issue Oct 24, 2018

readme: state that we support elogind
Now that elogind/elogind#87 and
elogind/elogind#86 have been fixed, we
can claim to officially support elogind.

Fixes #80
@bl33pbl0p

This comment has been minimized.

Copy link
Contributor

bl33pbl0p commented Oct 24, 2018

@CameronNemo

Just a heads up, latest systemd does not set DBUS_SESSION_BUS_ADDRESS, and sd-bus (and libdbus and gdbus too) check for the socket at $XDG_RUNTIME_DIR/bus. See systemd/systemd@2b2b722

@Yamakuzure

This comment has been minimized.

Copy link
Collaborator

Yamakuzure commented Oct 24, 2018

@CameronNemo

Just a heads up, latest systemd does not set DBUS_SESSION_BUS_ADDRESS, and sd-bus (and libdbus and gdbus too) check for the socket at $XDG_RUNTIME_DIR/bus. See systemd/systemd@2b2b722

If I understand Lennarts commit message correctly, we can simply drop it and be done with it? Cool!

Re-Opening as a reminder to cherry-pick that! 😸

@Yamakuzure Yamakuzure reopened this Oct 24, 2018

Yamakuzure added a commit that referenced this issue Nov 8, 2018

sd-bus: enable support for user bus instances
Bug: #87
Closes: #87
Signed-off-by: Cameron Nemo <camerontnorman@gmail.com>
Signed-off-by: Sven Eden <sven.eden@prydeworx.com>

Yamakuzure added a commit that referenced this issue Nov 8, 2018

pam_elogind: drop setting DBUS_SESSION_BUS_ADDRESS
Since D-Bus 1.9.14 (2015-03-02) dbus looks in $XDG_RUNTIME_DIR/bus for
the system bus on its own, hence we can finally drop setting this
environment variable. gdbus since glib 2.45.3 (June 2015) also supports
it.

Closes: #87
Sigend-off-by: Sven Eden <sven.eden@prydeworx.com>

Yamakuzure added a commit that referenced this issue Nov 9, 2018

bus-util: Remove invalid check against systemd providing PID 1. (#93)
This check always returns error -EHOSTDOWN, because sd_booted()
always returns 0. This will fix loginctl execution error, returned
from the login/loginctl.c:main().

Before enabling user buses, this check was bypassed by re-routing
attempts to connect to user buses to the system bus.

Bug: #87
Bug: #93
Closes: #93
Sigend-off-by: Sven Eden <sven.eden@prydeworx.com>

Yamakuzure added a commit that referenced this issue Nov 9, 2018

bus-util: Remove invalid check against systemd providing PID 1. (#93)
This check always returns error -EHOSTDOWN, because sd_booted()
always returns 0. This will fix loginctl execution error, returned
from the login/loginctl.c:main().

Before enabling user buses, this check was bypassed by re-routing
attempts to connect to user buses to the system bus.

Bug: #87
Bug: #93
Closes: #93
Sigend-off-by: Sven Eden <sven.eden@prydeworx.com>

Yamakuzure added a commit that referenced this issue Nov 26, 2018

sd-bus: enable support for user bus instances
Bug: #87
Signed-off-by: Sven Eden <sven.eden@prydeworx.com>

Yamakuzure added a commit that referenced this issue Nov 26, 2018

pam_elogind: drop setting DBUS_SESSION_BUS_ADDRESS
Since D-Bus 1.9.14 (2015-03-02) dbus looks in $XDG_RUNTIME_DIR/bus for
the system bus on its own, hence we can finally drop setting this
environment variable. gdbus since glib 2.45.3 (June 2015) also supports
it.

Bug: #87
Sigend-off-by: Sven Eden <sven.eden@prydeworx.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment