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

reintroduce store: allow shifting only with contiguous mappings #911

Merged
merged 2 commits into from
May 20, 2021

Conversation

giuseppe
Copy link
Member

reintroduce store: allow shifting only with contiguous mappings after it was reverted.

enable fuse-overlayfs shifting only when the specified mapping is contiguous.

Closes: containers/podman#10272

Signed-off-by: Giuseppe Scrivano [email protected]

The difference with the first version:

diff --git a/store.go b/store.go
index 22f932698..759407c63 100644
--- a/store.go
+++ b/store.go
@@ -1114,7 +1114,7 @@ func (s *store) CreateImage(id string, names []string, layer, metadata string, o
 func (s *store) imageTopLayerForMapping(image *Image, ristore ROImageStore, createMappedLayer bool, rlstore LayerStore, lstores []ROLayerStore, options types.IDMappingOptions) (*Layer, error) {
        layerMatchesMappingOptions := func(layer *Layer, options types.IDMappingOptions) bool {
                // If the driver supports shifting and the layer has no mappings, we can use it.
-               if s.canUseShifting(layer.UIDMap, layer.GIDMap) && len(layer.UIDMap) == 0 && len(layer.GIDMap) == 0 {
+               if s.canUseShifting(options.UIDMap, options.GIDMap) && len(layer.UIDMap) == 0 && len(layer.GIDMap) == 0 {
                        return true
                }
                // If we want host mapping, and the layer uses mappings, it's not the best match.
@@ -2706,7 +2706,7 @@ func (s *store) Mount(id, mountLabel string) (string, error) {
                                options.Volatile = v.(bool)
                        }
                }
-               options.DisableShifting = true
+               options.DisableShifting = !s.canUseShifting(container.UIDMap, container.GIDMap)
        }
        return s.mount(id, options)
 }

with this patch I get:

$ ./bin/podman run --rm --userns=keep-id  fedora  stat -c '%u:%g:%n'  /etc
0:0:/etc

enable fuse-overlayfs shifting only when the specified mapping is
contiguous.

Closes: containers/podman#10272

Signed-off-by: Giuseppe Scrivano <[email protected]>
Signed-off-by: Giuseppe Scrivano <[email protected]>
@rhatdan
Copy link
Member

rhatdan commented May 18, 2021

LGTM

@rhatdan
Copy link
Member

rhatdan commented May 20, 2021

Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

LGTM

@vrothberg vrothberg merged commit 78deb96 into containers:master May 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

userns doesn't seem to work anymore (rootless) - big UID
3 participants