From c81a9a2c885599cdf9f26ba92e0703ac753a0096 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A5=BA=E5=AD=90w=20=28Yumechi=29?= <35571479+eternal-flame-AD@users.noreply.github.com> Date: Fri, 22 Nov 2024 18:03:58 +0000 Subject: [PATCH] Set umask=0 when creating unix sockets (#743) Signed-off-by: eternal-flame-AD --- runner/runner.go | 3 +++ runner/umask.go | 7 +++++++ runner/umask_fallback.go | 7 +++++++ 3 files changed, 17 insertions(+) create mode 100644 runner/umask.go create mode 100644 runner/umask_fallback.go diff --git a/runner/runner.go b/runner/runner.go index 31e33cc7..4ddf1996 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -77,6 +77,9 @@ func startListening(connectionType, listenAddr string, port, keepAlive int) (net network, addr := getNetworkAndAddr(listenAddr, port) lc := net.ListenConfig{KeepAlive: time.Duration(keepAlive) * time.Second} + oldMask := umask(0) + defer umask(oldMask) + l, err := lc.Listen(context.Background(), network, addr) if err == nil { fmt.Println("Started listening for", connectionType, "on", l.Addr().Network(), l.Addr().String()) diff --git a/runner/umask.go b/runner/umask.go new file mode 100644 index 00000000..d25d7c76 --- /dev/null +++ b/runner/umask.go @@ -0,0 +1,7 @@ +//go:build unix + +package runner + +import "syscall" + +var umask = syscall.Umask diff --git a/runner/umask_fallback.go b/runner/umask_fallback.go new file mode 100644 index 00000000..4c5c2fb3 --- /dev/null +++ b/runner/umask_fallback.go @@ -0,0 +1,7 @@ +//go:build !unix + +package runner + +func umask(_ int) int { + return 0 +}