Skip to content

Commit e5daf60

Browse files
Merge pull request #25775 from jankaluza/idmap
Set the IDMappings also when RootfsOverlay is used.
2 parents 1d31265 + 9277643 commit e5daf60

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

libpod/container_internal.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -536,12 +536,8 @@ func (c *Container) setupStorage(ctx context.Context) error {
536536
return fmt.Errorf("creating container storage: %w", containerInfoErr)
537537
}
538538

539-
// Only reconfig IDMappings if layer was mounted from storage.
540-
// If it's an external overlay do not reset IDmappings.
541-
if !c.config.RootfsOverlay {
542-
c.config.IDMappings.UIDMap = containerInfo.UIDMap
543-
c.config.IDMappings.GIDMap = containerInfo.GIDMap
544-
}
539+
c.config.IDMappings.UIDMap = containerInfo.UIDMap
540+
c.config.IDMappings.GIDMap = containerInfo.GIDMap
545541

546542
processLabel, err := c.processLabel(containerInfo.ProcessLabel)
547543
if err != nil {

test/e2e/run_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,13 @@ var _ = Describe("Podman run", func() {
322322
osession.WaitWithDefaultTimeout()
323323
Expect(osession).Should(ExitCleanly())
324324
Expect(osession.OutputToString()).To(Equal("0 1234 5678"))
325+
326+
// Test --rootfs with an external overlay with --userns=auto
327+
osession = podmanTest.Podman([]string{"run", "--userns=auto", "--rm", "--security-opt", "label=disable",
328+
"--rootfs", rootfs + ":O", "cat", "/proc/self/uid_map"})
329+
osession.WaitWithDefaultTimeout()
330+
Expect(osession).Should(ExitCleanly())
331+
Expect(osession.OutputToString()).To(ContainSubstring("1024"))
325332
})
326333

327334
It("podman run a container with --init", func() {

0 commit comments

Comments
 (0)