summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-02-18 17:56:47 +0100
committerValentin Rothberg <rothberg@redhat.com>2021-02-18 18:23:23 +0100
commit71689052a1a70c10171607bdc6d75a4985f8565a (patch)
tree30050e2cfb18573f8a8dde8d59121c9e0c8775e4 /cmd
parentc3419d2168415cb3e6f1349afaa9c04c29cbb933 (diff)
downloadpodman-71689052a1a70c10171607bdc6d75a4985f8565a.tar.gz
podman-71689052a1a70c10171607bdc6d75a4985f8565a.tar.bz2
podman-71689052a1a70c10171607bdc6d75a4985f8565a.zip
cp: treat "." and "/." correctly
Make sure to treat "." and "/." correctly. Both cases imply to copy the contents of a directory in contrast to the directory. This implies to unset the KeepDirectoryNames options of the copiah package. Previously, the code was performing a simple string suffix check which is not enough since it would match files and directories ending with ".". Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/containers/cp.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go
index 69b61a06c..5db05719c 100644
--- a/cmd/podman/containers/cp.go
+++ b/cmd/podman/containers/cp.go
@@ -311,8 +311,8 @@ func copyToContainer(container string, containerPath string, hostPath string) er
}
getOptions := buildahCopiah.GetOptions{
- // Unless the specified path ends with ".", we want to copy the base directory.
- KeepDirectoryNames: !strings.HasSuffix(hostPath, "."),
+ // Unless the specified points to ".", we want to copy the base directory.
+ KeepDirectoryNames: hostInfo.IsDir && filepath.Base(hostPath) != ".",
}
if !hostInfo.IsDir && (!containerInfo.IsDir || containerInfoErr != nil) {
// If we're having a file-to-file copy, make sure to