Skip to content

Commit 9277643

Browse files
committed
Set the IDMappings also when RootfsOverlay is used.
This is related to #23292 and is needed to replace pause image container with pause container based on the rootfs. Without this change, the GIDs and UIDs are not mapped in the rootfs container which use overlay if --userns=auto is used. This leads to an error mounting /dev/pts with gid=5, becuase GID 5 simply does not exist in the pause container using rootfs. All the tests pass with this change, but I have to admit I did not find out why the original code has been introduced. Signed-off-by: Jan Kaluza <[email protected]>
1 parent 4f75d0b commit 9277643

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)