Browse Source

Merge pull request #30014 from tiborvass/plugin-devices-redone-master

Plugins: Rename DeviceCreation to AllowAllDevices
Tibor Vass 8 years ago
parent
commit
696ef7a19e
5 changed files with 17 additions and 13 deletions
  1. 4 4
      api/swagger.yaml
  2. 4 4
      api/types/plugin.go
  3. 5 1
      docs/extend/config.md
  4. 3 3
      plugin/backend_linux.go
  5. 1 1
      plugin/v2/plugin_linux.go

+ 4 - 4
api/swagger.yaml

@@ -1444,13 +1444,13 @@ definitions:
           Linux:
           Linux:
             type: "object"
             type: "object"
             x-nullable: false
             x-nullable: false
-            required: [Capabilities, DeviceCreation, Devices]
+            required: [Capabilities, AllowAllDevices, Devices]
             properties:
             properties:
               Capabilities:
               Capabilities:
                 type: "array"
                 type: "array"
                 items:
                 items:
                   type: "string"
                   type: "string"
-              DeviceCreation:
+              AllowAllDevices:
                 type: "boolean"
                 type: "boolean"
                 x-nullable: false
                 x-nullable: false
               Devices:
               Devices:
@@ -1522,7 +1522,7 @@ definitions:
           Type: ""
           Type: ""
         Linux:
         Linux:
           Capabilities: null
           Capabilities: null
-          DeviceCreation: false
+          AllowAllDevices: false
           Devices: null
           Devices: null
         Mounts: null
         Mounts: null
         PropagatedMount: "/data"
         PropagatedMount: "/data"
@@ -6364,7 +6364,7 @@ paths:
                     Type: ""
                     Type: ""
                   Linux:
                   Linux:
                     Capabilities: null
                     Capabilities: null
-                    DeviceCreation: false
+                    AllowAllDevices: false
                     Devices: null
                     Devices: null
                   Mounts: null
                   Mounts: null
                   PropagatedMount: "/data"
                   PropagatedMount: "/data"

+ 4 - 4
api/types/plugin.go

@@ -120,13 +120,13 @@ type PluginConfigInterface struct {
 // swagger:model PluginConfigLinux
 // swagger:model PluginConfigLinux
 type PluginConfigLinux struct {
 type PluginConfigLinux struct {
 
 
-	// capabilities
+	// allow all devices
 	// Required: true
 	// Required: true
-	Capabilities []string `json:"Capabilities"`
+	AllowAllDevices bool `json:"AllowAllDevices"`
 
 
-	// device creation
+	// capabilities
 	// Required: true
 	// Required: true
-	DeviceCreation bool `json:"DeviceCreation"`
+	Capabilities []string `json:"Capabilities"`
 
 
 	// devices
 	// devices
 	// Required: true
 	// Required: true

+ 5 - 1
docs/extend/config.md

@@ -153,6 +153,10 @@ Config provides the base accessible fields for working with V0 plugin format
 
 
           capabilities of the plugin (*Linux only*), see list [`here`](https://github.com/opencontainers/runc/blob/master/libcontainer/SPEC.md#security)
           capabilities of the plugin (*Linux only*), see list [`here`](https://github.com/opencontainers/runc/blob/master/libcontainer/SPEC.md#security)
 
 
+    - **`allowAllDevices`** *boolean*
+
+	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.
+
     - **`devices`** *PluginDevice array*
     - **`devices`** *PluginDevice array*
 
 
           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)
           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
             },
             },
             "Linux": {
             "Linux": {
                 "Capabilities": null,
                 "Capabilities": null,
-                "DeviceCreation": false,
+                "AllowAllDevices": false,
                 "Devices": null
                 "Devices": null
             },
             },
             "Mounts": null,
             "Mounts": null,

+ 3 - 3
plugin/backend_linux.go

@@ -159,10 +159,10 @@ func computePrivileges(c types.PluginConfig) (types.PluginPrivileges, error) {
 			})
 			})
 		}
 		}
 	}
 	}
-	if c.Linux.DeviceCreation {
+	if c.Linux.AllowAllDevices {
 		privileges = append(privileges, types.PluginPrivilege{
 		privileges = append(privileges, types.PluginPrivilege{
-			Name:        "device-creation",
-			Description: "allow creating devices inside plugin",
+			Name:        "allow-all-devices",
+			Description: "allow 'rwm' access to all devices",
 			Value:       []string{"true"},
 			Value:       []string{"true"},
 		})
 		})
 	}
 	}

+ 1 - 1
plugin/v2/plugin_linux.go

@@ -87,7 +87,7 @@ func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) {
 		s.Linux.RootfsPropagation = "rshared"
 		s.Linux.RootfsPropagation = "rshared"
 	}
 	}
 
 
-	if p.PluginObj.Config.Linux.DeviceCreation {
+	if p.PluginObj.Config.Linux.AllowAllDevices {
 		rwm := "rwm"
 		rwm := "rwm"
 		s.Linux.Resources.Devices = []specs.DeviceCgroup{{Allow: true, Access: &rwm}}
 		s.Linux.Resources.Devices = []specs.DeviceCgroup{{Allow: true, Access: &rwm}}
 	}
 	}