mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add pid host support
Tested using global-net-plugin-ipc which sets PidHost in config.json. Plugins might need access to host pid namespace. Add support for that. Tested using aragunathan/global-net-plugin-ipc which sets "pidhost" in config.json. Observed using `readlink /proc/self/ns/pid` that plugin and host have the same ns. Signed-off-by: Anusha Ragunathan <anusha.ragunathan@docker.com>
This commit is contained in:
parent
6d6185c257
commit
4d1edcb2cc
5 changed files with 20 additions and 0 deletions
|
@ -1445,6 +1445,7 @@ definitions:
|
|||
- WorkDir
|
||||
- Network
|
||||
- Linux
|
||||
- PidHost
|
||||
- PropagatedMount
|
||||
- IpcHost
|
||||
- Mounts
|
||||
|
@ -1517,6 +1518,9 @@ definitions:
|
|||
IpcHost:
|
||||
type: "boolean"
|
||||
x-nullable: false
|
||||
PidHost:
|
||||
type: "boolean"
|
||||
x-nullable: false
|
||||
Mounts:
|
||||
type: "array"
|
||||
items:
|
||||
|
|
|
@ -74,6 +74,10 @@ type PluginConfig struct {
|
|||
// Required: true
|
||||
Network PluginConfigNetwork `json:"Network"`
|
||||
|
||||
// pid host
|
||||
// Required: true
|
||||
PidHost bool `json:"PidHost"`
|
||||
|
||||
// propagated mount
|
||||
// Required: true
|
||||
PropagatedMount string `json:"PropagatedMount"`
|
||||
|
|
|
@ -117,6 +117,8 @@ Config provides the base accessible fields for working with V0 plugin format
|
|||
|
||||
- **`ipchost`** *boolean*
|
||||
Access to host ipc namespace.
|
||||
- **`pidhost`** *boolean*
|
||||
Access to host pid namespace.
|
||||
|
||||
- **`propagatedMount`** *string*
|
||||
|
||||
|
|
|
@ -157,6 +157,13 @@ func computePrivileges(c types.PluginConfig) (types.PluginPrivileges, error) {
|
|||
Value: []string{"true"},
|
||||
})
|
||||
}
|
||||
if c.PidHost {
|
||||
privileges = append(privileges, types.PluginPrivilege{
|
||||
Name: "host pid namespace",
|
||||
Description: "allow access to host pid namespace",
|
||||
Value: []string{"true"},
|
||||
})
|
||||
}
|
||||
for _, mount := range c.Mounts {
|
||||
if mount.Source != nil {
|
||||
privileges = append(privileges, types.PluginPrivilege{
|
||||
|
|
|
@ -60,6 +60,9 @@ func (p *Plugin) InitSpec(execRoot string) (*specs.Spec, error) {
|
|||
Options: []string{"rbind", "ro"},
|
||||
})
|
||||
}
|
||||
if p.PluginObj.Config.PidHost {
|
||||
oci.RemoveNamespace(&s, specs.NamespaceType("pid"))
|
||||
}
|
||||
|
||||
if p.PluginObj.Config.IpcHost {
|
||||
oci.RemoveNamespace(&s, specs.NamespaceType("ipc"))
|
||||
|
|
Loading…
Reference in a new issue