feat: add --socket-perm option for UNIX socket file permissions

Add a --socket-perm flag (VGW_SOCKET_PERM env var) to control the
file-mode permissions on file-backed UNIX domain sockets. This allows
operators to limit access permission without relying on process umask.
The option applies to S3, admin, and WebUI sockets and has no effect
on TCP/IP addresses or Linux abstract namespace sockets.

Fixes #2010
This commit is contained in:
Ben McClelland
2026-04-20 19:07:08 -07:00
parent 7b65d744e6
commit 0dc074acbf
7 changed files with 97 additions and 10 deletions
+11 -2
View File
@@ -19,6 +19,7 @@ import (
"fmt"
"net"
"net/http"
"os"
"strings"
"github.com/gofiber/fiber/v2"
@@ -43,6 +44,7 @@ type Server struct {
config *ServerConfig
pathPrefix string
quiet bool
socketPerm os.FileMode
}
// Option sets various options for NewServer()
@@ -63,6 +65,13 @@ func WithPathPrefix(prefix string) Option {
return func(s *Server) { s.pathPrefix = prefix }
}
// WithSocketPerm sets the file-mode permissions applied to file-backed UNIX
// domain sockets after binding. It has no effect on TCP/IP or abstract
// namespace sockets.
func WithSocketPerm(perm os.FileMode) Option {
return func(s *Server) { s.socketPerm = perm }
}
// NewServer creates a new GUI server instance
func NewServer(cfg *ServerConfig, opts ...Option) *Server {
app := fiber.New(fiber.Config{
@@ -175,9 +184,9 @@ func (s *Server) ServeMultiPort(ports []string) error {
var err error
if s.CertStorage != nil {
ln, err = utils.NewMultiAddrTLSListener(s.app.Config().Network, addrSpec, s.CertStorage.GetCertificate)
ln, err = utils.NewMultiAddrTLSListener(s.app.Config().Network, addrSpec, s.CertStorage.GetCertificate, utils.ListenerOptions{SocketPerm: s.socketPerm})
} else {
ln, err = utils.NewMultiAddrListener(s.app.Config().Network, addrSpec)
ln, err = utils.NewMultiAddrListener(s.app.Config().Network, addrSpec, utils.ListenerOptions{SocketPerm: s.socketPerm})
}
if err != nil {