summaryrefslogtreecommitdiff
path: root/cmd/podman/cp.go
diff options
context:
space:
mode:
authorQi Wang <qiwan@redhat.com>2019-08-08 16:48:17 -0400
committerQi Wang <qiwan@redhat.com>2019-08-08 17:14:47 -0400
commita2561ec58a1db6851a94d20c38fb1c913830cd34 (patch)
tree35b323f6391d36ea0cbef3b5f3af3f755516a191 /cmd/podman/cp.go
parent09cedd152d5c5827520635b10498d15225999e19 (diff)
downloadpodman-a2561ec58a1db6851a94d20c38fb1c913830cd34.tar.gz
podman-a2561ec58a1db6851a94d20c38fb1c913830cd34.tar.bz2
podman-a2561ec58a1db6851a94d20c38fb1c913830cd34.zip
fix copy change file owner if cp from container
If copies file from container to local machine, change the file owner to the cp command caller. Signed-off-by: Qi Wang <qiwan@redhat.com>
Diffstat (limited to 'cmd/podman/cp.go')
-rw-r--r--cmd/podman/cp.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd/podman/cp.go b/cmd/podman/cp.go
index bee7d2199..ad7253ac0 100644
--- a/cmd/podman/cp.go
+++ b/cmd/podman/cp.go
@@ -140,7 +140,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
if err != nil {
return errors.Wrapf(err, "error getting IDMappingOptions")
}
- containerOwner := idtools.IDPair{UID: int(user.UID), GID: int(user.GID)}
+ destOwner := idtools.IDPair{UID: int(user.UID), GID: int(user.GID)}
hostUID, hostGID, err := util.GetHostIDs(convertIDMap(idMappingOpts.UIDMap), convertIDMap(idMappingOpts.GIDMap), user.UID, user.GID)
if err != nil {
return err
@@ -183,6 +183,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
destPath = cleanedPath
}
} else {
+ destOwner = idtools.IDPair{UID: os.Getuid(), GID: os.Getgid()}
if isVol, volDestName, volName := isVolumeDestName(srcPath, ctr); isVol {
path, err := pathWithVolumeMount(ctr, runtime, volDestName, volName, srcPath)
if err != nil {
@@ -230,7 +231,7 @@ func copyBetweenHostAndContainer(runtime *libpod.Runtime, src string, dest strin
src = os.Stdin.Name()
extract = true
}
- err := copy(src, destPath, dest, idMappingOpts, &containerOwner, extract, isFromHostToCtr)
+ err := copy(src, destPath, dest, idMappingOpts, &destOwner, extract, isFromHostToCtr)
if lastError != nil {
logrus.Error(lastError)
}