Skip to content

Commit e4e08fc

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

File tree

4 files changed

+70
-17
lines changed

4 files changed

+70
-17
lines changed

config.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,13 @@ 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+
* **`effective`** (array of strings, OPTIONAL) - the 'bounding' field is the whitelist of bounding capabilities that are kept for the process.
138+
* **`inheritable`** (array of strings, OPTIONAL) - the 'bounding' field is the whitelist of bounding capabilities that are kept for the process.
139+
* **`permitted`** (array of strings, OPTIONAL) - the 'bounding' field is the whitelist of bounding capabilities that are kept for the process.
140+
* **`ambient`** (array of strings, OPTIONAL) - the 'ambient' field is the whitelist of ambient capabilities that are kept for the process.
136141
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for a process inside the container.
137142
Each entry has the following structure:
138143

@@ -189,11 +194,15 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are
189194
"apparmorProfile": "acme_secure_profile",
190195
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
191196
"noNewPrivileges": true,
192-
"capabilities": [
193-
"CAP_AUDIT_WRITE",
194-
"CAP_KILL",
195-
"CAP_NET_BIND_SERVICE"
196-
],
197+
"capabilities": {
198+
"bounding": [
199+
"CAP_AUDIT_WRITE",
200+
"CAP_KILL",
201+
],
202+
"ambient": [
203+
"CAP_NET_BIND_SERVICE"
204+
]
205+
},
197206
"rlimits": [
198207
{
199208
"type": "RLIMIT_NOFILE",
@@ -443,11 +452,15 @@ Here is a full example `config.json` for reference.
443452
"TERM=xterm"
444453
],
445454
"cwd": "/",
446-
"capabilities": [
447-
"CAP_AUDIT_WRITE",
448-
"CAP_KILL",
449-
"CAP_NET_BIND_SERVICE"
450-
],
455+
"capabilities": {
456+
"bounding": [
457+
"CAP_AUDIT_WRITE",
458+
"CAP_KILL",
459+
],
460+
"ambient": [
461+
"CAP_NET_BIND_SERVICE"
462+
]
463+
},
451464
"rlimits": [
452465
{
453466
"type": "RLIMIT_CORE",

schema/config-schema.json

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,36 @@
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+
"permitted": {
141+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/permitted",
142+
"type": "array",
143+
"items": {
144+
"$ref": "defs-linux.json#/definitions/Capability"
145+
}
146+
},
147+
"effective": {
148+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/effective",
149+
"type": "array",
150+
"items": {
151+
"$ref": "defs-linux.json#/definitions/Capability"
152+
}
153+
},
154+
"inheritable": {
155+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/inheritable",
156+
"type": "array",
157+
"items": {
158+
"$ref": "defs-linux.json#/definitions/Capability"
159+
}
160+
},
161+
"ambient": {
162+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/ambient",
163+
"type": "array",
164+
"items": {
165+
"$ref": "defs-linux.json#/definitions/Capability"
166+
}
167+
}
141168
}
142169
},
143170
"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: 15 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,19 @@ 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+
// http://man7.org/linux/man-pages/man7/capabilities.7.html
61+
type LinuxCapabilities struct {
62+
// Effective is the set of capabilities checked by the kernel.
63+
Effective []string `json:"effective",omitempty" platform:"linux"`
64+
// Inheritable is the capabilities preserved across execve.
65+
Inheritable []string `json:"inheritable,omitempty" platform:"linux"`
66+
// Permitted is the limiting superset for effective capabilities.
67+
Permitted []string `json:"permitted,omitempty" platform:"linux"`
68+
// Ambient is the ambient set of capabilities that are kept.
69+
Ambient []string `json:"ambient,omitempty" platform:"linux"`
70+
}
71+
5972
// Box specifies dimensions of a rectangle. Used for specifying the size of a console.
6073
type Box struct {
6174
// Height is the vertical dimension of a box.

0 commit comments

Comments
 (0)