Repository navigation
fix: honour logind block inhibitors for power actions - #121
Conversation
Reviewer's GuideImplementationRoute logind power actions through the inhibitor-aware WithFlags methods while preserving the existing ConsoleKit2 calls, and log refused requests.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/daemon/PowerManager.cpp" line_range="207" />
<code_context>
+ }
+
+ constexpr qint64 rootCheckInhibitors = 1; // SD_LOGIND_ROOT_CHECK_INHIBITORS
+ auto reply = m_interface->call(flagsMethod, rootCheckInhibitors);
+ if (reply.type() == QDBusMessage::ErrorMessage)
+ qWarning() << flagsMethod << "refused:" << reply.errorMessage();
</code_context>
<issue_to_address>
**Power actions are rejected**
When the logind backend handles a power action, `callWithInhibitCheck` sends only a signed `qint64` instead of the required interactive boolean and unsigned 64-bit flags argument, so logind rejects the request and the power action does not happen.
Pass the interactive boolean and flags value with the D-Bus types required by logind’s `*WithFlags` methods.
</issue_to_address>| } | ||
|
|
||
| constexpr qint64 rootCheckInhibitors = 1; // SD_LOGIND_ROOT_CHECK_INHIBITORS | ||
| auto reply = m_interface->call(flagsMethod, rootCheckInhibitors); |
There was a problem hiding this comment.
🟠 High · Power actions are rejected
When the logind backend handles a power action, callWithInhibitCheck sends only a signed qint64 instead of the required interactive boolean and unsigned 64-bit flags argument, so logind rejects the request and the power action does not happen.
Pass the interactive boolean and flags value with the D-Bus types required by logind’s *WithFlags methods.
Prompt for AI agents
In `src/daemon/PowerManager.cpp` at line 207:
**Power actions are rejected**
When the logind backend handles a power action, `callWithInhibitCheck` sends only a signed `qint64` instead of the required interactive boolean and unsigned 64-bit flags argument, so logind rejects the request and the power action does not happen.
Pass the interactive boolean and flags value with the D-Bus types required by logind’s `*WithFlags` methods.1. ddm runs as root and called the old Suspend(bool)-style logind 2. methods, which only set SD_LOGIND_INTERACTIVE, so logind let root 3. ignore block inhibitors and a file copy task in a Treeland session 4. could still be suspended from the lock screen shutdown menu 5. Call the *WithFlags variants with SD_LOGIND_ROOT_CHECK_INHIBITORS so 6. logind enforces the inhibitors for root as well, and log a warning 7. when the request is refused Log: Power actions from the lock screen now honour app block inhibitors Influence: 1. Start a large copy in dde-file-manager, then choose Suspend from the shutdown menu; the system must stay awake and ddm must log a warning 2. Without any inhibitor, verify Suspend, Hibernate, Power Off and Reboot still work from the lock screen 3. Verify power actions from the greeter before login still work, and a ConsoleKit2 build keeps the old logind call fix: 电源操作不再绕过 logind 的待机/关机抑制 1. ddm 以 root 运行且调用旧式 Suspend(bool) 系列 logind 接口,该接口只 设置 SD_LOGIND_INTERACTIVE,logind 因此允许 root 忽略 block inhibitor,Treeland 会话中有拷贝任务时仍能从关机菜单待机 2. 改用 *WithFlags 系列接口并传入 SD_LOGIND_ROOT_CHECK_INHIBITORS,由 logind 对 root 一并校验抑制,被拒时记录告警日志 Log: 关机菜单发起的待机、关机等电源操作现在会遵守应用的待机抑制 Influence: 1. 用文件管理器拷贝大文件,再从关机菜单点待机,系统应保持唤醒且 ddm 日志中出现告警 2. 无任何抑制时,锁屏下待机、休眠、关机、重启均正常工作 3. 登录界面(greeter)下的电源操作正常,ConsoleKit2 环境仍走旧接口 PMS: BUG-380947
deepin pr auto review🤖 AI 代码审查报告📊 总体评价
🔍 详细分析1. 语法逻辑 ✅评价: 语法正确,逻辑清晰 ✅ 通过 潜在问题: 建议: ['可考虑在 *WithFlags 调用失败时回退到 plainMethod 调用作为兜底,以增强对旧版 systemd 的兼容性;但需确保回退路径不会重新引入忽略 inhibitor 的原始问题。'] 2. 代码质量 ✅评价: 代码结构清晰,注释完整 ✅ 通过 潜在问题: 建议: [] 3. 代码性能 ✅评价: 性能良好,资源使用合理 ✅ 通过 潜在问题: 建议: [] 4. 代码安全 🔒评价: 存在0个安全漏洞 ✅ 通过
安全漏洞详情: 建议: [] 💡 改进建议代码示例// 可选增强:在 *WithFlags 调用失败时提供回退路径
void callWithInhibitCheck(const QString &plainMethod, const QString &flagsMethod) const {
if (m_interface->interface() != LOGIN1_OBJECT) {
m_interface->call(plainMethod, true);
return;
}
constexpr qint64 rootCheckInhibitors = 1; // SD_LOGIND_ROOT_CHECK_INHIBITORS
auto reply = m_interface->call(flagsMethod, rootCheckInhibitors);
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning() << flagsMethod << "refused:" << reply.errorMessage();
// 可选:回退到旧方法(注意可能重新引入忽略 inhibitor 的问题)
// m_interface->call(plainMethod, true);
}
}本报告由 AI 代码审查工具自动生成 |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Groveer, zccrs The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Log: Power actions from the lock screen now honour app block inhibitors
Influence:
fix: 电源操作不再绕过 logind 的待机/关机抑制
Log: 关机菜单发起的待机、关机等电源操作现在会遵守应用的待机抑制
Influence:
PMS: BUG-380947
Summary by Sourcery
Honor logind power-action inhibitors for root-initiated operations from the lock screen.
Bug Fixes:
Enhancements: