CGI implementation in libpxd/polluxd

As of 20250817 the polluxd architecture separates CGI processes from the main server process in a way that allows it to:

Can't you do all of this with fcgi? Yeah, you can, but fcgi requires a whole complicated protocol to do all of those things. libpxd reinvents part of the fcgi wheel with a relatively simple mechanism.

The procedure

There are three processes that are involved in launching a CGI script:

The main server process

From the perspective of the main server process what happens (from startup) is:

The CGI helper process

Before reading keys and dropping privileges, the main process fork()s (to create a CGI helper process), chroots, and drops privileges. It then listens for requests from the server-helper socket in a loop.

The request loop:

The CGI worker process

The CGI worker starts off with the server-worker socketpair open and runs with the permissions/chroot of the CGI helper which may be different from the main server process.

The CGI worker lifetime:

Once all of this is done, the CGI worker runs the script as an config-specified user in a config-specified chroot that may or may not be the same as the main server process. It never has access to any key material or any substantial part of the address space from the main server process.