Ownership: --numeric-ids enables chown under any metadata flag; directory ownership/xattrs/ACLs not applied #286

Closed
opened 2026-09-15 19:33:33 +02:00 by TapTap · 1 comment
Owner

Audit findings (protocol 2.22.0).

  1. --numeric-ids unexpectedly activates ownership. identity_active_enabled() and the owner/group-requested predicates include numeric_ids (src/shared/identity.c), so -t --numeric-ids / -U --numeric-ids (any metadata flag) fchown destinations to raw source ids. rsync's --numeric-ids is a mapping modifier only. Contradicts the RSYNC_COMPAT.md row claiming it is inert without an ownership option.
    Fix: remove numeric_ids from identity_active_enabled; keep it as a mapping branch inside identity_resolve_targets when -o/-g/maps request ownership. Add a regression test.

  2. Directory ownership is dropped on the recursive path. Recursively scanned dirs are created implicitly (src/shared/file.c file_open_secure_parent/file_ensure_directory_secure, which chown only for --copy-as), and dir_metadata_list_apply applies only times+mode, never owner/group (src/shared/file_receive.c). So -a/-o/-g do not reproduce directory owner/group (only --copy-as does).
    Fix: chown dirs in dir_metadata_list_apply via identity_apply_ownership_link, and/or apply the policy to implicitly created parents.

  3. Directory (and symlink) xattrs/ACLs are not preserved: the scanner captures xattrs only for regular files and the receiver applies them only for files, so -aX/-aA lose dir xattrs and default ACLs.
    Fix: capture dir xattrs on the dir entry and apply them fd-relative in dir_metadata_list_apply; add a directory ACL/xattr test.

Audit findings (protocol 2.22.0). 1) `--numeric-ids` unexpectedly activates ownership. `identity_active_enabled()` and the owner/group-requested predicates include `numeric_ids` (`src/shared/identity.c`), so `-t --numeric-ids` / `-U --numeric-ids` (any metadata flag) fchown destinations to raw source ids. rsync's `--numeric-ids` is a mapping modifier only. Contradicts the RSYNC_COMPAT.md row claiming it is inert without an ownership option. Fix: remove `numeric_ids` from `identity_active_enabled`; keep it as a mapping branch inside `identity_resolve_targets` when `-o`/`-g`/maps request ownership. Add a regression test. 2) Directory ownership is dropped on the recursive path. Recursively scanned dirs are created implicitly (`src/shared/file.c` `file_open_secure_parent`/`file_ensure_directory_secure`, which chown only for `--copy-as`), and `dir_metadata_list_apply` applies only times+mode, never owner/group (`src/shared/file_receive.c`). So `-a`/`-o`/`-g` do not reproduce directory owner/group (only `--copy-as` does). Fix: chown dirs in `dir_metadata_list_apply` via `identity_apply_ownership_link`, and/or apply the policy to implicitly created parents. 3) Directory (and symlink) xattrs/ACLs are not preserved: the scanner captures xattrs only for regular files and the receiver applies them only for files, so `-aX`/`-aA` lose dir xattrs and default ACLs. Fix: capture dir xattrs on the dir entry and apply them fd-relative in `dir_metadata_list_apply`; add a directory ACL/xattr test.
TapTap added the needs-triage label 2026-09-15 19:33:33 +02:00
Author
Owner

Fixed. (1) --numeric-ids no longer activates ownership — it is only a mapping modifier (identity_active_enabled excludes it), with a regression test. (2) Directory owner/group is applied via the deferred DirTimeList (dir_metadata_list_apply) and explicit --dirs entries. (3) Directory xattrs/ACLs are captured/sent/applied for the recursive path, and PR #308 applies them on the direct --dirs save path too. Residual: symlink xattrs/ACLs are not captured/applied (documented in RSYNC_COMPAT.md); closing it needs a dedicated symlink-xattr wire block and a PROTOCOL_VERSION bump. Closing as completed.

Fixed. (1) `--numeric-ids` no longer activates ownership — it is only a mapping modifier (`identity_active_enabled` excludes it), with a regression test. (2) Directory owner/group is applied via the deferred `DirTimeList` (`dir_metadata_list_apply`) and explicit `--dirs` entries. (3) Directory xattrs/ACLs are captured/sent/applied for the recursive path, and PR #308 applies them on the direct `--dirs` save path too. Residual: symlink xattrs/ACLs are not captured/applied (documented in `RSYNC_COMPAT.md`); closing it needs a dedicated symlink-xattr wire block and a `PROTOCOL_VERSION` bump. Closing as completed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#286