Skip to content

Add shadow.verify_password for Windows and wire into user.present#69142

Merged
dwoz merged 1 commit into
saltstack:3008.xfrom
twangboy:fix/41347/3008.x
May 14, 2026
Merged

Add shadow.verify_password for Windows and wire into user.present#69142
dwoz merged 1 commit into
saltstack:3008.xfrom
twangboy:fix/41347/3008.x

Conversation

@twangboy
Copy link
Copy Markdown
Contributor

What does this PR do?

Add verify_password to salt.modules.win_shadow, which validates a Windows user's password using LogonUser with LOGON32_LOGON_NETWORK (Microsoft's recommended approach per KB180548). A wrong password that causes an account lockout is automatically undone if the account was not already locked before the call.
Update the Windows _changes() path in salt.states.user to call shadow.verify_password so that user.present only sets the password when it actually differs, matching the idempotent behaviour on Linux/macOS. Also fix ret.changes to include passwd: XXX-REDACTED-XXX on Windows after a password change, since shadow.info always returns "Unavailable" and the normal diff comparison cannot detect the change. Add unit tests covering all LogonUser error-code branches, functional tests for correct/wrong/lockout password scenarios, and three user.present state tests for same-password idempotency, test-mode pending change, and actual password change reporting. Closes #41347

What issues does this PR fix or reference?

Fixes #41347

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Add verify_password to salt.modules.win_shadow, which validates a
Windows user's password using LogonUser with LOGON32_LOGON_NETWORK
(Microsoft's recommended approach per KB180548). A wrong password that
causes an account lockout is automatically undone if the account was
not already locked before the call.
Update the Windows _changes() path in salt.states.user to call
shadow.verify_password so that user.present only sets the password when
it actually differs, matching the idempotent behaviour on Linux/macOS.
Also fix ret.changes to include passwd: XXX-REDACTED-XXX on Windows
after a password change, since shadow.info always returns "Unavailable"
and the normal diff comparison cannot detect the change.
Add unit tests covering all LogonUser error-code branches, functional
tests for correct/wrong/lockout password scenarios, and three
user.present state tests for same-password idempotency, test-mode
pending change, and actual password change reporting.
Closes saltstack#41347
@dwoz dwoz merged commit 08f2fad into saltstack:3008.x May 14, 2026
2281 of 2290 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants