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

Clean up LangSelector processes from both supported paths during logout to prevent stale notification translations.

Bug Fixes:

  • Ensure logout terminates LangSelector processes launched from both legacy and current executable paths, preventing stale session languages from affecting subsequent notifications.

Enhancements:

  • Restrict LangSelector cleanup to the current user and anchor executable matching to avoid terminating unrelated processes.

@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-bot

deepin-bot Bot commented Oct 20, 2026

Copy link
Copy Markdown

TAG Bot

New tag: 2.0.35
DISTRIBUTION: unstable
Suggest: synchronizing this PR through rebase #238

@52cyb
52cyb force-pushed the master branch 2 times, most recently from e2dab27 to 65c0296 Compare October 28, 2026 03:38
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

deepin pr auto review

🤖 AI 代码审查报告

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

Pass


📊 总体评价

项目 结果
审查结论 代码审查通过
评分详情 本次提交修复了 stopLangSelector() 函数仅匹配旧路径的问题,改用正则表达式同时匹配新旧两条 langselector 进程路径。 代码改动简洁、注释完善、逻辑正确,四维度均无问题,无安全漏洞。正则表达式使用锚点和边界匹配确保精确匹配, 避免误杀其他进程,整体质量优秀。

🔍 详细分析

1. 语法逻辑 ✅

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

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

建议: []


2. 代码质量 ✅

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

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

建议: []


3. 代码性能 ✅

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

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

建议: []


4. 代码安全 🔒

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

🔐 发现 0 个安全漏洞

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

建议: []


💡 改进建议代码示例

当前代码无需修复,实现正确。完整代码如下:
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