From a9731fda8509a641b694937a60c2bea70d2d77eb Mon Sep 17 00:00:00 2001 From: eternal-flame-AD Date: Fri, 22 Nov 2024 11:42:48 -0600 Subject: [PATCH] Set umask=0 when creating unix sockets 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 +}