Skip to content

fix: localize expired AD password change errors - #585

Merged
deepin-bot[bot] merged 1 commit into
linuxdeepin:release/2500u2-pajilfrom
52cyb:release/2500u2-pajil
Nov 26, 2026
Merged

deepin-bot[bot] merged 1 commit into
linuxdeepin:release/2500u2-pajilfrom
52cyb:release/2500u2-pajil

Conversation

@52cyb

@52cyb 52cyb commented Nov 25, 2026 •

Copy link
Copy Markdown
  1. Load the configured PAM translation catalog for Snipe greeter and lock screen password changes.
  2. Preserve translated errors when PAM requests another entry.
  3. Translate mismatched password inputs and render catalog line breaks.

Log: Localize errors when changing expired AD passwords.

Influence:

  1. Verify the Chinese message for mismatched password inputs.
  2. Verify translated policy errors and line breaks on the lock screen.
  3. Verify translated errors persist when the greeter requests re-entry.

fix: 修复 AD 域用户过期改密提示的汉化缺口

  1. 登录和锁屏改密时读取 Snipe 配置指定的 PAM 翻译资源。
  2. 同一 PAM 会话要求重输新密码时保留错误译文。
  3. 补齐两次密码输入不一致的译文并正确显示换行。

Influence:

  1. 验证两次密码输入不一致时显示中文提示。
  2. 验证锁屏改密的策略错误译文和换行。
  3. 验证登录界面要求重输新密码时继续显示错误译文。

Log: 修复 AD 域密码过期后修改密码时的错误提示汉化。
PMS: BUG-384335

Summary by Sourcery

Localize and preserve PAM errors throughout expired-password changes in the greeter and lock screen.

Bug Fixes:

  • Localize PAM password-change errors for expired domain passwords in the greeter and lock screen, including mismatched-password messages and policy failures.
  • Preserve translated PAM errors when the greeter requests a new password again and render translated line breaks correctly.

Enhancements:

  • Load PAM error translations from the configured locale-specific catalog for password-change flows.

Tests:

  • Add coverage for retaining translated greeter errors across password retries and displaying catalog line breaks in lock-screen errors.

@sourcery-ai

sourcery-ai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Add the Chinese translation for the inconsistent-password-input message.

  • translations/dde-session-shell_zh_CN.ts L627-630

API

Extend the greeter password-change message interface to accept an optional translated PAM error and display it when an error arrives after a replacement password was sent.

  • src/global_util/greeterpasswordchange.cpp L241, L248-249
  • src/global_util/greeterpasswordchange.h L27

Uses of the API

Translate PAM errors at the greeter and lock-screen call sites before forwarding them to the password-change flow.

  • src/global_util/lockpasswordchange.cpp L6, L387, L394-398
  • src/lightdm-deepin-greeter/greeterworker.cpp L14, L960-965

Implementation

Add the catalog-backed PAM translator that loads locale-specific messages and matches PAM output to translated policy errors.

  • src/global_util/pamtranslator.cpp L1-158
  • src/global_util/pamtranslator.h L1-31

UI

Convert escaped catalog line breaks into visible newlines while keeping lock-screen errors rendered as plain text.

  • src/session-widgets/lockpasswordchangewidget.cpp L223-225

Configuration

Add the Snipe configuration entries used to locate the PAM translation catalogs for the greeter and lock screen.

  • configs/snipe/org.deepin.dde.lightdm-deepin-greeter.json L327-336
  • configs/snipe/org.deepin.dde.lock.json L324-333

Tests

Cover translated greeter errors across re-entry and lock-screen rendering of escaped line breaks.

  • tests/dde-lock/ut_greeterpasswordchange.cpp L20-45
  • tests/dde-lock/ut_lockpasswordchange.cpp L2039-2041

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 found 9 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="src/global_util/pamtranslator.cpp" line_range="153" />
<code_context>
+        return result;
+    }
+
+    qWarning() << " Need add translation : " << content;
+    return content;
+}
</code_context>
<issue_to_address>
**Passwords appear in system logs**

When a PAM message contains a password and has no catalog match, `GreeterWorker::showMessage()` passes unmatched PAM text to `trans()`, and `getTranslation()` logs the full message with `qWarning()`, exposing the password in system logs.

Remove the unmatched message contents from the warning or sanitize them before logging.

Also at `src/lightdm-deepin-greeter/greeterworker.cpp:961`.
</issue_to_address>

### Comment 2
<location path="src/global_util/pamtranslator.cpp" line_range="37" />
<code_context>
+    // 如果force为true,没有对应方案时用complexity constraints的翻译作为结果
+    if (force) {
+        if (!m_ADomainErrorDetailMap.values().contains(content)) {
+            content = getTranslation("complexity constraints");
+            qInfo() << Q_FUNC_INFO << " Content lost in detailMap : " << content;
+        }
</code_context>
<issue_to_address>
**Wrong password failure appears as policy error**

When the lock-screen password-change process fails with output that has no catalog match, `LockPasswordChange::startProcess()` calls `PamTranslator::trans()` with `force=true`, and the forced lookup substitutes the “complexity constraints” translation for unmatched output, so an unrelated failure appears as a password-policy error.

Preserve unmatched failure output instead of replacing it with the “complexity constraints” translation.

Also at `src/global_util/lockpasswordchange.cpp:395`.
</issue_to_address>

### Comment 3
<location path="src/lightdm-deepin-greeter/greeterworker.cpp" line_range="961-962" />
<code_context>
         if (!ensurePasswordChangeAllowed())
             return;
+#ifdef ENABLE_DSS_SNIPE
+        const auto message = PamTranslator::instance()->trans(text);
+        m_passwordChange->message(type == QLightDM::Greeter::MessageTypeError, message == text ? QString() : message);
+#else
         m_passwordChange->message(type == QLightDM::Greeter::MessageTypeError);
</code_context>
<issue_to_address>
**PAM errors use the wrong language**

When the active greeter user's authentication locale differs from the system locale, `PamTranslator` loads its catalog from the system locale, and `GreeterWorker::showMessage()` calls `trans()` without applying the authentication locale, so PAM errors appear in the wrong language or untranslated.

Set the translator to the active user's authentication locale before translating PAM messages.

Also at `src/global_util/pamtranslator.cpp:21`.
</issue_to_address>

### Comment 4
<location path="src/global_util/greeterpasswordchange.cpp" line_range="245" />
<code_context>
-    if (!m_active || !m_submitted || !error)
+    if (!m_active || !m_submitted)
+        return;
+    if (m_replacementSent && !translatedError.isEmpty())
+        m_passwordError = translatedError;
+    if (!error)
</code_context>
<issue_to_address>
**Informational messages become failure details**

When PAM sends a translated informational message after a replacement-password response, `GreeterPasswordChange::message()` stores `translatedError` before checking whether the message is an error, so an informational message can replace or remain as the detail shown during re-entry.

Only store translated messages for errors, and clear the cached detail when an error has no translation.
</issue_to_address>

### Comment 5
<location path="src/global_util/pamtranslator.cpp" line_range="87" />
<code_context>
+            QString source;
+            QString translation;
+
+            while (xml.readNextStartElement()) {
+                if (xml.name() == "source") {
+                    source = xml.readElementText();
</code_context>
<issue_to_address>
**Catalog entries with locations are skipped**

When a configured TS catalog has a `<location>` element before its source and translation, `readNextStartElement()` encounters an unhandled `<location>` child and exits the message loop before reading `<source>` or `<translation>`; the translation map stays empty for these standard TS entries, so PAM errors remain untranslated.

Skip unrecognized message children (or otherwise continue traversing the message) instead of ending the loop on them.
</issue_to_address>

### Comment 6
<location path="src/global_util/pamtranslator.cpp" line_range="91" />
<code_context>
+                if (xml.name() == "source") {
+                    source = xml.readElementText();
+                } else if (xml.name() == "translation") {
+                    translation = xml.readElementText();
+                }
+            }
</code_context>
<issue_to_address>
**Plural entries truncate the catalog**

When a configured PAM `.ts` catalog contains a plural translation before the password-error entries, `readElementText()` uses its default behavior, which treats nested elements as an XML error. A standard Qt plural translation contains a nested `<numerusform>` element, so parsing stops there and the loader returns only entries before it; later password-error translations are unavailable.

Read translation elements in a way that handles nested `<numerusform>` elements, and report or reject malformed catalogs instead of silently returning a partial map.
</issue_to_address>

### Comment 7
<location path="translations/dde-session-shell_zh_CN.ts" line_range="628-629" />
<code_context>
         <translation>密码不能为空</translation>
     </message>
+    <message>
+        <source>The two password inputs are inconsistent.</source>
+        <translation>两次密码输入不一致</translation>
+    </message>
     <message>
</code_context>
<issue_to_address>
**Greeter mismatch remains English**

When a user enters different new-password and confirmation values in the greeter, the added translation is in the `LockPasswordChangeWidget` context, but `GreeterPasswordChange::submit` looks up the same source text in the `GreeterPasswordChange` context; mismatched inputs in the greeter therefore still show the untranslated English message.

Add the message under the `GreeterPasswordChange` translation context as well.
</issue_to_address>

### Comment 8
<location path="tests/dde-lock/ut_greeterpasswordchange.cpp" line_range="38" />
<code_context>
+    ASSERT_TRUE(QTest::qWaitFor([&] { return responses.count() == 1; }));
+
+    change.message(false, detail);
+    EXPECT_EQ(change.passwordErrorText(), detail);
+    change.message(true);
+    change.prompt("New password:", true);
</code_context>
<issue_to_address>
**Retry error display goes unverified**

When the retry path stops emitting `formChanged` after clearing `busy`, when the retry path clears `busy` without emitting its own `formChanged`, `form.last()` still refers to the translated error emitted by `message(true)` before the retry, so this assertion passes without verifying that re-entry displays the error.

Record the spy count before the retry and assert that a new form signal is emitted with the translated error and `busy == false`.
</issue_to_address>

### Comment 9
<location path="tests/dde-lock/ut_greeterpasswordchange.cpp" line_range="43" />
<code_context>
+            "description": "提供pam翻译内容的ts文件路径前缀",
+            "permissions": "readwrite",
+            "visibility": "private"
         }
     }
 }
</code_context>
<issue_to_address>
**Finish clearing goes untested**

When `reset()` no longer clears a stored password error, when `reset()` stops clearing `m_passwordError`, `submit()` on line 39 has already cleared it, so `finish(false)` at line 41 has nothing to clear and the assertion at line 42 still passes.

Store a translated error again after the submit assertion and before calling `finish(false)`, then assert that finishing clears it.
</issue_to_address>

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

Comment thread src/global_util/pamtranslator.cpp Resolved
Comment thread src/global_util/pamtranslator.cpp Resolved
Comment thread src/global_util/pamtranslator.cpp Resolved
Comment thread src/global_util/pamtranslator.cpp Resolved
Comment thread translations/dde-session-shell_zh_CN.ts Resolved
@52cyb
52cyb force-pushed the release/2500u2-pajil branch from d8d6404 to ac3b6c7 Compare November 26, 2026 03:15
@52cyb

52cyb commented Nov 26, 2026

Copy link
Copy Markdown
Author

/test all

1. Load the configured PAM translation catalog for Snipe greeter
   and lock screen password changes.
2. Preserve translated errors when PAM requests another entry.
3. Translate mismatched password inputs and render catalog line breaks.

Log: Localize errors when changing expired AD passwords.

Influence:
1. Verify the Chinese message for mismatched password inputs.
2. Verify translated policy errors and line breaks on the lock screen.
3. Verify translated errors persist when the greeter requests re-entry.

fix: 修复 AD 域用户过期改密提示的汉化缺口

1. 登录和锁屏改密时读取 Snipe 配置指定的 PAM 翻译资源。
2. 同一 PAM 会话要求重输新密码时保留错误译文。
3. 补齐两次密码输入不一致的译文并正确显示换行。

Influence:
1. 验证两次密码输入不一致时显示中文提示。
2. 验证锁屏改密的策略错误译文和换行。
3. 验证登录界面要求重输新密码时继续显示错误译文。

Log: 修复 AD 域密码过期后修改密码时的错误提示汉化。
PMS: BUG-384335
@52cyb
52cyb force-pushed the release/2500u2-pajil branch from ac3b6c7 to 7884a97 Compare November 26, 2026 05:03
@deepin-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: 52cyb, yixinshark

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

@52cyb

52cyb commented Nov 26, 2026

Copy link
Copy Markdown
Author

/forcemerge

@deepin-bot

deepin-bot Bot commented Nov 26, 2026

Copy link
Copy Markdown

This pr force merged! (status: unstable)

@deepin-bot
deepin-bot Bot merged commit 67d32f1 into linuxdeepin:release/2500u2-pajil Nov 26, 2026
13 of 19 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