Index | Thread | Search

From:
Rafael Sadowski <rafael@sizeofvoid.org>
Subject:
httpd: do NOT send location fcgiparams twice
To:
tech@openbsd.org
Date:
Mon, 13 Jul 2026 13:55:09 +0200

Download raw body.

Thread
While working on the custom headers, I'm noticing more and more issues
in fcgiparams (since I used that as a template).

server "fcgi-test" {
	listen on 127.0.0.1 port 8089
	root "/htdocs"

	location "*.cgi" {
		fastcgi {
			socket "/run/slowcgi.sock"
			param FCGI_TEST_A "A"
			param FCGI_TEST_B "B"
			param FCGI_TEST_C "C"
			param FCGI_TEST_D "D"
			param FCGI_TEST_E "E"
		}
	}
}

curl -s http://127.0.0.1:8089/env.cgi
FCGI_TEST_E=E
FCGI_TEST_D=D
FCGI_TEST_C=C
FCGI_TEST_B=B
FCGI_TEST_A=A
FCGI_TEST_E=E
FCGI_TEST_D=D
FCGI_TEST_C=C
FCGI_TEST_B=B
FCGI_TEST_A=A

Yes, the order is reversed. we can fix it in a different commit.

OK?

commit 603108536a8ef506d76179d9d4007d1038b50eee
Author: Rafael Sadowski <rafael@sizeofvoid.org>
Date:   Mon Jul 13 13:33:34 2026 +0200

    httpd: do NOT send location fcgiparams twice
    
    Only emit the params when the current receiver is the server child.
    
    When sending a location-config from the parent, the FCGI params IMSG
    was emitted once per receiver iteration and always targeted the server
    child.  With both the server and the logger process needing the server
    config, the server child received IMSG_CFG_FCGI twice per location and
    appended the same params on top of the existing list. The FastCGI backends
    then saw every param duplicated.

diff --git a/config.c b/config.c
index 146ed2c..6522a4b 100644
--- a/config.c
+++ b/config.c
@@ -281,7 +281,8 @@ config_setserver(struct httpd *env, struct server *srv)
 			}
 
 			/* Configure FCGI parameters if necessary. */
-			config_setserver_fcgiparams(env, srv);
+			if (id == PROC_SERVER)
+				config_setserver_fcgiparams(env, srv);
 		}
 	}