Repository navigation
Conversation
The "mode" of a copy path was parsed and validated but never handed to the extraction, so a copied file or directory always kept the mode from the tarball. Generated content (text, make, symlink) did honour it. The mode is now passed along with the extraction request. A mode on a path that a glob of the same package also matches is a diverging mode for the tarball extraction and fails the cut, as the tarball package already specifies.
There was a problem hiding this comment.
🟡 Changes recommended
Hard-link modes and per-destination mode handling still have unresolved issues.
2 open findings
What changed in this PR
Fixes listed modes for copied files and directories during extraction.
Changes:
- Propagates listed modes to tarball extraction.
- Adds regression tests for mode application and conflicting glob matches.
| File | Summary |
|---|---|
internal/slicer/slicer.go |
Passes listed modes to tarball extraction. |
internal/slicer/slicer_test.go |
Adds mode and conflict regression tests. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
The tar header mode set for one destination of a source leaked into the next destination of the same source, so a destination without a listed mode could take another one. Each destination now starts from the mode in the tarball. A hard link extracted on its own takes its listed mode; one created against its target shares the inode, so a mode of its own is an error.
| if mode != 0 { | ||
| return fmt.Errorf("path %s is a hard link and cannot have its own mode 0%03o", link.path, mode) | ||
| } |
A hard link with a listed mode shares the inode of its target when the modes agree, special bits included, and is otherwise extracted as a file of its own with that mode. Pending links to the same target are grouped by listed mode the same way instead of erroring, and the second pass creates missing parent directories as the first one does.
|
@lczyk as stated in the docs, this |
|
@upils hmmm.. if "permission bits for any path chisel creates ... can only be used with copy, make and text" then chisel should enforce that. having said that, i've checked chisel-releases and atm there is a use for this: @zhijie-yang looping you in since its about 🐰 |
|
Isn't the deb doing something wrong here? What it could do instead is:
This may be a bit late to change these packages though... But I think this is an abuse of a bug we missed. I think we should push for packages to behave as best as they can and only tweak as few things as we can in chisel-releases. I know this is not possible in all cases and mutation scripts are here to bridge the gap, but the feature set is limited on purpose. |

did some formal verification (fizzbee, my specs are here and here) of the
cutpath and found 7 minor bugs:preferignores x-arch paths #330mutable: true, until: mutate#331until: mutate#333cut the following slice:
the listed
modeis parsed and validated but never reaches the extraction, so copied files and directories keep the mode from the deb.text,makeandsymlinkentries do honour it.rabbitmq-serverlists two such entries on every chisel-releases branch since 22.04. ( <- @zhijie-yang fyi, since you're the rabbit expert )repro using
chisel-proxy:with the fix both print
600.fix
the mode is passed along in the extraction request. a hard link with a listed mode shares its target's inode when the modes agree and is otherwise extracted as a file of its own with that mode; pending links to the same target are grouped by mode the same way. a mode listed for one destination of a source no longer leaks into another destination of the same source. one consequence: a
modeon a path that a glob of the same package also matches now fails the cut withrequested twice with diverging mode(the extraction's existing contract, pinned by its "Entries for same destination must have the same mode" test); pinned here in a slicer case rather than relaxed. no slice on anyubuntu-*branch has that overlap.