Skip to content

Commit

Permalink
podman cp: test /dev/stdin correctly
Browse files Browse the repository at this point in the history
/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 <[email protected]>
  • Loading branch information
vrothberg committed Mar 10, 2021
1 parent 20f2160 commit 08eba6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
2 changes: 0 additions & 2 deletions cmd/podman/containers/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions test/system/065-cp.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ...

Expand All @@ -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
Expand Down

0 comments on commit 08eba6f

Please sign in to comment.