aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGibheer <gibheer+git@zero-knowledge.org>2024-10-30 20:32:37 +0100
committerGibheer <gibheer+git@zero-knowledge.org>2024-10-30 20:32:37 +0100
commit1dd1579d9e9c2c087d6aaa455f970d9bea76b866 (patch)
tree5c23699db73bed2c299d6a5fe897437c3a476a8a
parentef425e0e4b8933e831914eafd7a49f1c6619366d (diff)
add support to modify the socket file mode
-rw-r--r--main.go11
1 files changed, 11 insertions, 0 deletions
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,