about summary refs log tree commit diff
path: root/nixpkgs/pkgs/servers/http/cgiserver/0001-Add-r-flag-to-set-CGI-SCRIPT_NAME.patch
blob: 0d9f947e615f55b9a07ba46c26006d49d886b6c6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
From e71226e93702268295d989c5ac7a103a1553a13a Mon Sep 17 00:00:00 2001
From: Alyssa Ross <hi@alyssa.is>
Date: Wed, 11 May 2022 14:26:14 +0000
Subject: [PATCH 1/2] Add -r flag to set CGI SCRIPT_NAME

---
 main.go | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/main.go b/main.go
index 2019888..6366db0 100644
--- a/main.go
+++ b/main.go
@@ -24,9 +24,11 @@ func main() {
 
 	// The default usage message isn't very helpful, so we provide our own.
 	flag.Usage = func() {
-		fmt.Fprintln(flag.CommandLine.Output(), "Usage: cgiserver /path/to/application.cgi")
+		fmt.Fprintln(flag.CommandLine.Output(), "Usage: cgiserver [-r ROOT] /path/to/application.cgi")
 	}
 
+	root := flag.String("r", "/", "CGI SCRIPT_NAME");
+
 	// We didn't configure any flags, so this just serves to display an error
 	// if someone tries to pass one. It also automatically handles -h/--help.
 	flag.Parse()
@@ -53,6 +55,7 @@ func main() {
 	// ...and Go's standard library does literally all of the hard work.
 	handler = &cgi.Handler{
 		Path: path,
+		Root: *root,
 		Env:  os.Environ(), // Environment variables aren't inherited by default.
 	}
 
-- 
2.35.1