Make Unix socket permissions configurable

This commit is contained in:
Kristoffer Dalby 2022-01-28 18:58:22 +00:00
parent 4d60aeae18
commit b4f8961e44
5 changed files with 34 additions and 2 deletions

9
app.go
View file

@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"io"
"io/fs"
"net"
"net/http"
"net/url"
@ -95,7 +96,8 @@ type Config struct {
DNSConfig *tailcfg.DNSConfig
UnixSocket string
UnixSocket string
UnixSocketPermission fs.FileMode
OIDC OIDCConfig
@ -426,6 +428,11 @@ func (h *Headscale) Serve() error {
return fmt.Errorf("failed to set up gRPC socket: %w", err)
}
// Change socket permissions
if err := os.Chmod(h.cfg.UnixSocket, h.cfg.UnixSocketPermission); err != nil {
return fmt.Errorf("failed change permission of gRPC socket: %w", err)
}
// Handle common process-killing signals so we can gracefully shut down:
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt, syscall.SIGTERM)