Skip to content

Commit

Permalink
canUseShifting can segfault
Browse files Browse the repository at this point in the history
Fixes: containers/podman#10535

Signed-off-by: Daniel J Walsh <[email protected]>
  • Loading branch information
rhatdan committed Jun 8, 2021
1 parent 39e7061 commit 3b2f449
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions store.go
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ func (s *store) ContainerStore() (ContainerStore, error) {
}

func (s *store) canUseShifting(uidmap, gidmap []idtools.IDMap) bool {
if !s.graphDriver.SupportsShifting() {
if s.graphDriver == nil || !s.graphDriver.SupportsShifting() {
return false
}
if uidmap != nil && !idtools.IsContiguous(uidmap) {
Expand Down Expand Up @@ -2668,6 +2668,10 @@ func (s *store) mount(id string, options drivers.MountOpts) (string, error) {
s.lastLoaded = time.Now()
}

if options.UidMaps != nil || options.GidMaps != nil {
options.DisableShifting = !s.canUseShifting(options.UidMaps, options.GidMaps)
}

if rlstore.Exists(id) {
return rlstore.Mount(id, options)
}
Expand Down Expand Up @@ -2708,7 +2712,6 @@ func (s *store) Mount(id, mountLabel string) (string, error) {
options.Volatile = v.(bool)
}
}
options.DisableShifting = !s.canUseShifting(container.UIDMap, container.GIDMap)
}
return s.mount(id, options)
}
Expand Down

0 comments on commit 3b2f449

Please sign in to comment.