home readme diff tree note docs

0commit 5a45459ef0f0cca7ac543d8ba4f5bd5549dd5a8c
1Author: lakefox <mason@lakefox.net>
2Date:   Fri May 22 20:49:52 2026 -0600
3
4    x
5
6diff --git a/cgi.awk b/cgi.awk
7deleted file mode 100644
8index 8b3ae82..0000000
9--- a/cgi.awk
10+++ /dev/null
11@@ -1,56 +0,0 @@
12-#!/bin/awk -f
13-
14-BEGIN {
15-	# 1. Parse Query String (reuse your logic)
16-	split(ENVIRON["QUERY_STRING"], pairs, "&")
17-	for (i in pairs) {
18-		split(pairs[i], kv, "=")
19-		if (kv[1] == "name") name = sanitize(kv[2])
20-		else if (kv[1] == "hash") hash = sanitize(kv[2])
21-		else if (kv[1] == "action") action = sanitize_path(kv[2])
22-		# Capture all other params to pass as arguments
23-		else params[kv[1]] = sanitize(kv[2])
24-	}
25-
26-	# Defaults
27-	if (name == "") { print "Status: 400 Bad Request\r\n\r\nMissing repository."; exit }
28-	if (hash == "") hash = "HEAD"
29-
30-	# 2. Setup environment
31-	repo_path = "/var/git/" name ".git"
32-	script_path = repo_path "/cgi/" action
33-
34-	# 3. Security: Check if file exists and is executable
35-	# Use 'test -x' via system() or stat (simplified here)
36-	if (action == "" || system("test -f " script_path " -a -x " script_path) != 0) {
37-		print "Status: 404 Not Found\r\n\r\nScript not found or not executable."
38-		exit
39-	}
40-
41-	# 4. Prepare execution
42-	# Build query string from remaining params for the script
43-	query_args = ""
44-	for (p in params) query_args = query_args p "=" params[p] " "
45-		# 5. Execute and capture output
46-		print "Content-Type: text/plain\r\n"
47-
48-		# Exporting environment variables for the script to use
49-		cmd = "GIT_DIR=" repo_path " HASH=" hash " " script_path " " query_args
50-		while ((cmd | getline line) > 0) {
51-			print line
52-		}
53-	close(cmd)
54-}
55-
56-function sanitize(str) {
57-	gsub(/[^a-zA-Z0-9._=-]/, "", str)
58-	return str
59-}
60-
61-function sanitize_path(str) {
62-	# Remove directory traversal
63-	gsub(/\.\./, "", str)
64-	# Only allow safe characters for paths
65-	gsub(/[^a-zA-Z0-9._/-]/, "", str)
66-	return str
67-}