Skip to content

Commit 359352a

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

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,7 +131,12 @@ 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+
* **`inheritable`** (array of strings, OPTIONAL) - the 'inheritable' field is the whitelist of inheritable capabilities that are kept for the process.
138+
* **`permitted`** (array of strings, OPTIONAL) - the 'permitted' field is the whitelist of permitted capabilities that are kept for the process.
139+
* **`ambient`** (array of strings, OPTIONAL) - the 'ambient' field is the whitelist of ambient capabilities that are kept for the process.
135140
* **`rlimits`** (array of objects, OPTIONAL) allows setting resource limits for a process inside the container.
136141
Each entry has the following structure:
137142

@@ -190,11 +195,15 @@ _Note: symbolic name for uid and gid, such as uname and gname respectively, are
190195
"apparmorProfile": "acme_secure_profile",
191196
"selinuxLabel": "system_u:system_r:svirt_lxc_net_t:s0:c124,c675",
192197
"noNewPrivileges": true,
193-
"capabilities": [
194-
"CAP_AUDIT_WRITE",
195-
"CAP_KILL",
196-
"CAP_NET_BIND_SERVICE"
197-
],
198+
"capabilities": {
199+
"bounding": [
200+
"CAP_AUDIT_WRITE",
201+
"CAP_KILL",
202+
],
203+
"ambient": [
204+
"CAP_NET_BIND_SERVICE"
205+
]
206+
},
198207
"rlimits": [
199208
{
200209
"type": "RLIMIT_NOFILE",
@@ -445,11 +454,15 @@ Here is a full example `config.json` for reference.
445454
"TERM=xterm"
446455
],
447456
"cwd": "/",
448-
"capabilities": [
449-
"CAP_AUDIT_WRITE",
450-
"CAP_KILL",
451-
"CAP_NET_BIND_SERVICE"
452-
],
457+
"capabilities": {
458+
"bounding": [
459+
"CAP_AUDIT_WRITE",
460+
"CAP_KILL",
461+
],
462+
"ambient": [
463+
"CAP_NET_BIND_SERVICE"
464+
]
465+
},
453466
"rlimits": [
454467
{
455468
"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)