aboutsummaryrefslogtreecommitdiff
path: root/ex.c
AgeCommit message (Collapse)Author
2021-12-29add ability to proxy requestsOmar Polo
Add to gmid the ability to forwad a request to another gemini server and thus acting like a reverse proxy. The current syntax for the config file is server "example.com" { ... proxy relay-to host:port } Further options (like the use of custom certificates) are planned. cf. github issue #7
2021-10-09don't work around a missing -Wno-unused-parameterOmar Polo
It's been there for a long time, and it's frankly annoying to pretend to use parameters. Most of the time, they're there to satisfy an interface and nothings more.
2021-10-07one FastCGI connection per clientOmar Polo
FastCGI is designed to multiplex requests over a single connection, so ideally the server can open only one connection per worker to the FastCGI application and that's that. Doing this kind of multiplexing makes the code harder to follow and easier to break/leak etc on the gmid side however. OpenBSD' httpd seems to open one connection per client, so why can't we too? One connection per request is still way better (lighter) than using CGI, and we can avoid all the pitfalls of the multiplexing (keeping track of "live ids", properly shut down etc...)
2021-10-02[cgi] switch from pipe(2) to socketpair(2)Omar Polo
We can't use normal pipe(2)s with libevent in some cases. Switch to socketpair(2), which doesn't have the same problem. This has the drawback that it doesn't prevent the CGI script from reading stdout, for instance. (sockets are two-way, pipes only one-way)
2021-07-08PF_UNIX is not a valid protocol for socketpairOmar Polo
OpenBSD accept it, but FreeBSD disallows it. PF_UNSPEC (or 0) should be used instead. The FastCGI bit in the regress suite still doesn't work on FreeBSD, but at least now it starts.
2021-07-08don't leak a file descriptorOmar Polo
make sure we always close every fd in every possible code path; while there, also add a log_err if fork(2) failed.
2021-07-06don't let CGI scripts inherit our stderrOmar Polo
our stderr could have been sent to the logger process, so it may be invalid. Furthermore, in the future we may want to capture also the stderr of the processes.
2021-05-15define and use GMID_VERSIONOmar Polo
2021-05-15use the correct document rootOmar Polo
pass the correct loc_off to the executor, so the various variables that depends on the matched location (like DOCUMENT_ROOT) are computed correctly.
2021-05-09fastcgi: a first implementationOmar Polo
Not production-ready yet, but it's a start. This adds a third ``backend'' for gmid: until now there it served local files or CGI scripts, now FastCGI applications too. FastCGI is meant to be an improvement over CGI: instead of exec'ing a script for every request, it allows to open a single connection to an ``application'' and send the requests/receive the responses over that socket using a simple binary protocol. At the moment gmid supports three different methods of opening a fastcgi connection: - local unix sockets, with: fastcgi "/path/to/sock" - network sockets, with: fastcgi tcp "host" [port] port defaults to 9000 and can be either a string or a number - subprocess, with: fastcgi spawn "/path/to/program" the fastcgi protocol is done over the executed program stdin of these, the last is only for testing and may be removed in the future. P.S.: the fastcgi rule is per-location of course :)
2021-04-30allow ``root'' rule to be specified per-location blockOmar Polo
2021-04-28added ``env'' option to define environment vars for CGI scriptsOmar Polo
2021-04-20restore signal handlers before exec'ing CGI scriptsOmar Polo
2021-04-13define TLS_VERSION, TLS_CIPHER and TLS_CIPHER_STRENGTH for CGI scriptsOmar Polo
2021-03-31list instead of fixed-size array for vhosts and locationsOmar Polo
saves some bytes of memory and removes the limit on the maximum number of vhosts and location blocks.
2021-03-20gmid v1.6 -- "Stargazers"v1.6Omar Polo
2021-03-20move all sandbox-related code to sandbox.cOmar Polo
while there, add capsicum for the logger process
2021-03-19refactoring: imsg everywhereOmar Polo
use imsg to handle ALL kinds of IPC in gmid. This simplifies and shorten the code, and makes everything more uniform too.
2021-03-03handle SIGHUP gracefullyOmar Polo
i.e. don't print scary messages with LOG_CRIT priority!
2021-03-03give each server process its own socket for the executorOmar Polo
this fixes a bug introduced with the prefork mechanics: every server process shared the same socket, and this would cause a race condition when multiple server processes asked for a script cgi being executed. This gives each server process its own socket to talk to the executor, so the race cannot happen.
2021-02-12fix various compilation errorsOmar Polo
Include gmid.h as first header in every file, as it then includes config.h (that defines _GNU_SOURCE for instance). Fix also a warning about unsigned vs signed const char pointers in openssl.
2021-02-07define TLS_CLIENT_NOT_BEFORE/NOT_AFTER in CGI scriptsOmar Polo
2021-02-07[cgi] split the query in words if needed and add them to the argvOmar Polo
2021-02-07use log_err instead of fprintfOmar Polo
2021-02-06ensure CGI stdout it's blockingOmar Polo
2021-02-04reload configuration on SIGHUPOmar Polo
2021-02-03refactor executor_mainOmar Polo
now it's symmetrical to listener_main().
2021-02-01[cgi] always set some variablesOmar Polo
2021-02-01don't add the query to argvOmar Polo
FRC3875 says that if the query does not contain any unecnoded "=" characters, we SHOULD treat the query string as a "search-string", split in on "+" and add every word to the CGI argv. In launch_cgi it's too late because iri->query is the *decoded* query! I have in mind some refactoring around how we decode things, so this is postponed.
2021-02-01bring the CGI implementation in par with GLV-1.12556Omar Polo
2021-02-01fix computed offsetOmar Polo
Oh my, this is such a stupid mistake. It went undiscovered only because I always used CGI scripts on the first vhost (and hence the offset would be 0) and never on the others.
2021-01-25unveil x the vhosts directoriesOmar Polo
2021-01-24sync the CGI environment with the manpageOmar Polo
while there also add SERVER_PROTOCOL
2021-01-24pass the fd, not the path!Omar Polo
2021-01-24chdir to the vhost root before exec'ing the CGI scriptOmar Polo
2021-01-19don't leak file descriptorsOmar Polo
2021-01-18fix requri constructionOmar Polo
when we switched from one process to two, I introduced a small optimisation: empty string are not send, so we receive NULL. Constructing requri we need to make sure that relpath is not null.
2021-01-16split into two processes: listener and executorOmar Polo
this way, we can sandbox the listener with seccomp (todo) or capsicum (already done) and still have CGI scripts. When we want to exec, we tell the executor what to do, the executor executes the scripts and send the fd backt to the listener.