Preserve dir mode and ownership in RUN --mount - #6981
Conversation
bc63624 to
3908788
Compare
Fixes: podman-container-tools#6747 Fixes: podman-container-tools/podman#27777 Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
|
Initially, the layer pull-ups were always excluded. This led to default directory permissions being used when a child entry survived the filter, because the tar extractor recreated the missing parent directories with root ownership. I started with this fix simonbrauner@b3ca65c which, as a contrast, included all the layer pull-ups. But that caused this test to fail ff07ebc. The final solution defers pull-up entries in the tar filter and only emits them when a child entry actually passes through. Parents with no surviving children are discarded at EOF, keeping layers minimal while preserving correct ownership. |
|
PTAL @podman-container-tools/buildah-maintainers @podman-container-tools/buildah-reviewers |
|
/packit rebuild-failed |
| if pullUpSpec.Mode != nil { | ||
| hdr.Mode = int64(*pullUpSpec.Mode & os.ModePerm) | ||
| } | ||
| return tarFilterDefer, false, nil |
There was a problem hiding this comment.
| return tarFilterDefer, false, nil | |
| // Fall through so timestamp/Windows transforms apply | |
| // before the deferred header is copied for later emit. | |
| action = tarFilterDefer |
| } | ||
| } | ||
| return false, false, nil | ||
| return tarFilterKeep, false, nil |
There was a problem hiding this comment.
| return tarFilterKeep, false, nil | |
| return action, false, nil |
| var initialized bool | ||
| wc = newTarFilterer(wc, func(hdr *tar.Header) (skip, replaceContents bool, replacementContents io.Reader) { | ||
| wc = newTarFilterer(wc, func(hdr *tar.Header) (action tarFilterAction, replaceContents bool, replacementContents io.Reader) { | ||
| modTime := hdr.ModTime |
There was a problem hiding this comment.
| modTime := hdr.ModTime | |
| action = tarFilterKeep | |
| modTime := hdr.ModTime |
|
My AI reviewer suggested handling windows a bit better. I think it looks good, but if @nalind says no, ignore the suggestions. Otherwise LGTM. |
What type of PR is this?
/kind bug
What this PR does / why we need it:
How to verify it
Which issue(s) this PR fixes:
Fixes: #6747
Fixes: podman-container-tools/podman#27777
Special notes for your reviewer:
Does this PR introduce a user-facing change?