Skip to content

fix: clean up both LangSelector paths on logout - #237

Open
52cyb wants to merge 1 commit into
linuxdeepin:masterfrom
52cyb:master
Open

52cyb wants to merge 1 commit into
linuxdeepin:masterfrom
52cyb:master

Conversation

@52cyb

@52cyb 52cyb commented Oct 20, 2026 •

Copy link
Copy Markdown
  1. The executable moved to /usr/libexec/deepin/langselector. /usr/lib/deepin-daemon/langselector remains a compatible entry point, using a wrapper and security loader to launch the new executable.
  2. Logout cleanup only matched the old path, missing the actual process. Surviving processes retained their startup locale and cached translations, causing notifications to use a previous session's language.
  3. Temporarily match both paths during logout, restricted to the current user. Anchor the command path and program name to avoid false matches. Abnormal session exits and reactivation after cleanup remain uncovered.

Log: Fix stale notification translations after changing session language

Influence:

  1. Switch between English, Simplified Chinese and Traditional Chinese; log out and back in, then verify notification language.
  2. Verify LangSelector processes from either path terminate on logout.
  3. Verify cleanup does not affect other users or similarly named programs.

fix: 注销时兼容清理新旧路径的 LangSelector 进程

  1. LangSelector 的真实二进制已迁移至 /usr/libexec/deepin/langselector,旧路径 /usr/lib/deepin-daemon/langselector 保留为兼容启动入口, 通过 wrapper 和安全加载器启动新路径下的程序。
  2. 原注销逻辑仅匹配旧路径,未覆盖新路径下的实际进程。 残留进程保留启动时的语言环境和翻译缓存,导致新会话切换语言时, 通知正文仍使用上一会话的语言。
  3. 临时方案在注销时同时匹配新旧路径,兼容不同安装布局, 保留当前用户限制,并限定命令行起始位置和程序名边界, 避免误匹配其他进程。 此方案暂不覆盖会话异常退出及清理后再次激活的情况。

Log: 修复切换会话语言后通知正文沿用旧语言的问题

Influence:

  1. 验证英文、简体中文、繁体中文之间切换并重新登录后的通知语言。
  2. 验证新旧路径启动的 LangSelector 均能在注销时退出。
  3. 验证不会清理其他用户的进程或名称相似的程序。

PMS: BUG-380095

Summary by Sourcery

Bug Fixes:

  • Ensure logout cleanup terminates LangSelector processes launched from both the legacy and relocated executable paths, preventing stale-language notifications in subsequent sessions.

1. The executable moved to /usr/libexec/deepin/langselector.
   /usr/lib/deepin-daemon/langselector remains a compatible entry point,
   using a wrapper and security loader to launch the new executable.
2. Logout cleanup only matched the old path, missing the actual process.
   Surviving processes retained their startup locale and cached translations,
   causing notifications to use a previous session's language.
3. Temporarily match both paths during logout, restricted to the current user.
   Anchor the command path and program name to avoid false matches.
   Abnormal session exits and reactivation after cleanup remain uncovered.

Log: Fix stale notification translations after changing session language

Influence:
1. Switch between English, Simplified Chinese and Traditional Chinese;
   log out and back in, then verify notification language.
2. Verify LangSelector processes from either path terminate on logout.
3. Verify cleanup does not affect other users or similarly named programs.

fix: 注销时兼容清理新旧路径的 LangSelector 进程

1. LangSelector 的真实二进制已迁移至
   /usr/libexec/deepin/langselector,旧路径
   /usr/lib/deepin-daemon/langselector 保留为兼容启动入口,
   通过 wrapper 和安全加载器启动新路径下的程序。
2. 原注销逻辑仅匹配旧路径,未覆盖新路径下的实际进程。
   残留进程保留启动时的语言环境和翻译缓存,导致新会话切换语言时,
   通知正文仍使用上一会话的语言。
3. 临时方案在注销时同时匹配新旧路径,兼容不同安装布局,
   保留当前用户限制,并限定命令行起始位置和程序名边界,
   避免误匹配其他进程。
   此方案暂不覆盖会话异常退出及清理后再次激活的情况。

Log: 修复切换会话语言后通知正文沿用旧语言的问题

Influence:
1. 验证英文、简体中文、繁体中文之间切换并重新登录后的通知语言。
2. 验证新旧路径启动的 LangSelector 均能在注销时退出。
3. 验证不会清理其他用户的进程或名称相似的程序。

PMS: BUG-380095
@deepin-ci-robot

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 52cyb

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 20, 2026

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

Reviewer's Guide

Updates logout cleanup so it terminates LangSelector processes launched from either the legacy /usr/lib/deepin-daemon path or the actual /usr/libexec/deepin path, preventing stale locale and translation state from surviving into a new session without affecting other users or similarly named programs.

Sequence diagram for logout LangSelector cleanup

sequenceDiagram
    participant SessionManager
    participant ProcessTable
    participant LangSelector

    SessionManager->>ProcessTable: stopLangSelector()
    ProcessTable->>ProcessTable: Match current UID with anchored LangSelector paths
    ProcessTable-->>SessionManager: Select legacy or actual path
    SessionManager->>LangSelector: Terminate matched process
Loading

File-Level Changes

Change Details Files
Expand logout-time LangSelector process matching to cover both the legacy compatibility entry point and the relocated executable while preserving user and command-boundary safeguards.
  • Match processes owned by the current UID.
  • Anchor the command path at the beginning and constrain it to the two supported LangSelector locations.
  • Require whitespace or end-of-command after the executable name to avoid similarly named process matches.
src/dde-session/impl/sessionmanager.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

@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 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 总体评分 98 分,大于 70 分通过阈值,代码质量符合要求。本次变更修复了注销时 LangSelector 进程清理仅匹配旧路径的问题,使用正则表达式同时匹配新旧路径,实现正确且安全。

🔍 详细分析

1. 语法逻辑 ✅

评价: 优秀 ✅ 通过

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

建议: 语法正确,逻辑清晰。正则表达式 ^/usr/(lib/deepin-daemon|libexec/deepin)/langselector([[:space:]]|$) 为有效的 POSIX ERE 模式,pkill -ef -u 命令结构正确,EXEC_COMMAND 宏通过 QProcess::start(cmd, args) 安全分离命令和参数执行,QString::number(getuid()) 正确转换 UID。


2. 代码质量 ✅

评价: 优秀 ✅ 通过

潜在问题:

  1. src/dde-session/impl/sessionmanager.cpp:614 - 正则表达式参数缺少简要注释,建议说明匹配的新旧两条路径及锚定目的,提高可维护性

建议: 建议在正则表达式参数上方添加简要注释,说明匹配的新旧两条路径(/usr/lib/deepin-daemon/langselector 和 /usr/libexec/deepin/langselector)以及锚定的目的,提高可维护性。


3. 代码性能 ✅

评价: 优秀 ✅ 通过

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

建议: 性能良好,资源使用合理。pkill 扫描 /proc 文件系统在注销场景下开销可接受,正则表达式简单无性能隐患。


4. 代码安全 🔒

评价: 优秀 ✅ 通过

🔐 发现 0 个安全漏洞

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

建议: 存在0个安全漏洞。正则表达式为编译期字符串字面量,无命令注入风险;getuid() 返回数值类型,无法被篡改;正则模式以 ^ 锚定起始、以 ([[:space:]]|$) 锚定结束,有效防止误匹配;-u 参数限制仅终止当前用户进程,确保用户隔离。


💡 改进建议代码示例

// 建议在正则参数上方添加注释
void SessionManager::stopLangSelector()
{
    // TODO 待优化,可以跟随当前用户一同退出
    // 匹配新旧两条路径的 langselector 进程:
    // /usr/lib/deepin-daemon/langselector (旧兼容入口)
    // /usr/libexec/deepin/langselector (新实际路径)
    EXEC_COMMAND("pkill"
                 , QStringList()
                 << "-ef"
                 << "-u"
                 << QString::number(getuid())
                 << "^/usr/(lib/deepin-daemon|libexec/deepin)/langselector([[:space:]]|$)"
                 );
}

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

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