Skip to content

fix(linux): copy xattrs before applying read-only modes - #55

Open
RaphaelFakhri wants to merge 1 commit into
anomalyco:devfrom
RaphaelFakhri:fix/linux-readonly-xattr-copy
Open

RaphaelFakhri wants to merge 1 commit into
anomalyco:devfrom
RaphaelFakhri:fix/linux-readonly-xattr-copy

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Summary

copy_metadata_linux applied the source mode before copying extended attributes. Linux setxattr on a user.* attribute needs write access, so a read-only file (0444) or directory (0555) that carries one made rift create fail with Permission denied (os error 13) on reflink filesystems. The btrfs strategy uses the same helper for filtered imports.

This change copies extended attributes before setting the mode, matching the order the APFS strategy already uses since #21.

Changes

  • crates/core/src/strategy/reflink.rs: call copy_xattrs_linux before fs::set_permissions in copy_metadata_linux.
  • Add native_copy_preserves_xattrs_on_read_only_entries, which copies a 0444 file and a 0555 directory that both carry user.* attributes and checks the modes and attributes on the copy.

Verification

On XFS with reflink, as a non-root user:

  • RIFT_REQUIRE_REFLINK_TESTS=1 cargo test -p rift --locked --lib strategy::reflink: the new test fails without the fix (Io(Os { code: 13, kind: PermissionDenied })) and passes with it (6 passed).
  • cargo test --workspace --locked: all tests pass.
  • cargo fmt --all -- --check: clean. cargo clippy reports no new warnings.
  • The reproduction from the linked issue now creates the workspace, and the copy keeps mode 444 and the user.origin attribute.

Fixes #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create fails with "Permission denied (os error 13)" on Linux for read-only entries that carry xattrs

1 participant