libnetwork: don't register "libnetwork-setkey" re-exec on non-unix
It's a no-op on Windows and other non-Linux, non-FreeBSD platforms, so there's no need to register the re-exec. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
881fff1a2f
commit
a813d7e961
4 changed files with 24 additions and 59 deletions
|
@ -1,12 +0,0 @@
|
|||
package libnetwork
|
||||
|
||||
import "github.com/docker/docker/pkg/reexec"
|
||||
|
||||
type setKeyData struct {
|
||||
ContainerID string
|
||||
Key string
|
||||
}
|
||||
|
||||
func init() {
|
||||
reexec.Register("libnetwork-setkey", processSetKeyReexec)
|
||||
}
|
|
@ -13,6 +13,7 @@ import (
|
|||
"path/filepath"
|
||||
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
"github.com/docker/docker/pkg/reexec"
|
||||
"github.com/docker/docker/pkg/stringid"
|
||||
"github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -24,6 +25,16 @@ const (
|
|||
success = "success"
|
||||
)
|
||||
|
||||
func init() {
|
||||
// TODO(thaJeztah): should this actually be registered on FreeBSD, or only on Linux?
|
||||
reexec.Register("libnetwork-setkey", processSetKeyReexec)
|
||||
}
|
||||
|
||||
type setKeyData struct {
|
||||
ContainerID string
|
||||
Key string
|
||||
}
|
||||
|
||||
// processSetKeyReexec is a private function that must be called only on an reexec path
|
||||
// It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <short-controller-id> }
|
||||
// It also expects specs.State as a json string in <stdin>
|
||||
|
@ -65,7 +76,8 @@ func setKey() error {
|
|||
func SetExternalKey(shortCtlrID string, containerID string, key string, execRoot string) error {
|
||||
keyData := setKeyData{
|
||||
ContainerID: containerID,
|
||||
Key: key}
|
||||
Key: key,
|
||||
}
|
||||
|
||||
uds := filepath.Join(execRoot, execSubdir, shortCtlrID+".sock")
|
||||
c, err := net.Dial("unix", uds)
|
||||
|
|
11
libnetwork/sandbox_externalkey_unsupported.go
Normal file
11
libnetwork/sandbox_externalkey_unsupported.go
Normal file
|
@ -0,0 +1,11 @@
|
|||
//go:build !linux && !freebsd
|
||||
// +build !linux,!freebsd
|
||||
|
||||
package libnetwork
|
||||
|
||||
// no-op on non linux systems
|
||||
func (c *Controller) startExternalKeyListener() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) stopExternalKeyListener() {}
|
|
@ -1,46 +0,0 @@
|
|||
//go:build windows
|
||||
// +build windows
|
||||
|
||||
package libnetwork
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net"
|
||||
|
||||
"github.com/docker/docker/libnetwork/types"
|
||||
)
|
||||
|
||||
// processSetKeyReexec is a private function that must be called only on an reexec path
|
||||
// It expects 3 args { [0] = "libnetwork-setkey", [1] = <container-id>, [2] = <controller-id> }
|
||||
// It also expects configs.HookState as a json string in <stdin>
|
||||
// Refer to https://github.com/opencontainers/runc/pull/160/ for more information
|
||||
func processSetKeyReexec() {
|
||||
}
|
||||
|
||||
// SetExternalKey provides a convenient way to set an External key to a sandbox
|
||||
func SetExternalKey(controllerID string, containerID string, key string) error {
|
||||
return types.NotImplementedErrorf("SetExternalKey isn't supported on non linux systems")
|
||||
}
|
||||
|
||||
func sendKey(c net.Conn, data setKeyData) error {
|
||||
return types.NotImplementedErrorf("sendKey isn't supported on non linux systems")
|
||||
}
|
||||
|
||||
func processReturn(r io.Reader) error {
|
||||
return types.NotImplementedErrorf("processReturn isn't supported on non linux systems")
|
||||
}
|
||||
|
||||
// no-op on non linux systems
|
||||
func (c *Controller) startExternalKeyListener() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Controller) acceptClientConnections(sock string, l net.Listener) {
|
||||
}
|
||||
|
||||
func (c *Controller) processExternalKey(conn net.Conn) error {
|
||||
return types.NotImplementedErrorf("processExternalKey isn't supported on non linux systems")
|
||||
}
|
||||
|
||||
func (c *Controller) stopExternalKeyListener() {
|
||||
}
|
Loading…
Add table
Reference in a new issue