summaryrefslogtreecommitdiff
path: root/test/system
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2021-03-05 11:57:14 +0100
committerValentin Rothberg <rothberg@redhat.com>2021-03-09 09:02:14 +0100
commita61d70cf8ef8666be87758dd3875a01ccdcc4c53 (patch)
tree7eb0ce6fe6ad7591c80ef86802bd3216ffb574e2 /test/system
parent2abfef3809abc59e8d29bcbcf2b5e0aa7141fb6d (diff)
downloadpodman-a61d70cf8ef8666be87758dd3875a01ccdcc4c53.tar.gz
podman-a61d70cf8ef8666be87758dd3875a01ccdcc4c53.tar.bz2
podman-a61d70cf8ef8666be87758dd3875a01ccdcc4c53.zip
podman cp: fix ownership
Make sure the files are chowned to the host/container user, depending on where things are being copied to. Fixes: #9626 Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'test/system')
-rw-r--r--test/system/065-cp.bats17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/system/065-cp.bats b/test/system/065-cp.bats
index 88ed983d8..24d8a9fd1 100644
--- a/test/system/065-cp.bats
+++ b/test/system/065-cp.bats
@@ -88,6 +88,7 @@ load helpers
run_podman rmi -f $cpimage
}
+
@test "podman cp file from host to container tmpfs mount" {
srcdir=$PODMAN_TMPDIR/cp-test-file-host-to-ctr
mkdir -p $srcdir
@@ -113,6 +114,22 @@ load helpers
}
+@test "podman cp file from host to container and check ownership" {
+ srcdir=$PODMAN_TMPDIR/cp-test-file-host-to-ctr
+ mkdir -p $srcdir
+ content=cp-user-test-$(random_string 10)
+ echo "content" > $srcdir/hostfile
+ userid=$(id -u)
+
+ run_podman run --user=$userid --userns=keep-id -d --name cpcontainer $IMAGE sleep infinity
+ run_podman cp $srcdir/hostfile cpcontainer:/tmp/hostfile
+ run_podman exec cpcontainer stat -c "%u" /tmp/hostfile
+ is "$output" "$userid" "copied file is chowned to the container user"
+ run_podman kill cpcontainer
+ run_podman rm -f cpcontainer
+}
+
+
@test "podman cp file from container to host" {
srcdir=$PODMAN_TMPDIR/cp-test-file-ctr-to-host
mkdir -p $srcdir