aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2021-02-17 14:09:28 -0500
committerMatthew Heon <mheon@redhat.com>2021-02-18 10:16:25 -0500
commit59d2eac78a2a8e619d9c1c53b065f34f0e19795c (patch)
tree5755dca6967d8d9d03ffcd03c07f716d9bc29f73
parent2fb1511690dba70adf25c36c28ec4bad2af79106 (diff)
downloadpodman-59d2eac78a2a8e619d9c1c53b065f34f0e19795c.tar.gz
podman-59d2eac78a2a8e619d9c1c53b065f34f0e19795c.tar.bz2
podman-59d2eac78a2a8e619d9c1c53b065f34f0e19795c.zip
Change source path resolution for volume copy-up
Instead of using the container's mountpoint as the base of the chroot and indexing from there by the volume directory, instead use the full path of what we want to copy as the base of the chroot and copy everything in it. This resolves the bug, ends up being a bit simpler code-wise (no string concatenation, as we already have the full path calculated for other checks), and seems more understandable than trying to resolve things on the destination side of the copy-up. Fixes #9354 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
-rw-r--r--libpod/container_internal.go2
-rw-r--r--test/e2e/run_volume_test.go12
2 files changed, 13 insertions, 1 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index ac7c1b2dc..7aaa002b2 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1642,7 +1642,7 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string)
getOptions := copier.GetOptions{
KeepDirectoryNames: false,
}
- errChan <- copier.Get(mountpoint, "", getOptions, []string{v.Dest + "/."}, writer)
+ errChan <- copier.Get(srcDir, "", getOptions, []string{"/."}, writer)
}()
// Copy, volume side: stream what we've written to the pipe, into
diff --git a/test/e2e/run_volume_test.go b/test/e2e/run_volume_test.go
index 91d8f15f4..d81fb769d 100644
--- a/test/e2e/run_volume_test.go
+++ b/test/e2e/run_volume_test.go
@@ -334,6 +334,18 @@ RUN sh -c "cd /etc/apk && ln -s ../../testfile"`
Expect(outputSession.OutputToString()).To(Equal(baselineOutput))
})
+ It("podman named volume copyup of /var", func() {
+ baselineSession := podmanTest.Podman([]string{"run", "--rm", "-t", "-i", fedoraMinimal, "ls", "/var"})
+ baselineSession.WaitWithDefaultTimeout()
+ Expect(baselineSession.ExitCode()).To(Equal(0))
+ baselineOutput := baselineSession.OutputToString()
+
+ outputSession := podmanTest.Podman([]string{"run", "-t", "-i", "-v", "/var", fedoraMinimal, "ls", "/var"})
+ outputSession.WaitWithDefaultTimeout()
+ Expect(outputSession.ExitCode()).To(Equal(0))
+ Expect(outputSession.OutputToString()).To(Equal(baselineOutput))
+ })
+
It("podman read-only tmpfs conflict with volume", func() {
session := podmanTest.Podman([]string{"run", "--rm", "-t", "-i", "--read-only", "-v", "tmp_volume:" + dest, ALPINE, "touch", dest + "/a"})
session.WaitWithDefaultTimeout()