diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-03-15 14:52:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-15 14:52:45 -0700 |
commit | 3754f58499ad17386d8faa7c2fab1d9cc8231923 (patch) | |
tree | 5fd61e85cccaabc6ae7ad0166d739f0d5443ec54 | |
parent | 6e4c32967ec02cdc33b801df8b5730dffce9b8a3 (diff) | |
parent | 9d81be961491ac965f6cc9fd96884833c0165334 (diff) | |
download | podman-3754f58499ad17386d8faa7c2fab1d9cc8231923.tar.gz podman-3754f58499ad17386d8faa7c2fab1d9cc8231923.tar.bz2 podman-3754f58499ad17386d8faa7c2fab1d9cc8231923.zip |
Merge pull request #2643 from rhatdan/volumes
Make sure buildin volumes have the same ownership and permissions as …
-rw-r--r-- | docs/podman-load.1.md | 2 | ||||
-rw-r--r-- | libpod/container_internal.go | 4 | ||||
-rw-r--r-- | libpod/container_internal_linux.go | 17 | ||||
-rw-r--r-- | libpod/container_internal_unsupported.go | 4 |
4 files changed, 26 insertions, 1 deletions
diff --git a/docs/podman-load.1.md b/docs/podman-load.1.md index 8b6501a5c..5363f3f1e 100644 --- a/docs/podman-load.1.md +++ b/docs/podman-load.1.md @@ -4,7 +4,7 @@ podman\-load - Load an image from docker archive ## SYNOPSIS -**podman load** *name*[:*tag*|@*digest*] +**podman load** [ARCHIVE] ## DESCRIPTION **podman load** copies an image from either **docker-archive** or **oci-archive** stored diff --git a/libpod/container_internal.go b/libpod/container_internal.go index 872802016..ac2d65342 100644 --- a/libpod/container_internal.go +++ b/libpod/container_internal.go @@ -1429,5 +1429,9 @@ func (c *Container) copyWithTarFromImage(src, dest string) error { } a := archive.NewDefaultArchiver() source := filepath.Join(mountpoint, src) + + if err = c.copyOwnerAndPerms(source, dest); err != nil { + return err + } return a.CopyWithTar(source, dest) } diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go index a7b4aed9f..2a7808bdf 100644 --- a/libpod/container_internal_linux.go +++ b/libpod/container_internal_linux.go @@ -982,3 +982,20 @@ func (c *Container) generatePasswd() (string, error) { } return passwdFile, nil } + +func (c *Container) copyOwnerAndPerms(source, dest string) error { + info, err := os.Stat(source) + if err != nil { + if os.IsNotExist(err) { + return nil + } + return errors.Wrapf(err, "cannot stat `%s`", dest) + } + if err := os.Chmod(dest, info.Mode()); err != nil { + return errors.Wrapf(err, "cannot chmod `%s`", dest) + } + if err := os.Chown(dest, int(info.Sys().(*syscall.Stat_t).Uid), int(info.Sys().(*syscall.Stat_t).Gid)); err != nil { + return errors.Wrapf(err, "cannot chown `%s`", dest) + } + return nil +} diff --git a/libpod/container_internal_unsupported.go b/libpod/container_internal_unsupported.go index 4af0cd56c..f707b350c 100644 --- a/libpod/container_internal_unsupported.go +++ b/libpod/container_internal_unsupported.go @@ -35,3 +35,7 @@ func (c *Container) checkpoint(ctx context.Context, options ContainerCheckpointO func (c *Container) restore(ctx context.Context, options ContainerCheckpointOptions) error { return ErrNotImplemented } + +func (c *Container) copyOwnerAndPerms(source, dest string) error { + return nil +} |