socket: Enforce socket length

A Unix domain socket is limited to 107 usable bytes on Linux. However,
not all code creating socket paths was checking for this limits.

Created a new `utils.BuildSocketPath()` function (with tests) to
encapsulate the logic and updated all code creating sockets to use it.

Fixes #268.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt
2018-05-09 11:28:23 +01:00
parent f6544a3524
commit bce9edd277
12 changed files with 173 additions and 40 deletions

View File

@@ -739,12 +739,17 @@ func (h *hyper) register() error {
}
defer h.disconnect()
console, err := h.sandbox.hypervisor.getSandboxConsole(h.sandbox.id)
if err != nil {
return err
}
registerVMOptions := &proxyClient.RegisterVMOptions{
Console: h.sandbox.hypervisor.getSandboxConsole(h.sandbox.id),
Console: console,
NumIOStreams: 0,
}
_, err := h.client.RegisterVM(h.sandbox.id, h.sockets[0].HostPath,
_, err = h.client.RegisterVM(h.sandbox.id, h.sockets[0].HostPath,
h.sockets[1].HostPath, registerVMOptions)
return err
}