Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bug copy from container directory #4774

Merged
merged 1 commit into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cmd/podman/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
srcPath = os.Stdin.Name()
extract = true
}
return copy(srcPath, destPath, dest, idMappingOpts, &destOwner, extract, isFromHostToCtr)
return copy(srcPath, destPath, src, dest, idMappingOpts, &destOwner, extract, isFromHostToCtr)
}

func getUser(mountPoint string, userspec string) (specs.User, error) {
Expand Down Expand Up @@ -276,8 +276,8 @@ func getPathInfo(path string) (string, os.FileInfo, error) {
return path, srcfi, nil
}

func copy(src, destPath, dest string, idMappingOpts storage.IDMappingOptions, chownOpts *idtools.IDPair, extract, isFromHostToCtr bool) error {
srcPath, err := evalSymlinks(src)
func copy(srcPath, destPath, src, dest string, idMappingOpts storage.IDMappingOptions, chownOpts *idtools.IDPair, extract, isFromHostToCtr bool) error {
srcPath, err := evalSymlinks(srcPath)
if err != nil {
return errors.Wrapf(err, "error evaluating symlinks %q", srcPath)
}
Expand Down
27 changes: 27 additions & 0 deletions test/e2e/cp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,33 @@ var _ = Describe("Podman cp", func() {
session = podmanTest.Podman([]string{"cp", testDirPath, name + ":/foodir"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

testctr := "testctr"
setup := podmanTest.RunTopContainer(testctr)
setup.WaitWithDefaultTimeout()
Expect(setup.ExitCode()).To(Equal(0))

session = podmanTest.Podman([]string{"exec", testctr, "mkdir", "foo"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))

session = podmanTest.Podman([]string{"cp", testDirPath + "/.", testctr + ":/foo"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
session = podmanTest.Podman([]string{"exec", testctr, "ls", "foo"})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
Expect(len(session.OutputToString())).To(Equal(0))

session = podmanTest.Podman([]string{"cp", testctr + ":/foo/.", testDirPath})
session.WaitWithDefaultTimeout()
Expect(session.ExitCode()).To(Equal(0))
cmd := exec.Command("ls", testDirPath)
res, err := cmd.Output()
Expect(err).To(BeNil())
Expect(len(res)).To(Equal(0))

os.RemoveAll(testDirPath)
})

It("podman cp stdin/stdout", func() {
Expand Down