Add shadow.verify_password for Windows and wire into user.present#69142
Merged
Conversation
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
d4f33ba to
1aaa471
Compare
dwoz
approved these changes
May 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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