Skip to content

Commit b26f15e

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

File tree

4 files changed

+80
-17
lines changed

4 files changed

+80
-17
lines changed

config.md

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,13 @@ For Windows, see links for details about [mountvol](http://ss64.com/nt/mountvol.
131131
* **`env`** (array of strings, OPTIONAL) with the same semantics as [IEEE Std 1003.1-2001's `environ`][ieee-1003.1-2001-xbd-c8.1].
132132
* **`args`** (array of strings, REQUIRED) with similar semantics to [IEEE Std 1003.1-2001 `execvp`'s *argv*][ieee-1003.1-2001-xsh-exec].
133133
This specification extends the IEEE standard in that at least one entry is REQUIRED, and that entry is used with the same semantics as `execvp`'s *file*.
134-
* **`capabilities`** (array of strings, OPTIONAL) is an array that specifies the set of capabilities of the process(es) inside the container. Valid values are platform-specific. For example, valid values for Linux are defined in the [CAPABILITIES(7)](http://man7.org/linux/man-pages/man7/capabilities.7.html) man page.
134+
* **`capabilities`** (object of strings, OPTIONAL) is an array that specifies the set of capabilities of the process(es) inside the container. Valid values are platform-specific. For example, valid values for Linux are defined in the [CAPABILITIES(7)](http://man7.org/linux/man-pages/man7/capabilities.7.html) man page.
135+
capabilities contains the following properties:
136+
* **`effective`** (array of strings, OPTIONAL) - the 'effective' field is the whitelist of effective capabilities that are kept for the process.
137+
* **`bounding`** (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 'inheritable' field is the whitelist of inheritable capabilities that are kept for the process.
139+
* **`permitted`** (array of strings, OPTIONAL) - the 'permitted' field is the whitelist of permitted 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.
135141
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for a process inside the container.
136142
Each entry has the following structure:
137143

@@ -190,11 +196,15 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are
190196
"apparmorProfile": "acme_secure_profile",
191197
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
192198
"noNewPrivileges": true,
193-
"capabilities": [
194-
"CAP_AUDIT_WRITE",
195-
"CAP_KILL",
196-
"CAP_NET_BIND_SERVICE"
197-
],
199+
"capabilities": {
200+
"bounding": [
201+
"CAP_AUDIT_WRITE",
202+
"CAP_KILL",
203+
],
204+
"ambient": [
205+
"CAP_NET_BIND_SERVICE"
206+
]
207+
},
198208
"rlimits": [
199209
{
200210
"type": "RLIMIT_NOFILE",
@@ -445,11 +455,15 @@ Here is a full example `config.json` for reference.
445455
"TERM=xterm"
446456
],
447457
"cwd": "/",
448-
"capabilities": [
449-
"CAP_AUDIT_WRITE",
450-
"CAP_KILL",
451-
"CAP_NET_BIND_SERVICE"
452-
],
458+
"capabilities": {
459+
"bounding": [
460+
"CAP_AUDIT_WRITE",
461+
"CAP_KILL",
462+
],
463+
"ambient": [
464+
"CAP_NET_BIND_SERVICE"
465+
]
466+
},
453467
"rlimits": [
454468
{
455469
"type": "RLIMIT_CORE",

schema/config-schema.json

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,43 @@
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+
"permitted": {
148+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/permitted",
149+
"type": "array",
150+
"items": {
151+
"$ref": "defs-linux.json#/definitions/Capability"
152+
}
153+
},
154+
"effective": {
155+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/effective",
156+
"type": "array",
157+
"items": {
158+
"$ref": "defs-linux.json#/definitions/Capability"
159+
}
160+
},
161+
"inheritable": {
162+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/inheritable",
163+
"type": "array",
164+
"items": {
165+
"$ref": "defs-linux.json#/definitions/Capability"
166+
}
167+
},
168+
"ambient": {
169+
"id": "https://opencontainers.org/schema/bundle/process/linux/capabilities/ambient",
170+
"type": "array",
171+
"items": {
172+
"$ref": "defs-linux.json#/definitions/Capability"
173+
}
174+
}
141175
}
142176
},
143177
"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: 17 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,21 @@ 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+
// Bounding is the set of capabilities checked by the kernel.
63+
Bounding []string `json:"bounding",omitempty" platform:"linux"`
64+
// Effective is the set of capabilities checked by the kernel.
65+
Effective []string `json:"effective",omitempty" platform:"linux"`
66+
// Inheritable is the capabilities preserved across execve.
67+
Inheritable []string `json:"inheritable,omitempty" platform:"linux"`
68+
// Permitted is the limiting superset for effective capabilities.
69+
Permitted []string `json:"permitted,omitempty" platform:"linux"`
70+
// Ambient is the ambient set of capabilities that are kept.
71+
Ambient []string `json:"ambient,omitempty" platform:"linux"`
72+
}
73+
5974
// Box specifies dimensions of a rectangle. Used for specifying the size of a console.
6075
type Box struct {
6176
// Height is the vertical dimension of a box.

0 commit comments

Comments
 (0)