file flags: fix generic set_flags, keep unprivileged flags on EPERM, warn on failure - #10104
Draft
ThomasWaldmann wants to merge 3 commits into
Draft
file flags: fix generic set_flags, keep unprivileged flags on EPERM, warn on failure#10104ThomasWaldmann wants to merge 3 commits into
ThomasWaldmann wants to merge 3 commits into
Conversation
…EPERM - platform.base.set_flags (used on NetBSD and generic POSIX) now also does the masked read-modify-write cycle instead of setting the archived value as-is, see borgbackup#9039. The flag masks are defined once in platform.base and shared by the freebsd/darwin implementations. - if setting the flags fails with EPERM (e.g. super-user-only SF_* flags while not running as root, or immutable/append-only on Linux without CAP_LINUX_IMMUTABLE), retry influencing only the unprivileged flags, so e.g. the nodump flag still gets restored, see borgbackup#1345. - macOS: tolerate EOPNOTSUPP like the other platforms already do. - linux: remove the unused FS_COMPR_FL declaration.
Previously, a failure to set the archived flags was silently ignored. Now it emits a warning and sets the warning exit code, like xattr errors already do.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #10104 +/- ##
==========================================
+ Coverage 87.01% 87.05% +0.04%
==========================================
Files 99 100 +1
Lines 17615 17684 +69
Branches 2664 2673 +9
==========================================
+ Hits 15327 15395 +68
Misses 1593 1593
- Partials 695 696 +1 ☔ View full report in Codecov by Harness. |
ThomasWaldmann
marked this pull request as draft
August 14, 2026 14:46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1345 (leftovers from the #9039 work).
platform.base.set_flags(used on NetBSD and generic POSIX) now also does the masked read-modify-write cycle instead of setting the archived value as-is. Before, a foreign flag bit made the wholelchflagscall fail (losing all flags for that item) and a succeeding call clobbered flags that are not settable from userspace. The flag masks are defined once inplatform.basenow and shared by the freebsd/darwin implementations.SF_*flags while not running as root, or immutable/append-only on Linux withoutCAP_LINUX_IMMUTABLE), retry influencing only the unprivileged flags, so e.g. the nodump flag still gets restored by an unprivilegedborg extract.set_flags: tolerate EOPNOTSUPP like the linux/freebsd implementations already do.FS_COMPR_FLdeclaration.lstat/lchflags, so they run on all platforms) and for the extract warning; docs section describing cross-platform behavior of file flags.This answers the two questions from #1345: the flag sets do differ per platform (borg archives BSD-style values, translating on Linux), and extracting an item with flags unsupported on the destination platform drops only those flags — per-flag via the masks, and now also per-flag for flags that merely lack privileges. Only when flags cannot be set at all are the item's flags skipped, with a warning now.
🤖 Generated with Claude Code