Skip to content

fix(power): deny inactive authorization without prompting - #200

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
mhduiy:power-wakeup-polkit
Oct 20, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:masterfrom
mhduiy:power-wakeup-polkit

Conversation

@mhduiy

@mhduiy mhduiy commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • deny polkit authorization for inactive sessions without opening an authentication dialog
  • log the rejected D-Bus sender, interface, and member

Verification

  • built plugin-power-system
  • validated policy XML
  • ran isolated D-Bus denial smoke test

PMS: BUG-379055
PMS: BUG-377891

Summary by Sourcery

Prevent inactive-session power actions from triggering authentication dialogs while improving diagnostics for rejected requests.

Bug Fixes:

  • Deny power authorization requests from inactive sessions without presenting an authentication prompt.
  • Log denied Polkit requests with their action, D-Bus sender, interface, and member.

Reject inactive-session power authorization without authentication prompts and log rejected D-Bus callers.

PMS: BUG-379055

PMS: BUG-377891
@sourcery-ai

sourcery-ai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

The power-system plugin now enforces non-interactive denial for inactive-session polkit requests, logs the rejected D-Bus call context, and returns an explicit access-denied response instead of allowing an authentication prompt.

Sequence diagram for inactive-session power authorization denial

sequenceDiagram
    participant Client as D-Bus Client
    participant Manager as SystemPowerManager
    participant Polkit as Polkit Authority

    Client->>Manager: authorizePowerAction()
    Manager->>Polkit: Check authorization for kPowerAction
    Polkit-->>Manager: result != Yes
    Manager->>Manager: qWarning(logPowerSystem)
    Manager-->>Client: AccessDenied: Authentication failed
Loading

File-Level Changes

Change Details Files
Reject failed polkit authorization explicitly and record the originating D-Bus request.
  • Log the power action and D-Bus sender, interface, and member when authorization is not granted.
  • Return an AccessDenied D-Bus error with the existing authentication-failed message and stop processing.
src/plugin-qt/power/system/powermanager.cpp
Update the power-system polkit policy to deny inactive-session requests without prompting.
  • Adjust the authorization policy rule for inactive sessions.
  • Validate the policy XML and exercise the denial path through an isolated D-Bus smoke test.
src/plugin-qt/power/system/misc/org.deepin.dde.power.policy

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

总体评分: 100 分 (通过阈值: 70分)

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交目的是修复电源管理安全策略:将 inactive 会话的电源操作权限从 auth_admin(需管理员认证)收紧为 no(直接拒绝), 并在 polkit 授权被拒绝时增加 qWarning 日志记录以便排查。变更涉及 polkit 策略文件和 C++ 源码各一处,共 4 行新增、1 行删除, 改动范围小且目标明确。语法逻辑正确,代码质量良好,性能无影响,安全方面实际上是安全加固(收紧权限),未引入任何安全漏洞。 启发式扫描、AI 四维度分析、OCR 审查三方结果一致,均未发现问题。

🔍 详细分析

1. 语法逻辑 ✅

评价: 语法正确,逻辑清晰 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


2. 代码质量 ✅

评价: 代码结构清晰,注释完整 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


3. 代码性能 ✅

评价: 性能良好,资源使用合理 ✅ 通过

潜在问题:
✅ 未发现明显问题

建议: []


4. 代码安全 🔒

评价: 存在0个安全漏洞 ✅ 通过

🔐 发现 0 个安全漏洞

安全漏洞详情:
✅ 未发现安全漏洞

建议: []


💡 改进建议代码示例

无需修复,当前代码已符合最佳实践。

本报告由 AI 代码审查工具自动生成

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: fly602, mhduiy

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@mhduiy

mhduiy commented Oct 20, 2026

Copy link
Copy Markdown
Contributor Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

This pr force merged! (status: blocked)

@deepin-bot
deepin-bot Bot merged commit 13d8db6 into linuxdeepin:master Oct 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants