From cd39042c5916a81eae108ca3e09aa2e536b07fe2 Mon Sep 17 00:00:00 2001 From: Alban Crequy Date: Thu, 8 Mar 2018 19:36:52 +0100 Subject: [PATCH] uidMappings: change order of fields for clarity "man 7 user_namespaces" explains the format of uid_map and gid_map: The order of map entries in JSON does not matter. But for the clarity of the spec, I find it easier to understand if the order of the JSON fields is the same as the order of the fields in the underlying uid_map/gid_map files. I am about to file a PR in runtime-tools because the fields in uid_map/gid_map were parsed in the wrong order. Signed-off-by: Alban Crequy --- config-linux.md | 6 +++--- config.md | 4 ++-- schema/defs.json | 6 +++--- schema/test/config/good/spec-example.json | 4 ++-- specs-go/config.go | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/config-linux.md b/config-linux.md index e33cea5b7..df974df12 100644 --- a/config-linux.md +++ b/config-linux.md @@ -82,8 +82,8 @@ If a `namespaces` field contains duplicated namespaces with same `type`, the run Each entry has the following structure: -* **`hostID`** *(uint32, REQUIRED)* - is the starting uid/gid on the host to be mapped to *containerID*. * **`containerID`** *(uint32, REQUIRED)* - is the starting uid/gid in the container. +* **`hostID`** *(uint32, REQUIRED)* - is the starting uid/gid on the host to be mapped to *containerID*. * **`size`** *(uint32, REQUIRED)* - is the number of ids to be mapped. The runtime SHOULD NOT modify the ownership of referenced filesystems to realize the mapping. @@ -94,15 +94,15 @@ Note that the number of mapping entries MAY be limited by the [kernel][user-name ```json "uidMappings": [ { - "hostID": 1000, "containerID": 0, + "hostID": 1000, "size": 32000 } ], "gidMappings": [ { - "hostID": 1000, "containerID": 0, + "hostID": 1000, "size": 32000 } ] diff --git a/config.md b/config.md index 06801f5dd..333b98300 100644 --- a/config.md +++ b/config.md @@ -664,15 +664,15 @@ Here is a full example `config.json` for reference. ], "uidMappings": [ { - "hostID": 1000, "containerID": 0, + "hostID": 1000, "size": 32000 } ], "gidMappings": [ { - "hostID": 1000, "containerID": 0, + "hostID": 1000, "size": 32000 } ], diff --git a/schema/defs.json b/schema/defs.json index 377ec6d9f..c1533aede 100644 --- a/schema/defs.json +++ b/schema/defs.json @@ -108,10 +108,10 @@ "IDMapping": { "type": "object", "properties": { - "hostID": { + "containerID": { "$ref": "#/definitions/uint32" }, - "containerID": { + "hostID": { "$ref": "#/definitions/uint32" }, "size": { @@ -119,8 +119,8 @@ } }, "required": [ - "hostID", "containerID", + "hostID", "size" ] }, diff --git a/schema/test/config/good/spec-example.json b/schema/test/config/good/spec-example.json index c7db729bd..c1390c379 100644 --- a/schema/test/config/good/spec-example.json +++ b/schema/test/config/good/spec-example.json @@ -194,15 +194,15 @@ ], "uidMappings": [ { - "hostID": 1000, "containerID": 0, + "hostID": 1000, "size": 32000 } ], "gidMappings": [ { - "hostID": 1000, "containerID": 0, + "hostID": 1000, "size": 32000 } ], diff --git a/specs-go/config.go b/specs-go/config.go index 841eacb2d..ad265bf2c 100644 --- a/specs-go/config.go +++ b/specs-go/config.go @@ -194,10 +194,10 @@ const ( // LinuxIDMapping specifies UID/GID mappings type LinuxIDMapping struct { - // HostID is the starting UID/GID on the host to be mapped to 'ContainerID' - HostID uint32 `json:"hostID"` // ContainerID is the starting UID/GID in the container ContainerID uint32 `json:"containerID"` + // HostID is the starting UID/GID on the host to be mapped to 'ContainerID' + HostID uint32 `json:"hostID"` // Size is the number of IDs to be mapped Size uint32 `json:"size"` }