diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2021-07-01 13:15:00 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-01 13:15:00 -0400 |
commit | 955c1d2bfeac0c399bbc4d82fd7b72ed4cc868d3 (patch) | |
tree | 1758a6acf60589fa13ae95dd39e3a0e1ddc78c13 /libpod/container_copy_linux.go | |
parent | a855b30f81cc72e67fc40b7301b98124ab0e6d01 (diff) | |
parent | 86c6014145d5b8d4ea51f338beb9bddaa8b5a334 (diff) | |
download | podman-955c1d2bfeac0c399bbc4d82fd7b72ed4cc868d3.tar.gz podman-955c1d2bfeac0c399bbc4d82fd7b72ed4cc868d3.tar.bz2 podman-955c1d2bfeac0c399bbc4d82fd7b72ed4cc868d3.zip |
Merge pull request #10804 from matejvasek/fix-cp-sub-cmd
Implement --archive flag for podman cp
Diffstat (limited to 'libpod/container_copy_linux.go')
-rw-r--r-- | libpod/container_copy_linux.go | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/libpod/container_copy_linux.go b/libpod/container_copy_linux.go index 0ab322829..01e7ecacb 100644 --- a/libpod/container_copy_linux.go +++ b/libpod/container_copy_linux.go @@ -23,7 +23,7 @@ import ( "golang.org/x/sys/unix" ) -func (c *Container) copyFromArchive(ctx context.Context, path string, reader io.Reader) (func() error, error) { +func (c *Container) copyFromArchive(ctx context.Context, path string, chown bool, reader io.Reader) (func() error, error) { var ( mountPoint string resolvedRoot string @@ -62,13 +62,16 @@ func (c *Container) copyFromArchive(ctx context.Context, path string, reader io. } } - // Make sure we chown the files to the container's main user and group ID. - user, err := getContainerUser(c, mountPoint) - if err != nil { - unmount() - return nil, err + var idPair *idtools.IDPair + if chown { + // Make sure we chown the files to the container's main user and group ID. + user, err := getContainerUser(c, mountPoint) + if err != nil { + unmount() + return nil, err + } + idPair = &idtools.IDPair{UID: int(user.UID), GID: int(user.GID)} } - idPair := idtools.IDPair{UID: int(user.UID), GID: int(user.GID)} decompressed, err := archive.DecompressStream(reader) if err != nil { @@ -84,8 +87,8 @@ func (c *Container) copyFromArchive(ctx context.Context, path string, reader io. putOptions := buildahCopiah.PutOptions{ UIDMap: c.config.IDMappings.UIDMap, GIDMap: c.config.IDMappings.GIDMap, - ChownDirs: &idPair, - ChownFiles: &idPair, + ChownDirs: idPair, + ChownFiles: idPair, } return c.joinMountAndExec(ctx, |