Skip to content

Commit

Permalink
uidMappings: change order of fields for clarity
Browse files Browse the repository at this point in the history
"man 7 user_namespaces" explains the format of uid_map and gid_map:
    <containerID> <hostID> <mapSize>

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 <alban@kinvolk.io>
  • Loading branch information
alban committed Mar 8, 2018
1 parent fa4b36a commit cd39042
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions config-linux.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
]
Expand Down
4 changes: 2 additions & 2 deletions config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
],
Expand Down
6 changes: 3 additions & 3 deletions schema/defs.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@
"IDMapping": {
"type": "object",
"properties": {
"hostID": {
"containerID": {
"$ref": "#/definitions/uint32"
},
"containerID": {
"hostID": {
"$ref": "#/definitions/uint32"
},
"size": {
"$ref": "#/definitions/uint32"
}
},
"required": [
"hostID",
"containerID",
"hostID",
"size"
]
},
Expand Down
4 changes: 2 additions & 2 deletions schema/test/config/good/spec-example.json
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@
],
"uidMappings": [
{
"hostID": 1000,
"containerID": 0,
"hostID": 1000,
"size": 32000
}
],
"gidMappings": [
{
"hostID": 1000,
"containerID": 0,
"hostID": 1000,
"size": 32000
}
],
Expand Down
4 changes: 2 additions & 2 deletions specs-go/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down

0 comments on commit cd39042

Please sign in to comment.