Bug 463557 - Logout sometimes(!!) not possible
Summary: Logout sometimes(!!) not possible
Status: RESOLVED NOT A BUG
Alias: None
Product: ksmserver
Classification: Plasma
Component: general (show other bugs)
Version: 5.26.4
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: David Edmundson
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-28 16:04 UTC by Andreas Hartmann
Modified: 2023-03-08 22:15 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
qdbus org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.DBus.Properties.Get org.freedesktop.systemd1.Manager Environment > qdbus.txt (5.79 KB, text/plain)
2023-03-08 22:15 UTC, Alexander Wilms
Details
env > env.txt (4.72 KB, text/plain)
2023-03-08 22:15 UTC, Alexander Wilms
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Hartmann 2022-12-28 16:04:33 UTC
SUMMARY
Trying to logout sometimes - not always!! - doesn't work. If it doesn't work, you can see this error in system log:

Dec 28 08:36:37 lhost dbus-daemon[5204]: [session uid=1000 pid=5204] Activating service name='org.kde.LogoutPrompt' requested by ':1.18' (uid=1000 pid=5348 comm="/usr/bin/plasmashell --no-respawn ")
Dec 28 08:36:37 lhost ksmserver-logout-greeter[23052]: qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
Dec 28 08:36:37 lhost ksmserver-logout-greeter[23052]: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.
Dec 28 08:37:44 lhost dbus-daemon[5204]: [session uid=1000 pid=5204] Activating service name='org.kde.Shutdown' requested by ':1.63' (uid=1000 pid=23614 comm="/usr/lib/ksmserver-logout-greeter 

This only happened until now, if the user has been logged on for several hours. I tried to find a reason which could be responsible for the problem - but couldn't find any so far. I suspected switching between users or switching to console could trigger it - but that's not true (at least it isn't reproducible).

My workaround is to start the logout screen manually in konsole like this:
/usr/lib/ksmserver-logout-greeter -

STEPS TO REPRODUCE
1. Start logout via kicker
2. 
3. 

OBSERVED RESULT
nothing happens

EXPECTED RESULT
Logout screen should be started

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: 5.26.4
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.101.0
Qt Version: 5.15.7

ADDITIONAL INFORMATION
I'm using sddm 0.19.0 and X11 if this should be relevant!
Comment 1 David Edmundson 2023-01-01 14:38:09 UTC
Given the workaround works, the only remaining explanation is the dbus activation environment has got out of sync and lost DISPLAY/XAUTHORITY env vars. 

A good test would be to compare:
```
qdbus org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.DBus.Properties.Get org.freedesktop.systemd1.Manager Environment
```

and 
```
env
```

Assuming DISPLAY / XAUTHORITY are different, we need to work out why, though all signs point away from Plasma
Comment 2 Andreas Hartmann 2023-01-02 04:53:39 UTC
Thanks for your hint!
Problem appeared again - and there was no difference in environment compared to before, as it was working.
Comment 3 Bug Janitor Service 2023-01-17 05:17:00 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least
15 days. Please provide the requested information as soon as
possible and set the bug status as REPORTED. Due to regular bug
tracker maintenance, if the bug is still in NEEDSINFO status with
no change in 30 days the bug will be closed as RESOLVED > WORKSFORME
due to lack of needed information.

For more information about our bug triaging procedures please read the
wiki located here:
https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please
mark the bug as REPORTED so that the KDE team knows that the bug is
ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 4 Andreas Hartmann 2023-01-19 21:59:39 UTC
I now know what happens. I moved ksmserver-logout-greeter and added instead a small bash script which logs the environment to a log file. And voila, the culprit is:
...
DISPLAY=localhost:10.0
SSH_CONNECTION=192.168.1.59 35858 192.168.1.6 22
...

What happened? Before that, I remotely logged in via ssh to this machine with
ssh -XC 192.168.1.6 konsole

This obviously completely breaks the environment! But why?
Comment 5 Andreas Hartmann 2023-01-22 17:35:54 UTC
It's even more easy to reproduce it (assuming there is a ssh server running on localhost): just do a 
ssh -X localhost
and the problem can be seen.

Btw: if you do it like described above, there is a warning:
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.InvalidArgs: Invalid environment assignments

The actual workaround is to replace /usr/lib/ksmserver-logout-greeter with a script which explicitly sets DISPLAY to :0 and afterwards start the original ksmserver-logout-greeter.
Comment 6 Andreas Hartmann 2023-01-22 17:47:42 UTC
The exactly same behavior can be seen running KDE under Wayland.
Comment 7 Andreas Hartmann 2023-01-22 19:04:14 UTC
Further investigation showed: manually changing the activation-environment after the login has been performed on a local tty, things are working again, too:
dbus-update-activation-environment DISPLAY XAUTHORITY

Doing the same with a "broken" DISPLAY environment breaks the logout window again (not surprising).

The question for me is:
Why does a simple ssh -X - login changes the global environment - even for the local running user (at least for processes started by dbus)? This doesn't make any sense to me!
Comment 8 Andreas Hartmann 2023-01-22 19:55:49 UTC
Ok, I found the problem: openSuSE 15.4 comes with /etc/profile.d/openssh-dbus.sh as part of openssh-server:

if test -n "$SSH_CONNECTION" -a -n "$DISPLAY"
then
     dbus-update-activation-environment --systemd --all
fi

Deactivating this file makes it working again.
Comment 9 Erec 2023-03-02 12:01:35 UTC
OpenSuSE Bug 1206739 - Latest update to systemd causes "theft" of X's dbus session by ssh session for user with same UID
https://bugzilla.opensuse.org/show_bug.cgi?id=1206739
Comment 10 Alexander Wilms 2023-03-08 22:15:00 UTC
Started to happen repeatedly in the last few days for me.

Operating System: openSUSE Tumbleweed 20230307
KDE Plasma Version: 5.27.2
KDE Frameworks Version: 5.103.0
Qt Version: 5.15.8
Kernel Version: 6.2.1-1-default (64-bit)
Graphics Platform: X11
Comment 11 Alexander Wilms 2023-03-08 22:15:24 UTC
Created attachment 157126 [details]
qdbus org.freedesktop.systemd1 /org/freedesktop/systemd1 org.freedesktop.DBus.Properties.Get org.freedesktop.systemd1.Manager Environment > qdbus.txt
Comment 12 Alexander Wilms 2023-03-08 22:15:44 UTC
Created attachment 157127 [details]
env > env.txt