67 lines
2.7 KiB
Diff
67 lines
2.7 KiB
Diff
From 40e7e134d87727cb651e9d290a852bd9ef95b826 Mon Sep 17 00:00:00 2001
|
||
From: tangjie02 <tangjie02@kylinsec.com.cn>
|
||
Date: Mon, 18 Jul 2022 16:20:26 +0800
|
||
Subject: [PATCH] fix(menu): Fix the switch user error by xdmcp logging.
|
||
MIME-Version: 1.0
|
||
Content-Type: text/plain; charset=UTF-8
|
||
Content-Transfer-Encoding: 8bit
|
||
|
||
- 修复通过xdmcp远程登录后切换用户错误问题
|
||
|
||
Closes #57865
|
||
|
||
Signed-off-by: tangjie02 <tangjie02@kylinsec.com.cn>
|
||
---
|
||
src/common/kiran-power.cpp | 28 +++++++++++++++++++++++-----
|
||
1 file changed, 23 insertions(+), 5 deletions(-)
|
||
|
||
diff --git a/src/common/kiran-power.cpp b/src/common/kiran-power.cpp
|
||
index c7f1011..9ef8a2c 100644
|
||
--- a/src/common/kiran-power.cpp
|
||
+++ b/src/common/kiran-power.cpp
|
||
@@ -68,11 +68,18 @@ KiranPower::KiranPower()
|
||
SESSION_MANAGER_PATH,
|
||
SESSION_MANAGER_INTERFACE);
|
||
|
||
- // TODO: 这里直接选用seat0是有问题的,需要获取会话所在seat
|
||
- this->seat_manager_proxy_ = Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BUS_TYPE_SYSTEM,
|
||
- DISPLAY_MANAGER_DBUS,
|
||
- DISPLAY_MANAGER_SEAT_PATH,
|
||
- DISPLAY_MANAGER_INTERFACE);
|
||
+ auto xdg_seat_object_path = Glib::getenv("XDG_SEAT_PATH");
|
||
+ if (!xdg_seat_object_path.empty())
|
||
+ {
|
||
+ this->seat_manager_proxy_ = Gio::DBus::Proxy::create_for_bus_sync(Gio::DBus::BUS_TYPE_SYSTEM,
|
||
+ DISPLAY_MANAGER_DBUS,
|
||
+ xdg_seat_object_path,
|
||
+ DISPLAY_MANAGER_INTERFACE);
|
||
+ }
|
||
+ else
|
||
+ {
|
||
+ KLOG_WARNING("Failed to get environment variable XDG_SEAT_PATH.");
|
||
+ }
|
||
}
|
||
catch (const Gio::DBus::Error &e)
|
||
{
|
||
@@ -359,6 +366,17 @@ bool KiranPower::can_logout()
|
||
bool KiranPower::can_switch_user()
|
||
{
|
||
RETURN_VAL_IF_TRUE(this->settings_->get_boolean(STARTMENU_LOCKDOWN_KEY_DISABLE_USER_SWITCHING), false);
|
||
+
|
||
+ try
|
||
+ {
|
||
+ Glib::VariantBase variant_value;
|
||
+ this->seat_manager_proxy_->get_cached_property(variant_value, "CanSwitch");
|
||
+ return Glib::VariantBase::cast_dynamic<Glib::Variant<bool>>(variant_value).get();
|
||
+ }
|
||
+ catch (const Glib::Error &e)
|
||
+ {
|
||
+ KLOG_WARNING("%s", e.what().c_str());
|
||
+ }
|
||
return true;
|
||
}
|
||
|
||
--
|
||
2.33.0
|
||
|