Skip to content
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

Export dbus address conditionally #11378

Merged
merged 2 commits into from Jan 17, 2019

Conversation

keszybz
Copy link
Member

@keszybz keszybz commented Jan 10, 2019

Fixup for #11327. This takes the safer (I hope) route of reverting to the previous code.

src/login/pam_systemd.c Outdated Show resolved Hide resolved
@keszybz keszybz force-pushed the export-dbus-address-conditionally branch from b795ddc to e6cee47 Compare January 10, 2019 11:57
@evverx
Copy link
Member

evverx commented Jan 10, 2019

This pull request introduces 1 alert when merging e6cee47 into b26c904 - view on LGTM.com

new alerts:

  • 1 for FIXME comment

Comment posted by LGTM.com

@keszybz
Copy link
Member Author

keszybz commented Jan 10, 2019

Jan 10 12:49:09 autopkgtest systemd-udevd[1313]: Failed to resolve group 'render': Connection timed out
Jan 10 12:49:34 autopkgtest systemd-udevd[1313]: Failed to resolve group 'render': Connection timed out

Same as all the other PRs filed today.

* daemons that spawn dbus-daemon, instead of forcing
* DBUS_SESSION_BUS_ADDRESS= here. */

s = strjoin(runtime, "/bus");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strjoina?

@@ -199,6 +199,18 @@ static int export_legacy_dbus_address(
_cleanup_free_ char *s = NULL;
int r = PAM_BUF_ERR;

/* FIXME: We *really* should move the access() check into the
* daemons that spawn dbus-daemon, instead of forcing
* DBUS_SESSION_BUS_ADDRESS= here. */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we should conditionalize this as LEGACY or so? I don't think this is really worth supporting in new stuff

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer not to make things more complicated than they need to be. The tribulations we went through with systemd-240 suggest that dropping this is going to have bad effects even on recently written software. I think it's OK to export the variable without any plans to remove it.


if (asprintf(&rt, "/run/user/"UID_FMT, pw->pw_uid) < 0)
return PAM_BUF_ERR;
assert_cc(sizeof(uid_t) <= sizeof(int));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the assert? seems unnecessary to check this?

@poettering
Copy link
Member

if we readd the access() check it really have a clear explanation what the usecase for this is in an adjacent comment

This reverts commit 69bd76f.

$DBUS_SESSION_BUS_ADDRESS is again set only if the socket exists.

Quoting systemd#11327 (comment):
> [setting $DBUS_SESSION_BUS_ADDRESS unconditionally] makes pam_systemd
> incompatible with installations and distributions where dbus was not
> configured with --enable-user-session, and the session dbus-daemon is started
> by autolaunching or dbus-launch (as opposed to dbus.socket). I don't think
> that's wise: using autolaunching or dbus-launch, and disabling or not
> installing dbus.socket and dbus.service on the systemd user instance, is our
> compatibility story for people who still need a D-Bus session bus per X11
> session for whatever reason.
>
> For example, Debian can currently do either way, with a dbus-user-session
> package strongly recommended but not actually mandatory. dbus-user-session
> requires libpam-systemd; if pam_systemd now requires dbus.socket (which is in
> the dbus-user-session package), that's a circular dependency, which we
> normally try hard to avoid.

For systems that use dbus.socket this doesn't matter much, because the
user session is ordered after the user managaer, which pulls in dbus.socket
very early. For example, when logging over ssh:

sshd[20796]: pam_systemd(sshd:session): pam-systemd initializing
sshd[20796]: pam_systemd(sshd:session): Asking logind to create session: uid=1001 pid=20796 service=sshd type=tty class=user desktop= seat= vtnr=0 tty= display= remote=yes remote_user= remote_host=::1
sshd[20796]: pam_systemd(sshd:session): Session limits: memory_max=n/a tasks_max=n/a cpu_weight=n/a io_weight=n/a
systemd[1]: Created slice User Slice of UID 1001.
systemd[1]: Starting User Runtime Directory /run/user/1001...
systemd-logind[1210]: New session 3796 of user guest.
systemd[1]: Started User Runtime Directory /run/user/1001.
systemd[1]: Starting User Manager for UID 1001...
systemd[20805]: pam_systemd(systemd-user:session): pam-systemd initializing
systemd[20805]: Starting D-Bus User Message Bus Socket.
...
systemd[20805]: Reached target Sockets.
systemd[20805]: Reached target Basic System.
systemd[1]: Started User Manager for UID 1001.
systemd[1]: Started Session 3796 of user guest.
sshd[20796]: pam_systemd(sshd:session): Reply from logind: id=3796 object_path=/org/freedesktop/login1/session/_33796 runtime_path=/run/user/1001 session_fd=13 seat= vtnr=0 original_uid=1001
sshd[20796]: pam_unix(sshd:session): session opened for user guest by (uid=0)

Hence, everything in the ssh session is ordered after the user instance.
And in the user instance, services should be orderd after dbus.socket using
inter-unit dependencies. dbus.socket in turns does
systemctl --user set-environment DBUS_SESSION_BUS_ADDRESS=unix:path=%t/bus.

So there should be no race between starting of the dbus socket and our check
if it exists.

The alternative would be to set the "DBUS_SESSION_BUS_ADDRESS=unix:path=%s/bus;autolaunch:".
AFAICT, this would work as well. But I don't see any case where it actually works
better. Since this is an area with many compatiblity concerns, let's stick to
the previous setup which seems to work well.
@keszybz keszybz force-pushed the export-dbus-address-conditionally branch from e6cee47 to 15ee6c2 Compare January 15, 2019 13:25
@keszybz
Copy link
Member Author

keszybz commented Jan 15, 2019

Updated. All comments are addressed except for the LEGACY check, see above.

@poettering poettering merged commit c1642d7 into systemd:master Jan 17, 2019
@keszybz keszybz deleted the export-dbus-address-conditionally branch January 17, 2019 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

None yet

4 participants