Skip to content

Commit

Permalink
Set umask=0 when creating unix sockets (#743)
Browse files Browse the repository at this point in the history
Signed-off-by: eternal-flame-AD <[email protected]>
  • Loading branch information
eternal-flame-AD authored Nov 22, 2024
1 parent cc7da2a commit c81a9a2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
7 changes: 7 additions & 0 deletions runner/umask.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build unix

package runner

import "syscall"

var umask = syscall.Umask
7 changes: 7 additions & 0 deletions runner/umask_fallback.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !unix

package runner

func umask(_ int) int {
return 0
}

0 comments on commit c81a9a2

Please sign in to comment.