Repository navigation
fix: localize expired AD password change errors - #585
Conversation
Reviewer's GuideData structuresAdd the Chinese translation for the inconsistent-password-input message.
APIExtend 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.
Uses of the APITranslate PAM errors at the greeter and lock-screen call sites before forwarding them to the password-change flow.
ImplementationAdd the catalog-backed PAM translator that loads locale-specific messages and matches PAM output to translated policy errors.
UIConvert escaped catalog line breaks into visible newlines while keeping lock-screen errors rendered as plain text.
ConfigurationAdd the Snipe configuration entries used to locate the PAM translation catalogs for the greeter and lock screen.
TestsCover translated greeter errors across re-entry and lock-screen rendering of escaped line breaks.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
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>d8d6404 to
ac3b6c7
Compare
|
/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
ac3b6c7 to
7884a97
Compare
|
[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. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/forcemerge |
|
This pr force merged! (status: unstable) |
67d32f1
into
linuxdeepin:release/2500u2-pajil
Log: Localize errors when changing expired AD passwords.
Influence:
fix: 修复 AD 域用户过期改密提示的汉化缺口
Influence:
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:
Enhancements:
Tests: