Set umask=0 when creating unix sockets (#743)

Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
饺子w (Yumechi) 2024-11-22 18:03:58 +00:00 committed by GitHub
parent cc7da2ace3
commit c81a9a2c88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 0 deletions

View File

@ -77,6 +77,9 @@ func startListening(connectionType, listenAddr string, port, keepAlive int) (net
network, addr := getNetworkAndAddr(listenAddr, port) network, addr := getNetworkAndAddr(listenAddr, port)
lc := net.ListenConfig{KeepAlive: time.Duration(keepAlive) * time.Second} lc := net.ListenConfig{KeepAlive: time.Duration(keepAlive) * time.Second}
oldMask := umask(0)
defer umask(oldMask)
l, err := lc.Listen(context.Background(), network, addr) l, err := lc.Listen(context.Background(), network, addr)
if err == nil { if err == nil {
fmt.Println("Started listening for", connectionType, "on", l.Addr().Network(), l.Addr().String()) fmt.Println("Started listening for", connectionType, "on", l.Addr().Network(), l.Addr().String())

7
runner/umask.go Normal file
View File

@ -0,0 +1,7 @@
//go:build unix
package runner
import "syscall"
var umask = syscall.Umask

7
runner/umask_fallback.go Normal file
View File

@ -0,0 +1,7 @@
//go:build !unix
package runner
func umask(_ int) int {
return 0
}