Skip to content

Add PutOptions.AttemptUnpackDockerCompatibility - #7010

Open
ajoshua2004 wants to merge 1 commit into
podman-container-tools:mainfrom
ajoshua2004:unpackDocker
Open

Add PutOptions.AttemptUnpackDockerCompatibility#7010
ajoshua2004 wants to merge 1 commit into
podman-container-tools:mainfrom
ajoshua2004:unpackDocker

Conversation

@ajoshua2004

Copy link
Copy Markdown
Contributor

What type of PR is this?

/kind api-change

What this PR does / why we need it:

Adds AttemptUnpackDockerCompatibility (bool) to copier.PutOptions. When enabled, the Put handler detects if a written regular file is a possibly-compressed archive (gzip/bzip2/xz/zstd) and extracts its contents in place instead of keeping the archive as-is.

How to verify it

go test ./copier/ -run TestAttemptUnpackDockerCompatibilityNoChroot -v
go test ./copier/ -run TestAttemptUnpackDockerCompatibilityChroot -v

Which issue(s) this PR fixes:

Part of #6732

Special notes for your reviewer:

The detection reuses the existing isArchivePath() and compression.AutoDecompress() infrastructure already used on the Get side for ExpandArchives. The flag is not wired to any caller yet, it's available on PutOptions for callers to opt into when needed.

Does this PR introduce a user-facing change?

None

Comment thread copier/copier.go Outdated
f.Close()
return fmt.Errorf("copier: put: error reading unpacked archive %q: %w", path, err)
}
entryPath := filepath.Join(destDir, entry.Name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nalind is this safe? Could it write outside of it's destination?

Detect if written files are possibly compressed archives during Put and extract them
instead of copying them when the flag is set.

Signed-off-by: Joshua Arrevillaga <2004jarrevillaga@gmail.com>
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.

2 participants