aboutsummaryrefslogtreecommitdiffstats
path: root/rpc
diff options
context:
space:
mode:
authorMartin Alex Philip Dawson <u1356770@gmail.com>2019-01-03 00:33:17 +0800
committerGuillaume Ballet <gballet@gmail.com>2019-01-03 00:33:17 +0800
commitb025053ab03b2e19aee28505029954ca9d158b1d (patch)
tree08cf0f357f88e69c7de1c20489c21bec3cd9e7b3 /rpc
parent9bfd0b60cc5af3d6b8fdd9fae33ec1c0a4eb31b8 (diff)
downloaddexon-b025053ab03b2e19aee28505029954ca9d158b1d.tar.gz
dexon-b025053ab03b2e19aee28505029954ca9d158b1d.tar.zst
dexon-b025053ab03b2e19aee28505029954ca9d158b1d.zip
rpc: Warn the user when the path name is too long for the Unix ipc endpoint (#18330)
Diffstat (limited to 'rpc')
-rw-r--r--rpc/ipc_unix.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/rpc/ipc_unix.go b/rpc/ipc_unix.go
index 0851ea61e..707b47fd7 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 <sys/un.h>
+
+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