aboutsummaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-19 06:09:22 -0500
committerGitHub <noreply@github.com>2021-02-19 06:09:22 -0500
commit6a9257a292f034d2576b78913c0d555b936b4963 (patch)
tree296a9c359010dcab03b82f44da74352ecec06ed1 /pkg
parent1c6c94d44a207e42eddf9b863c20e5004021f3af (diff)
parent71689052a1a70c10171607bdc6d75a4985f8565a (diff)
downloadpodman-6a9257a292f034d2576b78913c0d555b936b4963.tar.gz
podman-6a9257a292f034d2576b78913c0d555b936b4963.tar.bz2
podman-6a9257a292f034d2576b78913c0d555b936b4963.zip
Merge pull request #9428 from vrothberg/cp-content-fix
cp: treat "." and "/." correctly
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/infra/abi/archive.go7
1 files changed, 4 insertions, 3 deletions
diff --git a/pkg/domain/infra/abi/archive.go b/pkg/domain/infra/abi/archive.go
index c64dfb02a..f38f5c132 100644
--- a/pkg/domain/infra/abi/archive.go
+++ b/pkg/domain/infra/abi/archive.go
@@ -3,6 +3,7 @@ package abi
import (
"context"
"io"
+ "path/filepath"
"strings"
buildahCopiah "github.com/containers/buildah/copier"
@@ -93,7 +94,7 @@ func (ic *ContainerEngine) ContainerCopyToArchive(ctx context.Context, nameOrID
containerPath = "/."
}
- _, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerMountPoint, containerPath)
+ statInfo, resolvedRoot, resolvedContainerPath, err := ic.containerStat(container, containerMountPoint, containerPath)
if err != nil {
unmount()
return nil, err
@@ -110,8 +111,8 @@ func (ic *ContainerEngine) ContainerCopyToArchive(ctx context.Context, nameOrID
return func() error {
defer container.Unmount(false)
getOptions := buildahCopiah.GetOptions{
- // Unless the specified path ends with ".", we want to copy the base directory.
- KeepDirectoryNames: !strings.HasSuffix(resolvedContainerPath, "."),
+ // Unless the specified points to ".", we want to copy the base directory.
+ KeepDirectoryNames: statInfo.IsDir && filepath.Base(containerPath) != ".",
UIDMap: idMappings.UIDMap,
GIDMap: idMappings.GIDMap,
ChownDirs: idPair,