summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--OWNERS2
-rw-r--r--cmd/podman/containers/cp.go8
-rw-r--r--docs/source/markdown/podman-save.1.md5
-rw-r--r--test/system/065-cp.bats9
4 files changed, 22 insertions, 2 deletions
diff --git a/OWNERS b/OWNERS
index 88dedae25..8f5368b00 100644
--- a/OWNERS
+++ b/OWNERS
@@ -5,6 +5,7 @@ approvers:
- jwhonce
- Luap99
- mheon
+ - mtrmac
- rhatdan
- saschagrunert
- TomSweeneyRedHat
@@ -19,6 +20,7 @@ reviewers:
- jwhonce
- Luap99
- mheon
+ - mtrmac
- QiWang19
- rhatdan
- saschagrunert
diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go
index 2c7d72b20..0ad258824 100644
--- a/cmd/podman/containers/cp.go
+++ b/cmd/podman/containers/cp.go
@@ -177,6 +177,10 @@ func copyFromContainer(container string, containerPath string, hostPath string)
containerTarget = filepath.Dir(containerTarget)
}
+ if !isStdout && containerInfo.IsDir && !hostInfo.IsDir {
+ return errors.New("destination must be a directory when copying a directory")
+ }
+
reader, writer := io.Pipe()
hostCopy := func() error {
defer reader.Close()
@@ -334,6 +338,10 @@ func copyToContainer(container string, containerPath string, hostPath string) er
stdinFile = tmpFile.Name()
}
+ if hostInfo.IsDir && !containerInfo.IsDir {
+ return errors.New("destination must be a directory when copying a directory")
+ }
+
reader, writer := io.Pipe()
hostCopy := func() error {
defer writer.Close()
diff --git a/docs/source/markdown/podman-save.1.md b/docs/source/markdown/podman-save.1.md
index ab21d2bc6..1f1f60b22 100644
--- a/docs/source/markdown/podman-save.1.md
+++ b/docs/source/markdown/podman-save.1.md
@@ -35,8 +35,9 @@ Write to a file, default is STDOUT
#### **--format**=*format*
-Save image to **oci-archive, oci-dir** (directory with oci manifest type), or **docker-dir** (directory with v2s2 manifest type)
+Save image to **docker-archive**, **oci-archive** (see `containers-transports(5)`), **oci-dir** (`oci` transport), or **docker-dir** (`dir` transport with v2s2 manifest type).
```
+--format docker-archive
--format oci-archive
--format oci-dir
--format docker-dir
@@ -100,7 +101,7 @@ Storing signatures
```
## SEE ALSO
-podman(1), podman-load(1), containers.conf(5)
+podman(1), podman-load(1), containers.conf(5), containers-transports(5)
## HISTORY
July 2017, Originally compiled by Urvashi Mohnani <umohnani@redhat.com>
diff --git a/test/system/065-cp.bats b/test/system/065-cp.bats
index 24ac8118e..eda04611f 100644
--- a/test/system/065-cp.bats
+++ b/test/system/065-cp.bats
@@ -272,6 +272,11 @@ load helpers
run_podman rm -f cpcontainer
done < <(parse_table "$tests")
+ run_podman create --name cpcontainer --workdir=/srv $cpimage sleep infinity
+ run_podman 125 cp $srcdir cpcontainer:/etc/os-release
+ is "$output" "Error: destination must be a directory when copying a directory" "cannot copy directory to file"
+ run_podman rm -f cpcontainer
+
run_podman rmi -f $cpimage
}
@@ -343,6 +348,10 @@ load helpers
is "$(< $destdir$dest_fullname/containerfile1)" "${randomcontent[1]}" "$description"
rm -rf $destdir/*
done < <(parse_table "$tests")
+
+ touch $destdir/testfile
+ run_podman 125 cp cpcontainer:/etc/ $destdir/testfile
+ is "$output" "Error: destination must be a directory when copying a directory" "cannot copy directory to file"
run_podman rm -f cpcontainer
run_podman rmi -f $cpimage