win_lgpo: read/write advanced audit policy via advapi32, not auditpol.exe#68935
Merged
dwoz merged 6 commits intosaltstack:3006.xfrom Apr 23, 2026
Merged
win_lgpo: read/write advanced audit policy via advapi32, not auditpol.exe#68935dwoz merged 6 commits intosaltstack:3006.xfrom
dwoz merged 6 commits intosaltstack:3006.xfrom
Conversation
593a6fd to
c3a7eff
Compare
b31d4b8 to
8eb8ea4
Compare
Read auditpol /backup output with locale.getencoding() (Python 3.11+) or mbcs fallback so CSV is decoded with the system ANSI encoding instead of fopen's default UTF-8. Prevents UnicodeDecodeError when lgpo.get runs on non-English Windows (e.g. German). Fixes saltstack#68354
….exe Replace locale-dependent parsing of auditpol.exe output with ctypes calls to advapi32 (AuditQuerySystemPolicy, AuditSetSystemPolicy, AuditFree). Enable SeSecurityPrivilege only while applying changes. Keep a static GUID-to-English subcategory map in win_lgpo_auditpol; expose bitmask settings and get_advaudit_policy_rows() for structured consumers. win_lgpo._get_advaudit_defaults now uses those rows instead of CSV from get_auditpol_dump; get_auditpol_dump remains a UTF-8 CSV serializer for compatibility. Bindings on the lazy API object use PascalCase to match Win32 exports. Update win_auditpol messaging and LGPO unit test mocks.
dwoz
approved these changes
Apr 23, 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?
Read auditpol /backup output with locale.getencoding() (Python 3.11+) or mbcs fallback so CSV is decoded with the system ANSI encoding instead of fopen's default UTF-8. Prevents UnicodeDecodeError when lgpo.get runs on non-English Windows (e.g. German).
What issues does this PR fix or reference?
Fixes #68354
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes