Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support gitsign-credential-cache on Windows #579

Merged
merged 1 commit into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading