mirror of
https://github.com/restic/restic.git
synced 2025-12-08 06:09:56 +00:00
* Fix: Correctly restore ACL inheritance state When restoring a file or directory on Windows, the `IsInherited` property of its Access Control Entries (ACEs) was always being set to `False`, even if the ACEs were inherited in the original backup. This was caused by the restore process calling the `SetNamedSecurityInfo` API without providing context about the object's inheritance policy. By default, this API applies the provided Discretionary Access Control List (DACL) as an explicit set of permissions, thereby losing the original inheritance state. This commit fixes the issue by inspecting the `Control` flags of the saved Security Descriptor during restore. Based on whether the `SE_DACL_PROTECTED` flag is present, the code now adds the appropriate `PROTECTED_DACL_SECURITY_INFORMATION` or `UNPROTECTED_DACL_SECURITY_INFORMATION` flag to the `SetNamedSecurityInfo` API call. By providing this crucial inheritance context, the Windows API can now correctly reconstruct the ACL, ensuring the `IsInherited` status of each ACE is preserved as it was at the time of backup. * Fix: Correctly restore ACL inheritance flags This commit resolves an issue where the ACL inheritance state (`IsInherited` property) was not being correctly restored for files and directories on Windows. The root cause was that the `SECURITY_INFORMATION` flags used in the `SetNamedSecurityInfo` API call contained both the `PROTECTED_DACL_SECURITY_INFORMATION` and `UNPROTECTED_DACL_SECURITY_INFORMATION` flags simultaneously. When faced with this conflicting information, the Windows API defaulted to the more restrictive `PROTECTED` behavior, incorrectly disabling inheritance on restored items. The fix modifies the `setNamedSecurityInfoHigh` function to first clear all existing inheritance-related flags from the `securityInfo` bitmask. It then adds the single, correct flag (`PROTECTED` or `UNPROTECTED`) based on the `SE_DACL_PROTECTED` control bit from the original, saved Security Descriptor. This ensures that the API receives unambiguous instructions, allowing it to correctly preserve the inheritance state as it was at the time of backup. The accompanying test case for ACL inheritance now passes with this change. * Fix inheritance flag handling in low-privilege security descriptor restore When restoring files without admin privileges, the IsInherited property of Access Control Entries (ACEs) was not being preserved correctly. The low-privilege restore path (setNamedSecurityInfoLow) was using a static PROTECTED_DACL_SECURITY_INFORMATION flag, which always marked the restored DACL as explicitly set rather than inherited. This commit updates setNamedSecurityInfoLow to dynamically determine the correct inheritance flag based on the SE_DACL_PROTECTED control flag from the original security descriptor, matching the behavior of the high-privilege path (setNamedSecurityInfoHigh). Changes: - Update setNamedSecurityInfoLow to accept control flags parameter - Add logic to set either PROTECTED_DACL_SECURITY_INFORMATION or UNPROTECTED_DACL_SECURITY_INFORMATION based on the original SD - Add TestRestoreSecurityDescriptorInheritanceLowPrivilege to verify inheritance is correctly restored in low-privilege scenarios This ensures that both admin and non-admin restore operations correctly preserve the inheritance state of ACLs, maintaining the original permissions flow on child objects. Addresses review feedback on PR for issue #5427 * Refactor security flags into separate backup/restore variants Split highSecurityFlags into highBackupSecurityFlags and highRestoreSecurityFlags to avoid runtime bitwise operations. This makes the code cleaner and more maintainable by using appropriate flags for GET vs SET operations. Addresses review feedback on PR for issue #5427 --------- Co-authored-by: Aneesh Nireshwalia <anireshw@akamai.com> |
||
|---|---|---|
| .. | ||
| 0.6.0_2017-05-29 | ||
| 0.6.1_2017-06-01 | ||
| 0.7.0_2017-07-01 | ||
| 0.7.1_2017-07-22 | ||
| 0.7.2_2017-09-13 | ||
| 0.7.3_2017-09-20 | ||
| 0.8.0_2017-11-26 | ||
| 0.8.1_2017-12-27 | ||
| 0.8.2_2018-02-17 | ||
| 0.8.3_2018-02-26 | ||
| 0.9.0_2018-05-21 | ||
| 0.9.1_2018-06-10 | ||
| 0.9.2_2018-08-06 | ||
| 0.9.3_2018-10-13 | ||
| 0.9.4_2019-01-06 | ||
| 0.9.5_2019-04-23 | ||
| 0.9.6_2019-11-22 | ||
| 0.10.0_2020-09-19 | ||
| 0.11.0_2020-11-05 | ||
| 0.12.0_2021-02-14 | ||
| 0.12.1_2021-08-03 | ||
| 0.13.0_2022-03-26 | ||
| 0.14.0_2022-08-25 | ||
| 0.15.0_2023-01-12 | ||
| 0.15.1_2023-01-30 | ||
| 0.15.2_2023-04-24 | ||
| 0.16.0_2023-07-31 | ||
| 0.16.1_2023-10-24 | ||
| 0.16.2_2023-10-29 | ||
| 0.16.3_2024-01-14 | ||
| 0.16.4_2024-02-04 | ||
| 0.16.5_2024-07-01 | ||
| 0.17.0_2024-07-26 | ||
| 0.17.1_2024-09-05 | ||
| 0.17.2_2024-10-27 | ||
| 0.17.3_2024-11-08 | ||
| 0.18.0_2025-03-27 | ||
| 0.18.1_2025-09-21 | ||
| unreleased | ||
| changelog-github.tmpl | ||
| CHANGELOG.tmpl | ||
| TEMPLATE | ||