Skip to content

fix(backup): keep readable xattrs and report incomplete metadata - #661

Open
akatsukiwork0320 wants to merge 1 commit into
rustic-rs:mainfrom
akatsukiwork0320:fix/596-readable-xattrs
Open

akatsukiwork0320 wants to merge 1 commit into
rustic-rs:mainfrom
akatsukiwork0320:fix/596-readable-xattrs

Conversation

@akatsukiwork0320

Copy link
Copy Markdown

Closes #596

A failed extended-attribute read currently discards every attribute already collected for the entry. The file can still be restored, but the caller sees zero source errors. This patch keeps the file and each readable attribute, continues past failed value reads, and reports the first error for each affected entry through the existing progress callback and snapshot summary.

If listing attributes returns Unsupported, the entry contributes zero errors. This preserves backups from mounts without xattr support, as intended by #233. Once a name has been listed, a failure to read its value counts as incomplete metadata, including when that read returns Unsupported.

Previously, if an attribute disappeared between listing and reading, the snapshot kept its name with no value. The patch omits that name without counting an error. An attribute that is present with a zero-length value is still saved.

Verification

On Linux, the test backed up mode 0644 files from a read-only FUSE mount and restored them to a fresh directory as an ordinary user. The counts below come from the backup return value and a separate lookup of the saved snapshot by ID. The three named attributes, in order, were alpha, beta and gamma in the user.rustic_ namespace.

Source behavior Restored file contents Restored test attributes Error count returned / reloaded
Listing returns EOPNOTSUPP for four files and one directory All four files match None 0 / 0
Listed value beta returns EACCES Match alpha, gamma 1 / 1
Listed value beta returns EOPNOTSUPP Match alpha, gamma 1 / 1
Listed values beta and gamma both return EACCES Match alpha 1 / 1

The readable attribute values matched in the saved snapshot and at the 0644 destination. In a separate 0444 case, the snapshot contained both readable values and the restored file contents matched. The unprivileged restore left both attributes absent, and a direct user.* write on that destination returned EACCES.

On Linux with Rust 1.99.0, the patched tree at bf1de63 passed all 325 core tests. The workspace run with all targets and features passed 365 tests. Formatting, spelling, Clippy with -D warnings and the workspace documentation build also passed. The macOS and Windows runs below used Rust 1.100.0.

On macOS 26.7.2 (arm64, APFS), all 365 workspace tests passed and the documentation built successfully. With the original chmod +a "everyone deny readextattr" f from #596, both listing the attributes and reading com.example.k directly returned EACCES. The restored file matched the original bytes, the attribute was absent, and the returned and reloaded summaries both recorded one error. In the earlier macOS 15.8.2 comparison on the same base, upstream restored the file with 0/0 and the #613 mapper omitted it with 1/1. Earlier proposal #613

On Windows Server 2025 (x86-64), all 288 workspace tests passed and the documentation built successfully. A separate backup and restore of an ordinary binary file reproduced its bytes exactly. The backup return value and the snapshot reloaded by ID both reported zero errors. This Windows check covered ordinary file contents only.

AI tools assisted with the patch, test execution and PR text.

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.

Backup silently drops extended attributes it cannot read

1 participant