Skip to content

fix: reset error flag in home-path early-return of getFileInfo - #568

Closed
pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/pms-bug-bot/f2f26fe16e42
Closed

pengfeixx wants to merge 1 commit into
linuxdeepin:masterfrom
pengfeixx:agent/pms-bug-bot/f2f26fe16e42

Conversation

@pengfeixx

@pengfeixx pengfeixx commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Root Cause Analysis

DLDBusHandler::getFileInfo() has an early-return branch for home-path logs (isHomePath(flag)) that bypasses DBus and reads locally via UserLogAccess. This branch was introduced by security commit 2c782c4 (BUG-376053) but did not reset the m_bGetFileInfoError flag. When a user first cancels a system-log DBus auth dialog, the flag is set to true; switching to app logs (home-path) leaves the stale true untouched, and LogApplicationParseThread::parseByFile() (logapplicationparsethread.cpp:153) unconditionally checks isGetFileInfoError(), mistaking the stale state for an auth failure and aborting — producing a blank view.

Key evidence:

  • dldbushandler.cpp:255-256: home-path early-return directly returns without resetting m_bGetFileInfoError
  • logapplicationparsethread.cpp:153: parseByFile() checks isGetFileInfoError() unconditionally, regardless of log path type
  • logapplicationhelper.cpp: app log default path is ~/.cache/deepin/<appname>, which triggers the home-path branch

Fix Approach

Add m_bGetFileInfoError = false; before the early return in the home-path branch of getFileInfo(), ensuring the error flag is cleared regardless of which code path executes. This is consistent with the DBus success branch (line 266) that already resets the flag. The fix is a single-line addition with no logic changes to existing paths.

Change Safety Assessment

Code Safety

  • Risk Level: Low
  • The home-path branch was introduced by security commit 2c782c4 (BUG-376053); this fix supplements the flag reset that was missed in that commit without reverting or altering the security hardening
  • Downstream caller LogApplicationParseThread::parseByFile() benefits directly — stale true no longer causes false abort; no other callers are affected
  • No regression risk to related PMS bugs (278915, 374573) — their commits do not touch getFileInfo()'s home-path branch or m_bGetFileInfoError

Business Impact Scope

  • Application log display: App logs (stored under ~/.cache/deepin/) will now always display correctly regardless of prior system-log auth state
  • System log flow: Unchanged — DBus error/success paths retain existing flag-setting behavior
  • User scenario: Switching between system logs (with auth cancel) and app logs no longer produces blank app log content

Verification Suggestion

  1. Open log viewer, switch to a system log type, cancel the auth dialog, then switch to app logs — verify app logs display normally
  2. Repeatedly switch between system logs and app logs — verify no blank screens appear

根因分析

DLDBusHandler::getFileInfo() 的 home-path early-return 分支(isHomePath(flag))绕过 DBus 直接通过 UserLogAccess 本地读取日志。该分支由安全提交 2c782c4(BUG-376053)引入,但未重置 m_bGetFileInfoError 标志。当用户先取消系统日志 DBus 鉴权弹窗时,标志被置为 true;切换到应用日志(home-path)时,过期的 true 状态未被清除,LogApplicationParseThread::parseByFile()(logapplicationparsethread.cpp:153)无条件检查 isGetFileInfoError(),误判为鉴权失败并中止,导致应用日志显示空白。

关键证据:

  • dldbushandler.cpp:255-256:home-path early-return 直接返回,不重置 m_bGetFileInfoError
  • logapplicationparsethread.cpp:153:parseByFile() 无条件检查 isGetFileInfoError(),不区分日志路径类型
  • logapplicationhelper.cpp:应用日志默认路径为 ~/.cache/deepin/<appname>,走 home-path 分支

修复方案

在 getFileInfo() 的 home-path early-return 分支的 return 之前新增 m_bGetFileInfoError = false;,确保无论走哪条路径都清除错误标志。与 DBus 成功分支(266 行)已有重置逻辑保持一致。仅新增 1 行,不修改任何现有路径逻辑。

改动安全评估

代码安全评估

  • 风险等级:低风险
  • home-path 分支由安全提交 2c782c4(BUG-376053)引入;本修复仅补充遗漏的标志重置,不撤销或修改安全加固逻辑
  • 下游调用方 LogApplicationParseThread::parseByFile() 直接受益——过期的 true 不再导致误中止;无其他调用方受影响
  • 对关联 PMS 单(278915、374573)无回归风险——其提交不涉及 getFileInfo() 的 home-path 分支或 m_bGetFileInfoError

业务影响范围

  • 应用日志显示:应用日志(存储在 ~/.cache/deepin/ 下)不再受先前系统日志鉴权状态影响,始终正常显示
  • 系统日志流程:不变——DBus 错误/成功路径保持现有标志设置逻辑
  • 用户场景:在系统日志(取消鉴权)与应用日志之间切换不再出现空白内容

验证建议

  1. 打开日志收集工具,切换到系统日志类型,取消鉴权弹窗,再切换到应用日志——验证应用日志正常显示
  2. 在系统日志与应用日志之间反复切换——验证不出现空白

Summary by Sourcery

Bug Fixes:

  • Clear the file-info error state when reading home-directory application logs, preventing stale authentication errors from leaving app-log views blank.

1. Root cause: getFileInfo() home-path early-return branch (introduced
   by security commit 2c782c4) skips m_bGetFileInfoError reset, leaving
   stale true from prior system-log DBus auth failure to pollute app-log
   parsing
2. Fix: add m_bGetFileInfoError = false before early return so the flag
   is cleared regardless of which path executes
3. Impact: only the home-path branch gets the reset; DBus error/success
   paths unchanged, no behavior change for system-log flow

Influence:
1. Test app log display after canceling system-log auth dialog
2. Test switching between system logs and app logs repeatedly
3. Verify app logs display normally after DBus auth failure recovery

fix: 修复getFileInfo的home路径提前返回分支未重置错误标志

1. 根因:getFileInfo() 的 home-path 提前返回分支(安全提交 2c782c4 引入)
   未重置 m_bGetFileInfoError,导致系统日志 DBus 鉴权失败留下的过期 true
   状态污染后续应用日志解析
2. 方案:在提前返回前新增 m_bGetFileInfoError = false,确保无论走哪条
   分支都清除错误标志
3. 影响:仅 home-path 分支增加重置,DBus 错误/成功路径不变,系统日志
   流程无行为变化

Influence:
1. 测试取消系统日志鉴权弹窗后查看应用日志是否正常显示
2. 测试系统日志与应用日志之间反复切换
3. 验证 DBus 鉴权失败恢复后应用日志显示正常

PMS: BUG-378513
@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

Copy link
Copy Markdown

Sorry @pengfeixx, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 9 hours and 32 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pengfeixx

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

@sourcery-ai

sourcery-ai Bot commented Oct 27, 2026

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

Reviewer's Guide

This one-line fix resets the error flag on the home-path early return, preventing a previously cancelled system-log authentication from causing application-log parsing to abort and display blank content.

Sequence diagram for clearing stale log access errors

sequenceDiagram
    participant User
    participant LogApplicationParseThread
    participant DLDBusHandler
    participant UserLogAccess

    User->>LogApplicationParseThread: parseByFile()
    LogApplicationParseThread->>DLDBusHandler: getFileInfo(flag, unzip)
    alt home-path application log
        DLDBusHandler->>DLDBusHandler: m_bGetFileInfoError = false
        DLDBusHandler->>UserLogAccess: getFileInfo(flag, unzip)
        UserLogAccess-->>DLDBusHandler: file information
        DLDBusHandler-->>LogApplicationParseThread: file information
        LogApplicationParseThread-->>User: display application logs
    else prior system-log authentication was cancelled
        LogApplicationParseThread->>DLDBusHandler: isGetFileInfoError()
        DLDBusHandler-->>LogApplicationParseThread: false
    end
Loading

File-Level Changes

Change Details Files
Clear stale get-file-info error state before returning from the local home-path log handling branch.
  • Reset m_bGetFileInfoError before delegating home-path file enumeration to UserLogAccess.
  • Preserve existing DBus and local log retrieval behavior while preventing downstream false authentication failures.
application/dbusproxy/dldbushandler.cpp

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

@deepin-ci-robot

Copy link
Copy Markdown

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 getFileInfo 函数中 home-path 早返回路径未重置 m_bGetFileInfoError 错误标志的问题,变更正确、最小化且逻辑清晰,四维度均无问题,启发式扫描与 OCR 审查均未发现问题,无安全漏洞。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: 无


2. 代码质量 ✅

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

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

建议: 无


3. 代码性能 ✅

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

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

建议: 无


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: 无


💡 改进建议代码示例

// 当前修复已正确,无需额外修改
// application/dbusproxy/dldbushandler.cpp
QStringList DLDBusHandler::getFileInfo(const QString &flag, bool unzip)
{
    // ...
    // home 目录下日志由用户日志访问类本地列举
    if (isHomePath(flag)) {
        m_bGetFileInfoError = false;  // 重置错误标志,防止上次调用的错误状态残留
        return UserLogAccess::instance()->getFileInfo(flag, unzip);
    }
    // ...
}

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

@pengfeixx pengfeixx closed this Oct 28, 2026
@pengfeixx
pengfeixx deleted the agent/pms-bug-bot/f2f26fe16e42 branch October 28, 2026 09:24
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.

2 participants