ibus: launch daemon via D-Bus service activation
If the system is booted with no users, GDM launches gnome-initial-setup instead of the normal greeter. One the gnome-initial-setup flow is complete, it tells GDM to sign in the newly-created user, and GDM tears down the gnome-initial-setup session by sending SIGTERM to its gnome-session's process group. gnome-shell is a child of gnome-session, and currently spawns ibus-daemon directly as a subprocess.
One of the first actions ibus-daemon takes is to move itself to a new process group, so it escapes the SIGTERM sent to gnome-session's process group at the end of the session. Ordinarily, this wouldn't matter, because the X11 session would soon also die, causing the ibus-x11 process (spawned by ibus-daemon) to die; its last act is to send a message to ibus-daemon, telling it to terminate.
However, if GDM is built with --disable-user-display-server (as it in on Endless), the X11 session is reused for the new user. As a result, ibus-x11 survives, and so does ibus-daemon.
A further knock-on problem is that logind waits for all processes in the session (identified by unknown means) to exit before killing the systemd --user session, the D-Bus session bus, and all services connected to it.
systemd-logind: Session c1 logged out. Waiting for processes to exit. $ loginctl session-status c1 c1 - gnome-initial-setup (110) Since: Mon 2018-11-19 15:17:36 GMT; 5min ago Leader: 735 Seat: seat0; vc1 Display: :0 Service: gdm-launch-environment; type x11; class greeter State: closing Unit: session-c1.scope ├─ 875 ibus-daemon --xim --panel disable ├─1092 /usr/lib/ibus/ibus-dconf ├─1094 /usr/lib/ibus/ibus-x11 --kill-daemon └─1202 /usr/lib/ibus/ibus-engine-simple
Most of the other lingering applications (such as PulseAudio) have no GUI, but on one Endless product we run a separate GUI application from gnome-initial-setup. This application is launched via D-Bus service activation, so it is not part of the gnome-session process group; it survives the transition from gnome-initial-setup to the new user's session. Similarly, if the lockdown of the gnome-initial-setup shell mode is incomplete and the user finds a way to launch some other application (sadly not unprecedented) then this too is carried over to the new user's session.
logind doesn't consider D-Bus-activated services to be part of the login session, so launching ibus-daemon via D-Bus service activation means that logind considers the gnome-initial-setup session to be closed and tears down everything else.
I originally reported this against GDM. A similar symptom can be reproduced with --enable-user-display-server but I think it's actually orthogonal.
One interesting side-effect of this change: on Debian-like systems, the
im-config package also tries to launch ibus-daemon. In my testing,
before this change gnome-shell would win the race; after it, im-config
wins. In particular, this means that
--panel disable, which was
previously specified by gnome-shell and is also in the D-Bus
org.freedesktop.IBus.service file, is not used in practice.