diff options
author | Gibheer <gibheer+git@zero-knowledge.org> | 2024-10-30 20:32:37 +0100 |
---|---|---|
committer | Gibheer <gibheer+git@zero-knowledge.org> | 2024-10-30 20:32:37 +0100 |
commit | 1dd1579d9e9c2c087d6aaa455f970d9bea76b866 (patch) | |
tree | 5c23699db73bed2c299d6a5fe897437c3a476a8a | |
parent | ef425e0e4b8933e831914eafd7a49f1c6619366d (diff) |
add support to modify the socket file mode
-rw-r--r-- | main.go | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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, |