Refuse profile names that collide with reserved subvolumes - #2
Open
munzzyy wants to merge 1 commit into
Open
Conversation
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.
The on-device profile tooling refuses reserved subvolume names.
is_reserved_subvol()in flipperone-linux-build-scripts (overlays/usr/lib/flipper-btrfs.sh) lists them:and
create-profile,rename-profileanddelete-profileall bail out with "Refusing to use reserved name". The installer creates those same subvolumes and has no equivalent check —grep -rn "reserved" src/corefinds nothing.So a profile pack named
stock-snapshots(orhome, orvar-log) parses like any other profile and is accepted all the way todeploy_profile, which runs:{mnt}/@stock-snapshotsalready exists by then —run()mkdir's it before the first receive. When the destination is an existing directory, btrfs doesn't error, it names the new subvolume after the basename of the source and puts it inside. That leaves a subvolume stranded one level down in a shared area, whichbtrfs subvolume deletewon't remove since it isn't recursive. For a profile calledhomethe same thing happens inside the user's populated/home.Added
reject_reserved_profile_name(), called for the minimal profile and every selected extra right after the layout resolves and beforeblkdiscard, so it fails while the disk is still untouched. It checks the same list as the shell helper, plus whatever the active layout defines, so the two stay in step.Two tests come with it. The first builds a
ProfilePackfrom the realparse_pack("stock-snapshots_694_stock_pack.zst")and assertsroot_subvol()equalsSTOCK_SNAPSHOTS_DIR— the collision is real on unmodified parsing, not something the test invents. The second checks every reserved name is refused and that ordinary names likeMinimalandDesktopstill pass.parse_packbecamepub(crate)so the first test can call it; nothing else changed incatalog.rs. Clippy is unchanged at the same 5 pre-existing warnings, none ininstall.rs.Two caveats. This needs a build that actually ships an oddly named pack, so it's a guard rather than something biting today — I'd rather it match the shell tooling than rely on nobody ever naming a profile
home. And I confirmed the btrfs nesting behaviour frombtrfs-subvolume(8)rather than on a real filesystem, since I wasn't going to runmkfsto test it.