From 1dd1579d9e9c2c087d6aaa455f970d9bea76b866 Mon Sep 17 00:00:00 2001 From: Gibheer Date: Wed, 30 Oct 2024 20:32:37 +0100 Subject: add support to modify the socket file mode --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.go b/main.go index 5049fe2..dad740b 100644 --- a/main.go +++ b/main.go @@ -2,12 +2,14 @@ package main import ( "flag" + "io/fs" "log" "net" "net/http" "net/http/cgi" "os" "os/signal" + "strconv" "strings" ) @@ -16,6 +18,7 @@ func main() { dir := flag.String("dir", "", "set a different working directory from the base path of 'path'") env := flag.String("env", "", "set environment variables for the CGI process") prefix := flag.String("uri-prefix", "/", "set the URL prefix when the CGI process is hosted in a sub directory") + socketMode := flag.String("mode", "777", "set the filesystem mode when using a unix socket") addr := flag.String("listen", "127.0.0.1:8080", "set the listen address") flag.Parse() @@ -38,6 +41,14 @@ func main() { if err != nil { log.Fatalf("could not start to listen: %s", err) } + if listenType == "unix" { + mode, err := strconv.ParseUint(*socketMode, 8, 32) + if err != nil { + log.Fatalf("could not parse mode: %s", err) + } + log.Printf("what we parsed: %s", fs.FileMode(mode)) + os.Chmod(listenAddr, fs.FileMode(mode)) + } forwarder := &cgi.Handler{ Path: *path, -- cgit v1.2.3-70-g09d2