From ecb2ec9b069c1b29bdadf5e27f4845d3bf200269 Mon Sep 17 00:00:00 2001 From: Martin Dawson Date: Tue, 18 Dec 2018 23:28:48 +0000 Subject: [PATCH 1/2] added the log.warn for the ipc endpoint --- rpc/ipc_unix.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/rpc/ipc_unix.go b/rpc/ipc_unix.go index 0851ea61e16a..8b9a844a8341 100644 --- a/rpc/ipc_unix.go +++ b/rpc/ipc_unix.go @@ -23,10 +23,17 @@ import ( "net" "os" "path/filepath" + + "github.com/ethereum/go-ethereum/log" ) // ipcListen will create a Unix socket on the given endpoint. func ipcListen(endpoint string) (net.Listener, error) { + if len(endpoint) > 107 { + log.Warn("The ipc endpoint is longer than 107 characters and is restricted to this size by linux. "+ + "Shorten this path to less than 108 characters.", "endpoint", endpoint) + } + // Ensure the IPC path exists and remove any previous leftover if err := os.MkdirAll(filepath.Dir(endpoint), 0751); err != nil { return nil, err From e97307b8e05e3a622a143d23c71fd0ff1d281597 Mon Sep 17 00:00:00 2001 From: Guillaume Ballet Date: Wed, 2 Jan 2019 10:52:18 +0100 Subject: [PATCH 2/2] rpc: get max socket path length from OS headers --- rpc/ipc_unix.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/rpc/ipc_unix.go b/rpc/ipc_unix.go index 8b9a844a8341..707b47fd77a9 100644 --- a/rpc/ipc_unix.go +++ b/rpc/ipc_unix.go @@ -20,6 +20,7 @@ package rpc import ( "context" + "fmt" "net" "os" "path/filepath" @@ -27,11 +28,21 @@ import ( "github.com/ethereum/go-ethereum/log" ) +/* +#include + +int max_socket_path_size() { +struct sockaddr_un s; +return sizeof(s.sun_path); +} +*/ +import "C" + // ipcListen will create a Unix socket on the given endpoint. func ipcListen(endpoint string) (net.Listener, error) { - if len(endpoint) > 107 { - log.Warn("The ipc endpoint is longer than 107 characters and is restricted to this size by linux. "+ - "Shorten this path to less than 108 characters.", "endpoint", endpoint) + if len(endpoint) > int(C.max_socket_path_size()) { + log.Warn(fmt.Sprintf("The ipc endpoint is longer than %d characters. ", C.max_socket_path_size()), + "endpoint", endpoint) } // Ensure the IPC path exists and remove any previous leftover