Skip to content
Draft
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
2 changes: 1 addition & 1 deletion cmd/podman/containers/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var (
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(&chown, "archive", "a", false, `Chown copied files to the primary uid/gid of the destination container.`)

// Deprecated flags (both are NOPs): exist for backwards compat
flags.BoolVar(&cpOpts.Extract, "extract", false, "Deprecated...")
Expand Down
15 changes: 12 additions & 3 deletions libpod/container_copy_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ func (c *Container) copyFromArchive(path string, chown, noOverwriteDirNonDir boo
}

var idPair *idtools.IDPair
var userlessContainer bool
if chown {
// Make sure we chown the files to the container's main user and group ID.
user, err := getContainerUser(c, mountPoint)
Expand All @@ -196,6 +197,7 @@ func (c *Container) copyFromArchive(path string, chown, noOverwriteDirNonDir boo
return nil, err
}
idPair = &idtools.IDPair{UID: int(user.UID), GID: int(user.GID)}
userlessContainer = user.UserlessContainer
}

decompressed, err := archive.DecompressStream(reader)
Expand All @@ -219,6 +221,7 @@ func (c *Container) copyFromArchive(path string, chown, noOverwriteDirNonDir boo
NoOverwriteDirNonDir: noOverwriteDirNonDir,
NoOverwriteNonDirDir: noOverwriteDirNonDir,
Rename: rename,
UserlessContainer: userlessContainer,
}

return c.joinMountAndExec(
Expand Down Expand Up @@ -311,9 +314,15 @@ func getContainerUser(container *Container, mountPoint string) (specs.User, erro

uid, gid, _, err := chrootuser.GetUser(mountPoint, userspec)
u := specs.User{
UID: uid,
GID: gid,
Username: userspec,
UID: uid,
GID: gid,
Username: userspec,
UserlessContainer: false,
}

if errors.Is(err, chrootuser.ErrUserlessContainer) {
u.UserlessContainer = true
err = nil
}

if !strings.Contains(userspec, ":") {
Expand Down
5 changes: 3 additions & 2 deletions vendor/github.com/containers/buildah/copier/copier.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions vendor/github.com/containers/buildah/pkg/chrootuser/user.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.