Skip to content

Commit

Permalink
PR comments - Set default socket mode to current umask
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan971 committed Mar 4, 2024
1 parent 2fc09dd commit 33b75b4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os"
"strconv"
"strings"
"syscall"
"time"

"github.com/oauth2-proxy/oauth2-proxy/v7/pkg/apis/options"
Expand Down Expand Up @@ -97,7 +98,12 @@ func setupUnixSocketListener(networkType string, address string) (net.Listener,
}

socketPath := socketOpts[0]
socketMode := os.FileMode(0o644)

// must set umask to find out the previous value, so we set-store-reset it
currentUmask := syscall.Umask(0o777)
syscall.Umask(currentUmask)
socketMode := os.FileMode(currentUmask)

for _, socketOpt := range socketOpts[1:] {
socketOpt := strings.SplitN(socketOpt, "=", 2)
if len(socketOpt) != 2 {
Expand Down

0 comments on commit 33b75b4

Please sign in to comment.