aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal.go35
-rw-r--r--libpod/runtime_img.go2
2 files changed, 23 insertions, 14 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index c44ba5fe6..675311461 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1521,9 +1521,6 @@ func (c *Container) chownVolume(volumeName string) error {
return errors.Wrapf(err, "error retrieving named volume %s for container %s", volumeName, c.ID())
}
- uid := int(c.config.Spec.Process.User.UID)
- gid := int(c.config.Spec.Process.User.GID)
-
vol.lock.Lock()
defer vol.lock.Unlock()
@@ -1534,22 +1531,34 @@ func (c *Container) chownVolume(volumeName string) error {
if vol.state.NeedsChown {
vol.state.NeedsChown = false
+
+ uid := int(c.config.Spec.Process.User.UID)
+ gid := int(c.config.Spec.Process.User.GID)
+
+ if c.config.IDMappings.UIDMap != nil {
+ p := idtools.IDPair{
+ UID: uid,
+ GID: gid,
+ }
+ mappings := idtools.NewIDMappingsFromMaps(c.config.IDMappings.UIDMap, c.config.IDMappings.GIDMap)
+ newPair, err := mappings.ToHost(p)
+ if err != nil {
+ return errors.Wrapf(err, "error mapping user %d:%d", uid, gid)
+ }
+ uid = newPair.UID
+ gid = newPair.GID
+ }
+
vol.state.UIDChowned = uid
vol.state.GIDChowned = gid
if err := vol.save(); err != nil {
return err
}
- err := filepath.Walk(vol.MountPoint(), func(path string, info os.FileInfo, err error) error {
- if err != nil {
- return err
- }
- if err := os.Chown(path, uid, gid); err != nil {
- return err
- }
- return nil
- })
- if err != nil {
+
+ mountPoint := vol.MountPoint()
+
+ if err := os.Lchown(mountPoint, uid, gid); err != nil {
return err
}
}
diff --git a/libpod/runtime_img.go b/libpod/runtime_img.go
index eab05f34d..7c75dbf98 100644
--- a/libpod/runtime_img.go
+++ b/libpod/runtime_img.go
@@ -48,7 +48,7 @@ func (r *Runtime) RemoveImage(ctx context.Context, img *image.Image, force bool)
imageCtrs = append(imageCtrs, ctr)
}
}
- if len(imageCtrs) > 0 && len(img.Names()) <= 1 {
+ if len(imageCtrs) > 0 && (len(img.Names()) <= 1 || (force && img.InputIsID())) {
if force {
for _, ctr := range imageCtrs {
if err := r.removeContainer(ctx, ctr, true, false, false); err != nil {