Skip to content

Commit 599dbf6

Browse files
giuseppeclaude
andcommitted
storage: fix UID/GID map handling for shifting layers
when the driver supports shifting, set the rechown target to identity instead of the container's maps. Closes: https://redhat.atlassian.net/browse/RHEL-160859 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
1 parent 8443f51 commit 599dbf6

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

storage/layers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,9 @@ func (r *layerStore) create(id string, parentLayer *Layer, names []string, mount
16491649
}
16501650

16511651
idMappings := idtools.NewIDMappingsFromMaps(moreOptions.IDMappingOptions.UIDMap, moreOptions.IDMappingOptions.GIDMap)
1652+
if moreOptions.IDMappingOptions.HostUIDMapping && moreOptions.IDMappingOptions.HostGIDMapping {
1653+
idMappings = &idtools.IDMappings{}
1654+
}
16521655
opts := drivers.CreateOpts{
16531656
MountLabel: mountLabel,
16541657
StorageOpt: options,

storage/store.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2042,9 +2042,10 @@ func (s *store) CreateContainer(id string, names []string, image, layer, metadat
20422042
// But in transient store mode, all container layers are volatile.
20432043
Volatile: options.Volatile || s.transientStore,
20442044
}
2045+
useHostMapping := idMappingsOptions.HostUIDMapping || s.canUseShifting(uidMap, gidMap)
20452046
layerOptions.IDMappingOptions = LayerIDMappingOptions{
2046-
HostUIDMapping: idMappingsOptions.HostUIDMapping,
2047-
HostGIDMapping: idMappingsOptions.HostGIDMapping,
2047+
HostUIDMapping: useHostMapping,
2048+
HostGIDMapping: useHostMapping,
20482049
UIDMap: copySlicePreferringNil(uidMap),
20492050
GIDMap: copySlicePreferringNil(gidMap),
20502051
}

0 commit comments

Comments
 (0)