mirror of https://github.com/raandree/NTFSSecurity
Browse Source
Enable-NTFSAuditInheritance, Disable-NTFSAuditInheritance, and Set-NTFSInheritance -AuditInheritanceEnabled failed with "(5) Access is denied" for a file or folder without a SACL, also elevated with the Security privilege. The cmdlets read only the audit section and changed the flag that disables or enables audit inheritance. AlphaFS writes that flag only together with a SACL, so it wrote no section at all, which Windows denies; the retry as owner repeated the same write. An empty SACL is now added first, but only to a descriptor that was read with its SACL. The elevated CI runs of #100 to #106 showed this through the test of an omitted -AccessInheritanceEnabled. From #104 on, the test that keeps the inherited entries of a security descriptor failed as well: elevated, Get-NTFSSecurityDescriptor reads the SACL, and Windows then returns a DACL that isn't in the auto-inherit format, such as that of a file in the temp folder of the user, without its inherited flags. The test now reads the access section only and checks that the descriptor has inherited entries. Tests: five cases for items without audit entries, red with "Access is denied" before the fix; the test that keeps the explicit audit entries now checks the errors and the inheritance state of both calls; a test checks that a descriptor read without its audit entries gets no SACL, which would replace the audit entries of the item when it is written. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: AI Assistant <ai@example.com>pull/106/head
3 changed files with 88 additions and 3 deletions
Loading…
Reference in new issue