restic/changelog
Aneesh N b9afdf795e
Fix: Correctly restore ACL inheritance state (#5465)
* 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>
2025-11-28 19:22:47 +00:00
..
0.6.0_2017-05-29 Update changelog/ for new version of calens 2018-02-16 23:05:58 +01:00
0.6.1_2017-06-01 Update changelog/ for new version of calens 2018-02-16 23:05:58 +01:00
0.7.0_2017-07-01 Update changelog/ for new version of calens 2018-02-16 23:05:58 +01:00
0.7.1_2017-07-22 Fix typo in changelog 2021-08-21 12:16:04 +02:00
0.7.2_2017-09-13 Update changelog/ for new version of calens 2018-02-16 23:05:58 +01:00
0.7.3_2017-09-20 Update changelog/ for new version of calens 2018-02-16 23:05:58 +01:00
0.8.0_2017-11-26 Fix typos 2023-12-06 13:11:55 +01:00
0.8.1_2017-12-27 Update changelog/ for new version of calens 2018-02-16 23:05:58 +01:00
0.8.2_2018-02-17 Move changelog typo fixes to changelog files 2023-12-23 14:05:47 +01:00
0.8.3_2018-02-26 Fix typos 2023-12-06 13:11:55 +01:00
0.9.0_2018-05-21 Fix typos 2023-12-06 13:11:55 +01:00
0.9.1_2018-06-10 Fix changelog entry 2018-06-10 11:29:57 +02:00
0.9.2_2018-08-06 Create changelog/ release subdir for 0.9.2 2018-08-06 21:28:16 +02:00
0.9.3_2018-10-13 Fix typos 2023-12-06 13:11:55 +01:00
0.9.4_2019-01-06 Create changelog dir for 0.9.4 2019-01-06 21:39:56 +01:00
0.9.5_2019-04-23 Move changelog entry for #2179 2019-11-24 15:15:19 +01:00
0.9.6_2019-11-22 Fix typos 2023-12-06 13:11:55 +01:00
0.10.0_2020-09-19 fix some typos 2024-03-11 14:35:12 +08:00
0.11.0_2020-11-05 Move changelog typo fixes to changelog files 2023-12-23 14:05:47 +01:00
0.12.0_2021-02-14 replace all uses of target in relation to backup 2024-07-24 19:40:53 +02:00
0.12.1_2021-08-03 Prepare changelog for 0.12.1 2021-08-03 11:45:19 +02:00
0.13.0_2022-03-26 Prepare changelog for 0.13.0 2022-03-26 20:09:39 +01:00
0.14.0_2022-08-25 doc: Correct two typos 2023-10-27 19:48:00 +02:00
0.15.0_2023-01-12 Prepare changelog for 0.15.0 2023-01-12 20:50:44 +01:00
0.15.1_2023-01-30 Prepare changelog for 0.15.1 2023-01-30 20:43:15 +01:00
0.15.2_2023-04-24 Prepare changelog for 0.15.2 2023-04-24 20:28:24 +02:00
0.16.0_2023-07-31 replace all uses of target in relation to backup 2024-07-24 19:40:53 +02:00
0.16.1_2023-10-24 Prepare changelog for 0.16.1 2023-10-24 20:02:29 +02:00
0.16.2_2023-10-29 Prepare changelog for 0.16.2 2023-10-29 19:50:04 +01:00
0.16.3_2024-01-14 Prepare changelog for 0.16.3 2024-01-14 20:21:19 +01:00
0.16.4_2024-02-04 Prepare changelog for 0.16.4 2024-02-04 19:50:34 +01:00
0.16.5_2024-07-01 Prepare changelog for 0.16.5 2024-07-01 21:25:33 +02:00
0.17.0_2024-07-26 Prepare changelog for 0.17.0 2024-07-26 11:28:55 +02:00
0.17.1_2024-09-05 Prepare changelog for 0.17.1 2024-09-05 21:25:19 +02:00
0.17.2_2024-10-27 Prepare changelog for 0.17.2 2024-10-27 16:37:08 +01:00
0.17.3_2024-11-08 Prepare changelog for 0.17.3 2024-11-08 20:36:25 +01:00
0.18.0_2025-03-27 Fix release note typos 2025-09-06 21:59:11 +02:00
0.18.1_2025-09-21 Prepare changelog for 0.18.1 2025-09-21 20:03:56 +02:00
unreleased Fix: Correctly restore ACL inheritance state (#5465) 2025-11-28 19:22:47 +00:00
changelog-github.tmpl Fix indentation of blockquotes in github release notes 2024-10-18 21:47:59 +02:00
CHANGELOG.tmpl cleanup changelog whitespace 2024-01-08 21:33:05 +01:00
TEMPLATE Changelogs should omit problem if it duplicates the new behavior 2024-09-14 20:54:27 +02:00