Bug 427777 - Missing "switch user" functionality in lock screen with systemd 246
Summary: Missing "switch user" functionality in lock screen with systemd 246
Status: RESOLVED FIXED
Alias: None
Product: kscreenlocker
Classification: Plasma
Component: greeter (show other bugs)
Version: unspecified
Platform: Other Linux
: VHI normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords: regression
: 430271 (view as bug list)
Depends on:
Blocks:
 
Reported: 2020-10-15 20:37 UTC by Antonio Rojas
Modified: 2022-08-25 07:08 UTC (History)
7 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.20.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Rojas 2020-10-15 20:37:53 UTC
SUMMARY
Same as bug 423526 but for the screen locker. kscreenlocker also needs to be ported away from GetSessionByPID
Comment 1 David Edmundson 2020-10-15 22:21:25 UTC
It should be, it uses the same library
Comment 2 Antonio Rojas 2020-10-15 22:44:42 UTC
Which library? The fix in bug 423526 is for libkworkspace, and kscreenlocker doesn't use that. And it is calling GetSessionByPID in https://invent.kde.org/plasma/kscreenlocker/-/blob/master/logind.cpp#L103
Comment 3 Wolfgang Bauer 2020-10-16 14:40:34 UTC
From my recent investigations, the greeter uses the sessionsModel.canSwitchUser property (from  org.kde.plasma.private.sessions) to determine whether the button should be shown, which in turn does use libkworkspace (KDisplayManager::isSwitchable()).
See also my comments in bug#https://bugs.kde.org/show_bug.cgi?id=427673
Comment 4 Wolfgang Bauer 2020-11-06 08:16:27 UTC
I had a look at this on openSUSE Tumbleweed, which also has systemd 246 and this problem.

The "Switch User" button is indeed missing because KDisplayManager::isSwitchable() returns false.

For reference, here's the code of KDisplayManager::isSwitchable():
    if (DMType == NewGDM || DMType == LightDM) {
        QDBusObjectPath currentSeat;
        if (getCurrentSeat(nullptr, &currentSeat)) {
            SystemdSeat SDseat(currentSeat);
            if (SDseat.isValid()) {
                QVariant prop = SDseat.property("CanMultiSession");
                if (prop.isValid())
                    return prop.toBool();
            }
... (ConsoleKit stuff follows here)

Now the problem is that with systemd 246, SDseat.property("CanMultiSession") yields QVariant(Invalid), i.e. apparently getting that property fails.

Although, "qdbus-qt5 --system org.freedesktop.login1 /org/freedesktop/login1/seat/auto org.freedesktop.DBus.Properties.Get org.freedesktop.login1.Seat CanMultiSession" does work and returns true.
But the property is not listed in qdbusviewer either.

As a quick test, I changed the code to this:
                if (prop.isValid())
                    return prop.toBool();
                else
                    return true; // if the property cannot be get, assume that MultiSession is supported

Now the button appears again, and user switching works (together with https://invent.kde.org/plasma/plasma-workspace/-/commit/c5fa3a15a444b0e7c9113b2dd0351e1cf7141d29, otherwise switching to an existing session just hangs on an empty screen ).
Comment 5 Wolfgang Bauer 2020-11-06 08:26:59 UTC
Maybe something like this would be necessary to get the "CanMultiSession" property as well?
(this is from KDisplayManager::SystemdSeat, https://invent.kde.org/plasma/plasma-workspace/-/blob/master/libkworkspace/kdisplaymanager.cpp#L150 )

    /* HACK to be able to extract a(so) type from QDBus, property doesn't do the trick */
    QList<NamedDBusObjectPath> getSessions() {
        QDBusMessage message = QDBusMessage::createMethodCall(service(), path(), DBUS_PROPERTIES_IFACE, DBUS_PROPERTIES_GET);
        message <<  interface() << SYSTEMD_SESSIONS_PROPERTY;
        QDBusMessage reply = QDBusConnection::systemBus().call(message);
Comment 6 Nate Graham 2020-11-06 16:26:55 UTC
Thanks for the thorough investigation! Hopefully that means this can finally be knocked out. :)
Comment 7 Wolfgang Bauer 2020-11-09 09:04:35 UTC
Btw, @David Edmundson wrote in bug#423526 comment#15:
> src/login/logind-seat-dbus.c:        SD_BUS_PROPERTY("CanMultiSession", "b", property_get_const_true, 0, SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN),
> 
> 
> So it does still exist, but it's hidden from introspection.
> And always returns true anyway: 8f8cc84ba4612e74cd1e26898c6816e6e60fc4e9 which > makes our check somewhat redundant!

So my "workaround" in comment#4 would probably be an acceptable fix?

(I'd think falling back to the ConsoleKit code shouldn't be necessary anymore if we successfully did get a systemd seat already...)
Comment 8 Bug Janitor Service 2020-11-09 11:32:00 UTC
A possibly relevant merge request was started @ https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/436
Comment 9 Wolfgang Bauer 2020-11-10 09:18:03 UTC
Git commit f1393bc835ee28ceee54cdceb8d873622e36826a by Wolfgang Bauer.
Committed on 10/11/2020 at 09:11.
Pushed by wbauer into branch 'master'.

Fix missing "Switch User" button on lockscreen with systemd 246

With newer systemd versions (since 246), getting the "CanMultiSession" property
doesn't work anymore.

It's hidden and always true, see https://github.com/systemd/systemd/commit/8f8cc84ba4612e74cd1e26898c6816e6e60fc4e9
and https://github.com/systemd/systemd/commit/c2b178d3cacad52eadc30ecc349160bc02d32a9c

So let's just assume that it's supported if the property is invalid.
FIXED-IN: 5.20.3

M  +8    -0    libkworkspace/kdisplaymanager.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/f1393bc835ee28ceee54cdceb8d873622e36826a
Comment 10 Wolfgang Bauer 2020-11-10 09:18:52 UTC
Git commit 92b9d097ea6e154f273849f69053f6e9cccf7fa8 by Wolfgang Bauer.
Committed on 10/11/2020 at 09:18.
Pushed by wbauer into branch 'cherry-pick-f1393bc8'.

Fix missing "Switch User" button on lockscreen with systemd 246

With newer systemd versions (since 246), getting the "CanMultiSession" property
doesn't work anymore.

It's hidden and always true, see https://github.com/systemd/systemd/commit/8f8cc84ba4612e74cd1e26898c6816e6e60fc4e9
and https://github.com/systemd/systemd/commit/c2b178d3cacad52eadc30ecc349160bc02d32a9c

So let's just assume that it's supported if the property is invalid.
FIXED-IN: 5.20.3


(cherry picked from commit f1393bc835ee28ceee54cdceb8d873622e36826a)

M  +8    -0    libkworkspace/kdisplaymanager.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/92b9d097ea6e154f273849f69053f6e9cccf7fa8
Comment 11 Wolfgang Bauer 2020-11-10 09:20:00 UTC
Git commit aaa7a59a6710a89f21ebd441616df13be5ba8fef by Wolfgang Bauer.
Committed on 10/11/2020 at 09:19.
Pushed by wbauer into branch 'Plasma/5.20'.

Fix missing "Switch User" button on lockscreen with systemd 246

With newer systemd versions (since 246), getting the "CanMultiSession" property
doesn't work anymore.

It's hidden and always true, see https://github.com/systemd/systemd/commit/8f8cc84ba4612e74cd1e26898c6816e6e60fc4e9
and https://github.com/systemd/systemd/commit/c2b178d3cacad52eadc30ecc349160bc02d32a9c

So let's just assume that it's supported if the property is invalid.
FIXED-IN: 5.20.3


(cherry picked from commit f1393bc835ee28ceee54cdceb8d873622e36826a)

M  +8    -0    libkworkspace/kdisplaymanager.cpp

https://invent.kde.org/plasma/plasma-workspace/commit/aaa7a59a6710a89f21ebd441616df13be5ba8fef
Comment 12 Nate Graham 2020-12-17 05:24:20 UTC
*** Bug 430271 has been marked as a duplicate of this bug. ***
Comment 13 Jason Pollitt 2020-12-19 13:33:16 UTC
So I am running arch linux with extra/kscreenlocker 5.20.4-1  and I do not have switcher user, when the screen is locked, is there some extra step to get this working?
Comment 14 Wolfgang Bauer 2020-12-21 10:31:38 UTC
(In reply to Jason Pollitt from comment #13)
> So I am running arch linux with extra/kscreenlocker 5.20.4-1  and I do not
> have switcher user, when the screen is locked, is there some extra step to
> get this working?

The fix is in plasma-workspace (not kscreenlocker), since 5.20.3.

But no, there should be no extra step necessary. If you have plasma-workspace 5.20.4 (or 5.20.3), it should work  (you'd have to logout/login or reboot of course after installing the update).

It certainly works fine again in the latest openSUSE Tumbleweed (with systemd 246.7 and Plasma 5.20.4 meanwhile), I just tried a LiveCD.
Comment 15 Jason Pollitt 2020-12-22 18:15:20 UTC
(In reply to Wolfgang Bauer from comment #14)
Thanks, maybe I had not rebooted since the update all is working now.


> (In reply to Jason Pollitt from comment #13)
> > So I am running arch linux with extra/kscreenlocker 5.20.4-1  and I do not
> > have switcher user, when the screen is locked, is there some extra step to
> > get this working?
> 
> The fix is in plasma-workspace (not kscreenlocker), since 5.20.3.
> 
> But no, there should be no extra step necessary. If you have
> plasma-workspace 5.20.4 (or 5.20.3), it should work  (you'd have to
> logout/login or reboot of course after installing the update).
> 
> It certainly works fine again in the latest openSUSE Tumbleweed (with
> systemd 246.7 and Plasma 5.20.4 meanwhile), I just tried a LiveCD.
Comment 16 `{third: "Beedell", first: "Roke"}`{.JSON5} 2022-08-23 16:51:48 UTC
This continues to not operate for me. When I attempt to switch users after hitting Ctrl+L, the login page appears for a second, but is replaced by the Unlock button with a sliding-left animation.
Comment 17 Nate Graham 2022-08-25 07:08:44 UTC
That's a different issue. This bug report is about the functionality being missing; you're reporting that it's present, but doesn't work for you.