Browse code

plugins: rename DeviceCreation to AllowAllDevices

Signed-off-by: Tibor Vass <tibor@docker.com>

Tibor Vass authored on 2017/01/11 04:00:57
Showing 5 changed files
... ...
@@ -1444,13 +1444,13 @@ definitions:
1444 1444
           Linux:
1445 1445
             type: "object"
1446 1446
             x-nullable: false
1447
-            required: [Capabilities, DeviceCreation, Devices]
1447
+            required: [Capabilities, AllowAllDevices, Devices]
1448 1448
             properties:
1449 1449
               Capabilities:
1450 1450
                 type: "array"
1451 1451
                 items:
1452 1452
                   type: "string"
1453
-              DeviceCreation:
1453
+              AllowAllDevices:
1454 1454
                 type: "boolean"
1455 1455
                 x-nullable: false
1456 1456
               Devices:
... ...
@@ -1522,7 +1522,7 @@ definitions:
1522 1522
           Type: ""
1523 1523
         Linux:
1524 1524
           Capabilities: null
1525
-          DeviceCreation: false
1525
+          AllowAllDevices: false
1526 1526
           Devices: null
1527 1527
         Mounts: null
1528 1528
         PropagatedMount: "/data"
... ...
@@ -6364,7 +6364,7 @@ paths:
6364 6364
                     Type: ""
6365 6365
                   Linux:
6366 6366
                     Capabilities: null
6367
-                    DeviceCreation: false
6367
+                    AllowAllDevices: false
6368 6368
                     Devices: null
6369 6369
                   Mounts: null
6370 6370
                   PropagatedMount: "/data"
... ...
@@ -120,13 +120,13 @@ type PluginConfigInterface struct {
120 120
 // swagger:model PluginConfigLinux
121 121
 type PluginConfigLinux struct {
122 122
 
123
-	// capabilities
123
+	// allow all devices
124 124
 	// Required: true
125
-	Capabilities []string `json:"Capabilities"`
125
+	AllowAllDevices bool `json:"AllowAllDevices"`
126 126
 
127
-	// device creation
127
+	// capabilities
128 128
 	// Required: true
129
-	DeviceCreation bool `json:"DeviceCreation"`
129
+	Capabilities []string `json:"Capabilities"`
130 130
 
131 131
 	// devices
132 132
 	// Required: true
... ...
@@ -153,6 +153,10 @@ Config provides the base accessible fields for working with V0 plugin format
153 153
 
154 154
           capabilities of the plugin (*Linux only*), see list [`here`](https://github.com/opencontainers/runc/blob/master/libcontainer/SPEC.md#security)
155 155
 
156
+    - **`allowAllDevices`** *boolean*
157
+
158
+	If `/dev` is bind mounted from the host, and allowAllDevices is set to true, the plugin will have `rwm` access to all devices on the host.
159
+
156 160
     - **`devices`** *PluginDevice array*
157 161
 
158 162
           device of the plugin, (*Linux only*), struct consisting of the following fields, see [`DEVICES`](https://github.com/opencontainers/runtime-spec/blob/master/config-linux.md#devices)
... ...
@@ -205,7 +209,7 @@ Config provides the base accessible fields for working with V0 plugin format
205 205
             },
206 206
             "Linux": {
207 207
                 "Capabilities": null,
208
-                "DeviceCreation": false,
208
+                "AllowAllDevices": false,
209 209
                 "Devices": null
210 210
             },
211 211
             "Mounts": null,
... ...
@@ -159,10 +159,10 @@ func computePrivileges(c types.PluginConfig) (types.PluginPrivileges, error) {
159 159
 			})
160 160
 		}
161 161
 	}
162
-	if c.Linux.DeviceCreation {
162
+	if c.Linux.AllowAllDevices {
163 163
 		privileges = append(privileges, types.PluginPrivilege{
164
-			Name:        "device-creation",
165
-			Description: "allow creating devices inside plugin",
164
+			Name:        "allow-all-devices",
165
+			Description: "allow 'rwm' access to all devices",
166 166
 			Value:       []string{"true"},
167 167
 		})
168 168
 	}
... ...
@@ -87,7 +87,7 @@ func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) {
87 87
 		s.Linux.RootfsPropagation = "rshared"
88 88
 	}
89 89
 
90
-	if p.PluginObj.Config.Linux.DeviceCreation {
90
+	if p.PluginObj.Config.Linux.AllowAllDevices {
91 91
 		rwm := "rwm"
92 92
 		s.Linux.Resources.Devices = []specs.DeviceCgroup{{Allow: true, Access: &rwm}}
93 93
 	}