Skip to content

feat(metadata): implement Windows ACLs via GetSecurityInfo/SetSecurityInfo (#1866)#3533

Merged
oferchen merged 3 commits into
masterfrom
feat/windows-acls-1866
May 1, 2026
Merged

feat(metadata): implement Windows ACLs via GetSecurityInfo/SetSecurityInfo (#1866)#3533
oferchen merged 3 commits into
masterfrom
feat/windows-acls-1866

Conversation

@oferchen
Copy link
Copy Markdown
Owner

@oferchen oferchen commented May 1, 2026

Closes #1866.

Summary

  • Adds a real Windows ACL apply path under crates/metadata/src/acl_windows.rs that uses Win32 GetNamedSecurityInfoW / SetNamedSecurityInfoW to preserve NTFS DACLs when --acls/-A is in effect, replacing the prior acl_noop stub on Windows.
  • Reads and writes DACL_SECURITY_INFORMATION only; SACL preservation, inheritance flag round-tripping, and protected DACL bits are intentionally deferred (they require SE_SECURITY_NAME privilege and broader policy decisions).
  • SID/uid mapping mirrors upstream's lossy cross-platform convention (acls.c:902-928): senders resolve the account name with LookupAccountSidW and use the SID's lower sub-authority (RID) as the synthetic uid/gid; receivers look up the SID by account name with LookupAccountNameW and drop ACEs that cannot be mapped, emitting a one-shot warning so operators can audit lossy applications.
  • Wires into the existing acl module dispatch (get_rsync_acl, sync_acls, apply_acls_from_cache) via lib.rs cfg gating: cfg(all(feature = "acl", windows)) selects the new module, the acl_noop fallback is no longer chosen on Windows, and the windows crate dependency is target-gated so non-Windows builds are unchanged.

Audit findings

Test plan

  • cargo fmt --all -- --check
  • CI: fmt + clippy
  • CI: nextest (stable, Linux)
  • CI: nextest (stable, Windows) - exercises the new module under cfg(windows) and the gated read_dacl_on_temp_file_returns_dacl / sync_acls_round_trips_on_ntfs integration tests
  • CI: nextest (stable, macOS)
  • CI: Linux musl

Out of scope / follow-ups

  • Fix release workflow rustfmt installation #1869 - Windows ACL/xattr CI matrix (dedicated runner with NTFS DACL fixtures).
  • SACL preservation and inheritance flag round-tripping (requires SE_SECURITY_NAME privilege handling).
  • Per-file/per-dir SID cache to avoid redundant LookupAccountSidW calls on large transfers.

…yInfo (#1866)

Adds a real Windows ACL apply path that uses Win32
GetNamedSecurityInfoW/SetNamedSecurityInfoW so --acls/-A preserves NTFS
discretionary ACLs in cross-platform transfers. Replaces the prior
no-op stub which only emitted a warning on Windows.

The new module reads/writes DACL_SECURITY_INFORMATION only (SACL is
deliberately left as follow-up to avoid SE_SECURITY_NAME privilege
requirements). SID/uid mapping follows upstream's lossy
cross-platform convention: senders encode the resolved account name
and use the SID's lower sub-authority (RID) as the synthetic
uid/gid; receivers look up the SID by account name and drop ACEs
that cannot be mapped, mirroring acls.c:902-928.

Wires into the existing acl module dispatch via lib.rs cfg gating so
non-Windows builds remain unchanged.
@github-actions github-actions Bot added the enhancement New feature or request label May 1, 2026
oferchen added 2 commits May 1, 2026 22:55
Adds the windows crate to the metadata Cargo.lock entry to match the
target-gated dependency added in the parent commit. Without this,
cargo --locked (used by MSRV and fmt+clippy CI checks) fails with
"the lock file needs to be updated but --locked was passed".
@oferchen oferchen merged commit 9da533d into master May 1, 2026
37 of 41 checks passed
@oferchen oferchen deleted the feat/windows-acls-1866 branch May 1, 2026 21:08
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