Skip to content

Commit 110d793

Browse files
committed
Add ambient and bounding capability support
Closes opencontainers#668 Signed-off-by: Michael Crosby <[email protected]>
1 parent 3297cd5 commit 110d793

File tree

4 files changed

+26
-8
lines changed

4 files changed

+26
-8
lines changed

config.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,11 @@ See links for details about [mountvol](http://ss64.com/nt/mountvol.html) and [Se
131131

132132
For Linux-based systems the process structure supports the following process specific fields:
133133

134-
* **`capabilities`** (array of strings, OPTIONAL) capabilities is an array that specifies Linux capabilities that can be provided to the process inside the container.
134+
* **`capabilities`** (object, OPTIONAL) capabilities is a whitelist of capabilities for the bounding and ambient sets for Linux processes.
135135
Valid values are the strings for capabilities defined in [the man page](http://man7.org/linux/man-pages/man7/capabilities.7.html).
136+
capabilities contains the following properties:
137+
* **`bounding`** (array of strings, OPTIONAL) - the 'bounding' field is the whitelist of bounding capabilities that are kept for the process.
138+
* **`ambient`** (array of strings, OPTIONAL) - the 'ambient' field is the whitelist of ambient capabilities that are kept for the process.
136139
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for a process inside the container.
137140
Each entry has the following structure:
138141

schema/config-schema.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,17 @@
135135
},
136136
"capabilities": {
137137
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities",
138-
"type": "array",
139-
"items": {
140-
"$ref": "defs-linux.json#/definitions/Capability"
141-
}
138+
"type": "object",
139+
"properties": {
140+
"bounding": {
141+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/bounding",
142+
"$ref": "defs-linux.json#/definitions/Capability"
143+
},
144+
"ambient": {
145+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/ambient",
146+
"$ref": "defs-linux.json#/definitions/Capability"
147+
}
148+
}
142149
},
143150
"apparmorProfile": {
144151
"id": "https://opencontainers.org/schema/bundle/process/linux/apparmorProfile",

schema/defs-linux.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
}
7979
},
8080
"Capability": {
81-
"description": "Linux process permissions",
81+
"description": "Linux process capabilities",
8282
"type": "string",
8383
"pattern": "^CAP_([A-Z]|_)+$"
8484
},

specs-go/config.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ type Process struct {
4444
// Cwd is the current working directory for the process and must be
4545
// relative to the container's root.
4646
Cwd string `json:"cwd"`
47-
// Capabilities are Linux capabilities that are kept for the container.
48-
Capabilities []string `json:"capabilities,omitempty" platform:"linux"`
47+
// Capabilities are Linux capabilities that are kept for the process.
48+
Capabilities *LinuxCapabilities `json:"capabilities,omitempty" platform:"linux"`
4949
// Rlimits specifies rlimit options to apply to the process.
5050
Rlimits []LinuxRlimit `json:"rlimits,omitempty" platform:"linux"`
5151
// NoNewPrivileges controls whether additional privileges could be gained by processes in the container.
@@ -56,6 +56,14 @@ type Process struct {
5656
SelinuxLabel string `json:"selinuxLabel,omitempty" platform:"linux"`
5757
}
5858

59+
// LinuxCapabilities specifies the whitelist of capabilities that are kept for a process.
60+
type LinuxCapabilities struct {
61+
// Bounding is the bounding set of capabilities that are kept.
62+
Bounding []string `json:"bounding,omitempty" platform:"linux"`
63+
// Ambient are the ambient set of capabilities that are kept.
64+
Ambient []string `json:"ambient,omitempty" platform:"linux"`
65+
}
66+
5967
// Box specifies dimensions of a rectangle. Used for specifying the size of a console.
6068
type Box struct {
6169
// Height is the vertical dimension of a box.

0 commit comments

Comments
 (0)