From 8577be72e8ec7fa597c7196bca0705d2c66083e0 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Mon, 22 Feb 2021 15:08:40 +0100 Subject: podman cp: treat /dev/stdout correctly /dev/stdout should not be treated as "-" to remain compatible with Docker and to have a more consistent and idiomatic interface. Fixes: #9362 Signed-off-by: Valentin Rothberg --- test/system/065-cp.bats | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'test/system') diff --git a/test/system/065-cp.bats b/test/system/065-cp.bats index 0fcc437d4..87a961160 100644 --- a/test/system/065-cp.bats +++ b/test/system/065-cp.bats @@ -508,6 +508,10 @@ load helpers run_podman exec cpcontainer sh -c "echo '$rand_content' > /tmp/file.txt" run_podman exec cpcontainer touch /tmp/empty.txt + # Make sure that only "-" gets special treatment. "/dev/stdout" + run_podman 125 cp cpcontainer:/tmp/file.txt /dev/stdout + is "$output" 'Error: invalid destination: "/dev/stdout" must be a directory or a regular file' + # Copying from stdout will always compress. So let's copy the previously # created file from the container via stdout, untar the archive and make # sure the file exists with the expected content. -- cgit v1.2.3-54-g00ecf From f3a8e3324f206339386b541927445926dd137ad2 Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Mon, 22 Feb 2021 15:22:29 +0100 Subject: podman cp: test /dev/stdin correctly /dev/stdin should not be treated as "-" to remain compatible with Docker and to have a more consistent and idiomatic interface. Signed-off-by: Valentin Rothberg --- cmd/podman/containers/cp.go | 2 -- test/system/065-cp.bats | 8 ++++---- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'test/system') diff --git a/cmd/podman/containers/cp.go b/cmd/podman/containers/cp.go index b29a95707..7887e9539 100644 --- a/cmd/podman/containers/cp.go +++ b/cmd/podman/containers/cp.go @@ -231,8 +231,6 @@ func copyToContainer(container string, containerPath string, hostPath string) er if hostPath == "-" { hostPath = os.Stdin.Name() isStdin = true - } else if hostPath == os.Stdin.Name() { - isStdin = true } // Make sure that host path exists. diff --git a/test/system/065-cp.bats b/test/system/065-cp.bats index 87a961160..312106b36 100644 --- a/test/system/065-cp.bats +++ b/test/system/065-cp.bats @@ -475,9 +475,9 @@ load helpers run_podman exec cpcontainer rm -rf /tmp/$srcdir # Now for "/dev/stdin". + # Note: while this works, the content ends up in Nirvana. + # Same for Docker. run_podman cp /dev/stdin cpcontainer:/tmp < $tar_file - run_podman exec cpcontainer cat /tmp/$srcdir/$rand_filename - is "$output" "$rand_content" # Error checks below ... @@ -487,11 +487,11 @@ load helpers # Destination must be a directory (on an existing file). run_podman exec cpcontainer touch /tmp/file.txt - run_podman 125 cp /dev/stdin cpcontainer:/tmp/file.txt < $tar_file + run_podman 125 cp - cpcontainer:/tmp/file.txt < $tar_file is "$output" 'Error: destination must be a directory when copying from stdin' # Destination must be a directory (on an absent path). - run_podman 125 cp /dev/stdin cpcontainer:/tmp/IdoNotExist < $tar_file + run_podman 125 cp - cpcontainer:/tmp/IdoNotExist < $tar_file is "$output" 'Error: destination must be a directory when copying from stdin' run_podman rm -f cpcontainer -- cgit v1.2.3-54-g00ecf