Skip to content

feat(metadata): DACL <-> POSIX permission bit mapping (#2309) - #4361

Closed
oferchen wants to merge 1 commit into
masterfrom
feat/dacl-posix-mapping
Closed

oferchen wants to merge 1 commit into
masterfrom
feat/dacl-posix-mapping

Conversation

@oferchen

Copy link
Copy Markdown
Owner

Summary

  • Adds dacl_to_posix_mode(sddl) and posix_mode_to_dacl(mode, owner_sid, group_sid) to crates/metadata/src/acl_windows.rs, implementing the cross-platform translation matrix from docs/design/windows-ntfs-acl-support.md section 5 (WAS-4 / chore: update Homebrew formula for v0.5.3 #2309).
  • dacl_to_posix_mode parses the SDDL security descriptor, splits off the O: / G: / D: / S: sections, walks the DACL ACE list, and folds the first matching allow ACEs into a 9-bit rwxrwxrwx triplet. Owner SID -> owner bits, group SID -> group bits, WD (Everyone) -> other bits, with AU (Authenticated Users) as a documented fallback when no Everyone ACE is present.
  • posix_mode_to_dacl emits the canonical three-ACE form (owner, group, Everyone) with the P flag on the DACL header so parent inheritance cannot silently inject ACEs that were never on the source.
  • Lossy cases route through the existing warn_partial_apply once-only diagnostic, matching section 5.3 of the design doc: deny ACEs dropped, inherited (ID) ACEs dropped, non-rwx access bits collapsed, inheritance flags not transmitted.
  • lib.rs re-exports both new functions behind the existing #[cfg(all(feature = \"acl\", windows))] gate so crates/metadata consumers can use them without reaching into the private module.

Test plan

  • CI fmt + clippy across the workspace
  • Windows nextest exercises the new tests on windows-latest:
    • round_trip_mode_755_preserves_rwx_triplet
    • round_trip_full_mode_matrix_preserves_rwx (0o000..=0o777 round-trip)
    • posix_mode_to_dacl_uses_three_allow_aces_with_protected_flag
    • dacl_to_posix_mode_handles_everyone_as_other
    • dacl_to_posix_mode_falls_back_to_authenticated_users
    • dacl_to_posix_mode_drops_deny_aces
    • dacl_to_posix_mode_drops_inherited_aces
    • dacl_to_posix_mode_collapses_non_rwx_bits
    • sddl_rights_decode_two_letter_tokens / sddl_rights_decode_hex_mask
  • Linux/macOS CI compiles cleanly (module remains gated by cfg(all(feature = \"acl\", windows)))

Adds `dacl_to_posix_mode(sddl)` and `posix_mode_to_dacl(mode, owner_sid,
group_sid)` to `crates/metadata/src/acl_windows.rs`, implementing the
cross-platform translation matrix described in section 5 of
`docs/design/windows-ntfs-acl-support.md`.

- `dacl_to_posix_mode` parses an SDDL security descriptor string, locates
  the first allow ACE matching the owner SID, group SID, and Everyone
  (`WD`) trustee respectively, and folds their rights into a standard
  rwxrwxrwx mode triplet. Falls back to `AU` (Authenticated Users) for
  the other triplet when no explicit Everyone ACE is present.
- `posix_mode_to_dacl` emits the canonical three-ACE form with the
  `P` (protected) DACL flag so parent inheritance cannot silently inject
  ACEs not present on the source.
- Lossy cases (documented in section 5.3 of the design doc) are
  preserved as warnings via the existing `warn_partial_apply` channel:
  deny ACEs dropped, inherited (`ID`) ACEs dropped, non-rwx access bits
  collapsed.

Unit tests cover the canonical round trip across the full 0o000-0o777
mode matrix plus targeted assertions for deny ACE drop, inherited ACE
drop, Everyone vs Authenticated Users fallback, and the
`PROTECTED_DACL_SECURITY_INFORMATION` flag.
@github-actions github-actions Bot added the enhancement New feature or request label May 17, 2026
oferchen added a commit that referenced this pull request May 18, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
oferchen added a commit that referenced this pull request May 18, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
oferchen added a commit that referenced this pull request May 18, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
oferchen added a commit that referenced this pull request May 18, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
oferchen added a commit that referenced this pull request May 18, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
oferchen added a commit that referenced this pull request May 18, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
@oferchen

Copy link
Copy Markdown
Owner Author

Superseded by master's WAS-5 (#4388). Per PRC-3a audit (PR #4453), all 11 hunks are either already in master (7/11) or purely cosmetic comment additions (4/11). Master already ships dacl_to_posix_mode/posix_mode_to_dacl with full SDDL grammar, lib.rs re-exports, and identical test coverage including the 0o000..=0o777 round-trip matrix.

@oferchen oferchen closed this May 18, 2026
oferchen added a commit that referenced this pull request May 18, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
oferchen added a commit that referenced this pull request May 18, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
@oferchen
oferchen deleted the feat/dacl-posix-mapping branch May 19, 2026 15:13
oferchen added a commit that referenced this pull request Aug 24, 2026
Routes the `--acls` apply path through `acl_windows::read_dacl_sddl` /
`write_dacl_sddl` on Windows so DACL preservation rides the SDDL
fidelity payload from WAS-2/3 (#4354) instead of re-encoding only the
named ACEs. Cross-platform interop keeps the WAS-4 (#4361)
`dacl_to_posix_mode` and `posix_mode_to_dacl` helpers as the lossy
fall-back when one peer is POSIX.

Wire format reserves `user.win32.security_descriptor` (matches Samba's
NT-ACL slot on Linux backends) inside the existing xattr stream. The
sender appends an `XattrEntry` with the source's SDDL via
`metadata::sddl_xattr_entry`; the receiver consumes it in
`apply_xattrs_from_list`, dispatching to `write_dacl_sddl` on Windows
and silently dropping the slot on POSIX so the cross-platform rsync
ACL payload from `crates/protocol/src/acl/wire` still drives the
lowered POSIX bits. Local Windows-to-Windows `sync_acls` likewise
prefers the SDDL round-trip and falls back to the named-ACE encoder
only on volumes that refuse to serve a descriptor (FAT32, network
mounts).

Tests cover the new helpers on every platform and round-trip a custom
DACL through a Windows tempdir under `#[cfg(windows)]` so the new
dispatch shape is exercised end-to-end on `windows-latest` nextest.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant