Skip to content

Commit

Permalink
Set umask=0 when creating unix sockets
Browse files Browse the repository at this point in the history
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
  • Loading branch information
eternal-flame-AD committed Nov 22, 2024
1 parent cc7da2a commit a9731fd
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
@@ -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)

Check warning on line 82 in runner/runner.go

Codecov / codecov/patch

runner/runner.go#L80-L82

Added lines #L80 - L82 were not covered by tests
l, err := lc.Listen(context.Background(), network, addr)
if err == nil {
fmt.Println("Started listening for", connectionType, "on", l.Addr().Network(), l.Addr().String())
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 a9731fd

Please sign in to comment.