Skip to content

cp of a source ending in /. copies the directory itself, not its contents #1795

Description

@Jaro-c

podup cp payload/. SERVICE:/tmp should copy the contents of payload into /tmp, the way docker cp and podman cp treat a source ending in /.. It copies the directory itself instead, and the files land in /tmp/payload/.

Why

pack_path in internal/engine/copy/archive.rs names the archive's top entry with src.file_name(). Rust's Path drops a trailing . component, so Path::new("payload/.").file_name() is Some("payload"), and the tree is packed under payload/. Nothing on the way from the CLI to pack_path handles the /. suffix: I searched for it and found no match.

I found this by reading, during a review of #1790, and have not run it against a container yet. It is not introduced by #1790; it is on develop today.

What the fix needs

  • Detect the trailing /. on the source as written, before it becomes a Path, since the Path has already lost it.
  • Pack the directory's children at the top of the archive rather than under the directory's name.
  • A live test in tests/engine_integration/cp_flags.rs that copies payload/. and asserts the files are at /tmp/a.txt, not /tmp/payload/a.txt, plus the same for the host direction if cp SERVICE:/path/. host has the same shape.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions