From fc7b8efa711e20dbd85c1dbf7f6e59141ead7dd6 Mon Sep 17 00:00:00 2001 From: zhangkun Date: Tue, 18 Aug 2026 20:26:02 +0800 Subject: [PATCH] fix(power): secure system power actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. Register trusted callers with persisted UID and PID validation. 2. Authorize privileged power changes through caller records or Polkit. 3. Restrict SetAllowCaller to trusted registrars and D-Bus policies. 4. Add the security-loader and Polkit build/runtime dependencies. Log: Protect system Power1 mutations with explicit caller authorization. Influence: System power changes require authorization. fix(power): 加固系统电源操作 1. 通过持久化的 UID 和 PID 校验登记可信调用者。 2. 通过调用者记录或 Polkit 鉴权敏感电源变更。 3. 通过可信登记者和 D-Bus 策略限制 SetAllowCaller。 4. 添加 security-loader 与 Polkit 构建和运行依赖。 Log: 为系统 Power1 敏感操作增加明确的调用者鉴权。 PMS: TASK-394241 Influence: 系统电源变更需要通过鉴权。 --- debian/control | 4 +- src/plugin-qt/power/system/CMakeLists.txt | 3 + .../misc/dbus/org.deepin.dde.Power1.conf | 14 + src/plugin-qt/power/system/powermanager.cpp | 282 ++++++++++++++++++ src/plugin-qt/power/system/powermanager.h | 14 + 5 files changed, 316 insertions(+), 1 deletion(-) diff --git a/debian/control b/debian/control index fc7a3f59..b4ae4f7e 100644 --- a/debian/control +++ b/debian/control @@ -16,6 +16,7 @@ Build-Depends: debhelper (>= 11), libnet-dev, libglib2.0-dev, libdtk6gui-dev, + libpolkit-qt6-1-dev, libdtk6core-dev, libx11-dev, libxext-dev, @@ -44,7 +45,8 @@ Depends: ${misc:Depends}, deepin-service-manager (>> 1.0.21), dbus, - deepin-power-control (>= 2.0.1) + deepin-power-control (>= 2.0.1), + deepin-security-loader Recommends: iio-sensor-proxy Breaks: dde-daemon (<< 6.1.102) diff --git a/src/plugin-qt/power/system/CMakeLists.txt b/src/plugin-qt/power/system/CMakeLists.txt index 3dbe0946..b96853b6 100644 --- a/src/plugin-qt/power/system/CMakeLists.txt +++ b/src/plugin-qt/power/system/CMakeLists.txt @@ -16,6 +16,7 @@ find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core DBus) find_package(Dtk${DTK_VERSION_MAJOR} REQUIRED COMPONENTS Core) find_package(PkgConfig REQUIRED) pkg_check_modules(UDEV REQUIRED libudev) +pkg_check_modules(POLKIT_QT REQUIRED polkit-qt6-1) file(GLOB_RECURSE SRCS "*.cpp" "*.h") @@ -24,6 +25,7 @@ add_library(${BIN_NAME} MODULE ${SRCS}) target_include_directories(${BIN_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${UDEV_INCLUDE_DIRS} + ${POLKIT_QT_INCLUDE_DIRS} ) target_link_libraries(${BIN_NAME} PRIVATE @@ -31,6 +33,7 @@ target_link_libraries(${BIN_NAME} PRIVATE Qt${QT_VERSION_MAJOR}::DBus Dtk${DTK_VERSION_MAJOR}::Core ${UDEV_LIBRARIES} + ${POLKIT_QT_LIBRARIES} ) install(TARGETS ${BIN_NAME} diff --git a/src/plugin-qt/power/system/misc/dbus/org.deepin.dde.Power1.conf b/src/plugin-qt/power/system/misc/dbus/org.deepin.dde.Power1.conf index 1c8cf3e9..2b81e0f0 100644 --- a/src/plugin-qt/power/system/misc/dbus/org.deepin.dde.Power1.conf +++ b/src/plugin-qt/power/system/misc/dbus/org.deepin.dde.Power1.conf @@ -8,6 +8,16 @@ + + + + + +