Web lists-archives.com

Plasma5 user sessions

Greetings from Munich's LiMux developers team.

short story:

* during user session initialisation notifications get displayed as windows
* if one user requests a shutdown (reboot, poweroff) all sessions get killed

long story:

We are currently in development of our next (final?) release. Our
current release is based on Ubuntu 14.04 trust, whereas our next release
will be based on Ubuntu 18.04 bionic.

Thus we switch from
* upstart to systemd
* ConsoleKit to logind
* Plasma 4.x to Plasma 5.x

We have to execute some tasks for every user who logs into a computer.
This includes configuring start menu applications, configuring printers,
mounting network shares and synchronise the users home directory with a
filer (downsync). We also provide slots where administrators can run
scripts in the user context.

Up until now we hooked into the user session by putting some files into
/etc/X11/Xsession.d which is as far as we understand executed by the
display-manager when a x11 user session gets initialised.

During these configuration steps there are some notifications we want to
be displayed after the desktop is ready. Therefore we collect such
messages. The a script in /etc/xdg/autostart displays them after the
plasma session started as normal desktop notifications. Therefore the
script sends them through the DBus session bus via
org.freedesktop.Notifications. However on our development release those
messages get displayed as windows instead of the usual bubbles. It seems
that the notification handling is not ready when the autostarts are running.

When the user ends the session we also run code to synchronise the home
directory (upsync), umnount network shares etc. This works as expected
if the user does a simple logout. However if the user requests a
shutdown (reboot, poweroff) then the session and other user sessions are
killed and the computer shuts down. The KSMServer
(plasma-workspace/ksmserver/server.cpp, void KSMServer::cleanUp()) uses
a KDisplayManager (plasma-workspace/libkworkspace/kdisplaymanager.cpp)
which sends a "Reboot" or "PowerOff" through the system bus to logind.
This results in an immediate shutdown and neither our code nor parts of
the startkde script is executed.

Comments in kdisplaymanager.cpp state that there should be a policykit
dialog preventing a shutdown if other sessions are running, which is not
displayed in our case. But also without other sessions running, the
logout should finish in a clean way(wait for startkde to terminate).

We found out, that running a process with a systemd inhibitor as root e.g
> # systemd-inhibit --what=shutdown --mode=block sleep 365d
prevents the system from killing the session and a clean logout is
conducted. However in this case also the shutdown request is silently

There are some questions we where not able to find answers by ourselves:

Is there a definition when xdg-autostart applications are started?

Is there a way to make sure that the session is ready to display

It seems that sending dbus messages to logind in kdisplaymanager.cpp is
too early. Could this be a general issue? Should this not be the last
part of startkde?

Could this be a misconfiguration of policykit?

Could it be that the behaviour of logind changed recently?

It looks like there are currently some weak spots with plasma5 sessions.
We hope that we can work together to make the users session handling
more robust.