summaryrefslogtreecommitdiff
path: root/libpod/container_inspect.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-01-14 14:33:01 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2022-01-17 06:48:54 -0500
commit10d969ff1a15e8f53eb5a2fa7eb8cfb321609b55 (patch)
treefe5be3f9cd57047c393193d467457fcebd1a506a /libpod/container_inspect.go
parentea2656dc8658f99a0e9be2342557763e974513b9 (diff)
downloadpodman-10d969ff1a15e8f53eb5a2fa7eb8cfb321609b55.tar.gz
podman-10d969ff1a15e8f53eb5a2fa7eb8cfb321609b55.tar.bz2
podman-10d969ff1a15e8f53eb5a2fa7eb8cfb321609b55.zip
Use PODMAN_USERNS environment variable when running as a service
Fixes: https://github.com/containers/podman/issues/11350#issuecomment-1011562526 Also add inspect information about the idmappings if they exists. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/container_inspect.go')
-rw-r--r--libpod/container_inspect.go16
1 files changed, 15 insertions, 1 deletions
diff --git a/libpod/container_inspect.go b/libpod/container_inspect.go
index 792dfc58e..5e63db0f2 100644
--- a/libpod/container_inspect.go
+++ b/libpod/container_inspect.go
@@ -9,6 +9,7 @@ import (
"github.com/containers/podman/v3/libpod/define"
"github.com/containers/podman/v3/libpod/driver"
"github.com/containers/podman/v3/pkg/util"
+ "github.com/containers/storage/types"
units "github.com/docker/go-units"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/generate"
@@ -403,6 +404,17 @@ func (c *Container) generateInspectContainerConfig(spec *spec.Spec) *define.Insp
return ctrConfig
}
+func generateIDMappings(idMappings types.IDMappingOptions) *define.InspectIDMappings {
+ var inspectMappings define.InspectIDMappings
+ for _, uid := range idMappings.UIDMap {
+ inspectMappings.UIDMap = append(inspectMappings.UIDMap, fmt.Sprintf("%d:%d:%d", uid.ContainerID, uid.HostID, uid.Size))
+ }
+ for _, gid := range idMappings.GIDMap {
+ inspectMappings.GIDMap = append(inspectMappings.GIDMap, fmt.Sprintf("%d:%d:%d", gid.ContainerID, gid.HostID, gid.Size))
+ }
+ return &inspectMappings
+}
+
// Generate the InspectContainerHostConfig struct for the HostConfig field of
// Inspect.
func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, namedVolumes []*ContainerNamedVolume, mounts []spec.Mount) (*define.InspectContainerHostConfig, error) {
@@ -815,7 +827,9 @@ func (c *Container) generateInspectContainerHostConfig(ctrSpec *spec.Spec, named
}
}
hostConfig.UsernsMode = usernsMode
-
+ if c.config.IDMappings.UIDMap != nil && c.config.IDMappings.GIDMap != nil {
+ hostConfig.IDMappings = generateIDMappings(c.config.IDMappings)
+ }
// Devices
// Do not include if privileged - assumed that all devices will be
// included.