Skip to content

Commit

Permalink
Support gitsign-credential-cache on Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Aditya Sirish A Yelgundhalli <[email protected]>
  • Loading branch information
adityasaky committed Oct 18, 2024
1 parent 1b11c27 commit 9549acd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ builds:
- linux
- darwin
- freebsd
# - windows # TODO: fix undefined: syscall.Umask for windows builds
- windows
goarch:
- amd64
- arm64
Expand Down
14 changes: 10 additions & 4 deletions cmd/gitsign-credential-cache/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"net/rpc"
"os"
"path/filepath"
"syscall"

"github.com/coreos/go-systemd/v22/activation"
"github.com/spf13/pflag"
Expand All @@ -38,9 +37,6 @@ var (

func main() {
pflag.Parse()
// Override default umask so created files are always scoped to the
// current user.
syscall.Umask(0077)

if *versionFlag {
v := version.GetVersionInfo()
Expand Down Expand Up @@ -93,6 +89,16 @@ func main() {
if err != nil {
log.Fatalf("error opening socket: %v", err)
}

// Previously, we used syscall.Umask(0077) to ensure this was
// permissioned only to the current user. Windows doesn't have this
// syscall, so we're switching over to an explicit Chmod on the socket
// path.
// Also see https://github.com/golang/go/issues/11822
if err := os.Chmod(path, 0700); err != nil {
log.Fatalf("error setting socket permissions: %v", err)
}

go connToChan(l, connChan)
}
srv := rpc.NewServer()
Expand Down

0 comments on commit 9549acd

Please sign in to comment.