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

[WIP] Add support for podman cp --follow-link #15730

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 10 additions & 2 deletions cmd/podman/containers/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,16 @@ var (
)

var (
cpOpts entities.ContainerCpOptions
chown bool
cpOpts entities.ContainerCpOptions
chown bool
followLink bool
)

func cpFlags(cmd *cobra.Command) {
flags := cmd.Flags()
flags.BoolVar(&cpOpts.OverwriteDirNonDir, "overwrite", false, "Allow to overwrite directories with non-directories and vice versa")
flags.BoolVarP(&chown, "archive", "a", true, `Chown copied files to the primary uid/gid of the destination container.`)
flags.BoolVarP(&followLink, "follow-link", "L", true, `Always follow symbol link in SRC_PATH`)

// Deprecated flags (both are NOPs): exist for backwards compat
flags.BoolVar(&cpOpts.Extract, "extract", false, "Deprecated...")
Expand Down Expand Up @@ -93,6 +95,12 @@ func cp(cmd *cobra.Command, args []string) error {
return copyFromContainer(sourceContainerStr, sourcePath, destPath)
}

if followLink {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it also apply to symlink inside a container?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know.

sourcePath, err = filepath.EvalSymlinks(sourcePath)
if err != nil {
return err
}
}
return copyToContainer(destContainerStr, destPath, sourcePath)
}

Expand Down