diff --git a/rpc/ipc_unix.go b/rpc/ipc_unix.go index 0851ea61e16ac320d5991510713273e169323298..707b47fd77a9a2542d1d897aa70903c9c8b09ba0 100644 --- a/rpc/ipc_unix.go +++ b/rpc/ipc_unix.go @@ -20,13 +20,31 @@ package rpc import ( "context" + "fmt" "net" "os" "path/filepath" + + "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) > 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 if err := os.MkdirAll(filepath.Dir(endpoint), 0751); err != nil { return nil, err