Skip to content

Commit 1223f59

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

File tree

4 files changed

+49
-17
lines changed

4 files changed

+49
-17
lines changed

config.md

Lines changed: 22 additions & 11 deletions
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

@@ -189,11 +192,15 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are
189192
"apparmorProfile": "acme_secure_profile",
190193
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
191194
"noNewPrivileges": true,
192-
"capabilities": [
193-
"CAP_AUDIT_WRITE",
194-
"CAP_KILL",
195-
"CAP_NET_BIND_SERVICE"
196-
],
195+
"capabilities": {
196+
"bounding": [
197+
"CAP_AUDIT_WRITE",
198+
"CAP_KILL",
199+
],
200+
"ambient": [
201+
"CAP_NET_BIND_SERVICE"
202+
]
203+
},
197204
"rlimits": [
198205
{
199206
"type": "RLIMIT_NOFILE",
@@ -443,11 +450,15 @@ Here is a full example `config.json` for reference.
443450
"TERM=xterm"
444451
],
445452
"cwd": "/",
446-
"capabilities": [
447-
"CAP_AUDIT_WRITE",
448-
"CAP_KILL",
449-
"CAP_NET_BIND_SERVICE"
450-
],
453+
"capabilities": {
454+
"bounding": [
455+
"CAP_AUDIT_WRITE",
456+
"CAP_KILL",
457+
],
458+
"ambient": [
459+
"CAP_NET_BIND_SERVICE"
460+
]
461+
},
451462
"rlimits": [
452463
{
453464
"type": "RLIMIT_CORE",

schema/config-schema.json

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,22 @@
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"
138+
"type": "object",
139+
"properties": {
140+
"bounding": {
141+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/bounding",
142+
"type": "array",
143+
"items": {
144+
"$ref": "defs-linux.json#/definitions/Capability"
145+
}
146+
},
147+
"ambient": {
148+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/ambient",
149+
"type": "array",
150+
"items": {
151+
"$ref": "defs-linux.json#/definitions/Capability"
152+
}
153+
}
141154
}
142155
},
143156
"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)