Commit Graph

924 Commits

Author SHA1 Message Date
Omar Polo 52c92ef680 relax the "wont proxy request" check: don't check the port number
Don't refuse to serve the request if the port number doesn't match the
one we're listening on, as initially suggested by Allen Sobot.

Complex setup may have a gmid instance reachable from multiple ports and
the meaning of the check in the first places was to avoid tricking
clients into thinking that we're serving for those domains: the port
number is way less important than the schema or domain name.

In the long run, the best way would probably to add a `listen on'
keyword for the servers blocks, just like OpenBSD' httpd, but gmid can't
listen on multiple ports/interfaces yet
2021-12-09 20:59:05 +00:00
Omar Polo 34c4ca6ebc configure: support --prefix=...
It's like passing PREFIX=... on the command line
2021-12-09 19:24:18 +00:00
Omar Polo ae0d3cdbbe typo
forgot to rename variable in lib.sh: dont_check ->
dont_check_server_alive.
2021-12-09 19:13:30 +00:00
Omar Polo e5285d5422 rename `runtime' to `regress'
while there also kill an unused rule `regress', it's now redundant since
all the tests are run together.
2021-12-09 20:06:38 +01:00
Omar Polo a721c233ee rename variable 2021-12-09 19:03:18 +00:00
Omar Polo 5741561d57 run all kinds of tests via tests.sh/runtime
while there also change the dependency in the makefile: iri_test should
be alone, not as deps of `data'.
2021-12-09 19:02:09 +00:00
Omar Polo ea47a245aa add ocs stapling checking for gg 2021-12-09 18:51:02 +00:00
Omar Polo ebf3373d66 explain config-less mode 2021-12-02 08:32:47 +00:00
Omar Polo aa76c675eb sync changelog 2021-11-16 09:06:01 +00:00
Omar Polo eb77afa8d3 don't run the test binaries, compilation status is enough
During a cross-compilation we can compile the test binaries but not
run in the host machine.  Furthermore, the exit status of the test
isn't really important for the types of check we have, the compilation
status is enough.

Reported by Nikolay Korotkiy (@sikmir) on Github, fixes issue #8
2021-11-16 08:48:04 +00:00
Omar Polo 193380eaa4 free OCSP path when clearing the config
was forgotten in ff05125eb8
2021-10-24 16:57:31 +00:00
Omar Polo dcfdb969a2 don't list the exact pledge promises
It's easy to forgot to update the README after a code change (already
happened in the past) and they're easy to discover by reading
sandbox.c
2021-10-24 16:52:39 +00:00
Omar Polo d65fa58c1b use gmid from the repo instead of the system installed one 2021-10-24 16:38:11 +00:00
Omar Polo eaa02ac8c7 sync changelog 2021-10-24 16:34:34 +00:00
Omar Polo a81dd6cda6 fix "double slash" in logs
gmid ended up printing two slashes between the hostname and the path
when logging the request IRI.
2021-10-24 16:34:30 +00:00
Omar Polo 93edd35305 master is now 1.8-dev 2021-10-23 10:46:35 +00:00
Omar Polo 4842c72d9f fmt 2021-10-18 10:05:55 +00:00
Omar Polo f8bcc13822 typo 2021-10-15 09:19:17 +00:00
Omar Polo e84ee6a729 update the site for 1.7.5 2021-10-15 09:12:54 +00:00
Omar Polo 818d6aeeb6 sync changelog 2021-10-15 08:28:35 +00:00
Omar Polo 7fa6717647 fmt 2021-10-15 08:03:11 +00:00
Stephen Gregoratto ff05125eb8 Implement OCSP stapling support
Currently dogfooding this patch at gemini.sgregoratto.me. To test,
run the following command and look for the "OCSP response" header:

 openssl s_client -connect "gemini.sgregoratto.me:1965" -status
2021-10-15 09:58:23 +02:00
Omar Polo 387b976b99 c->req may be NULL now 2021-10-15 07:51:15 +00:00
Omar Polo 8044493865 move bufferevent initialization early in handle_handshake
the error path needs an initialized bufferevent too, otherwise it'll
crash when trying to write the response.

This moves the initialisation early, right after the tls_handshake.
Another option would be to initialise it in do_accept, but that may be
too early.
2021-10-15 07:46:30 +00:00
Omar Polo 33c4c3a5ba more small improvements for the quickstart 2021-10-13 20:52:19 +00:00
Omar Polo 2ae10bb4ee sync 2021-10-13 20:50:37 +00:00
Omar Polo c62a411f4f don't die on ECONNABORTED
ECONNABORTED is returned if a connections gets aborted after being
queued before the accept(2).  I had some cases of

	accept: Software caused connection abort

on FreeBSD, this should avoid that.
2021-10-13 20:49:58 +00:00
Omar Polo 8af884dff4 fix navigation links 2021-10-11 17:59:15 +00:00
Omar Polo 7c6bf71dc8 fix navigation links in *.gmi pages 2021-10-11 15:49:34 +00:00
Omar Polo fc4b58d450 tweak the quickstart guide 2021-10-11 15:46:41 +00:00
Omar Polo c0f81ed39e mention renew-certs in contrib.{gmi,html} 2021-10-11 15:32:47 +00:00
Omar Polo 536026c565 add script to automatically renew self-signed certificates 2021-10-11 14:42:11 +00:00
Omar Polo f0a01fc742 two -n to dump the parsed configuration
This adds a barebone dumping of the parsed configuration.  It is not
complete, but I'm interested in dumping the full path to `cert' and
`key' in order to write some scripts that can inspect the
configuration, extract the certificates and renew them when expired
automatically.

It's not easy to parse gmid configuration otherwise because the syntax
is flexible and users can use macros.  Instead, the idea is to run
gmid and let it dump the configuration once it's been parsed in a
static and predictable format.

Now is possible to parse gmid configuration with, say, awk or perl.
2021-10-09 21:40:55 +00:00
Omar Polo 5eb3fc905f don't work around a missing -Wno-unused-parameter
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-09 18:54:41 +00:00
Omar Polo c6bcc919c6 don't wrap the paths inside a <code></code> 2021-10-09 17:19:25 +00:00
Omar Polo c7b79c9eed fix navigation in contrib page 2021-10-09 17:13:35 +00:00
Omar Polo 1298e4307f split the cert generation example on multiple lines 2021-10-09 17:09:56 +00:00
Omar Polo 679d5d1a61 tweak the style for the manpage exported in HTML 2021-10-09 17:09:56 +00:00
Omar Polo 35340c9f1e typos 2021-10-09 16:54:33 +00:00
Omar Polo 540d05dedc typo 2021-10-09 16:31:43 +00:00
Omar Polo 0111ad5d26 add the Quickstart page 2021-10-09 16:30:36 +00:00
Omar Polo a83ba84448 mention gencert in contrib.{gmi,html} 2021-10-09 14:16:28 +00:00
Omar Polo d7e2e22c58 add gencert, a simple script to generate self-signed certs 2021-10-09 14:07:21 +00:00
Omar Polo 9bb2f62e24 tweak landlock comment 2021-10-08 15:55:48 +00:00
Omar Polo 807869c14e print the error too if we can't open a directory
It's not intuitive to print

	open ... for domain xyz

it doesn't convey that the open failed.

now it appends the error string, at least the user can understand that
something went wrong.

reported by cage on irc, thanks!
2021-10-07 17:19:45 +00:00
Omar Polo 492a274fd7 add compat for sys/tree.h 2021-10-07 11:36:25 +00:00
Omar Polo 207b3e80d8 Store clients inside a splay tree
From day one we've been using a static array of client struct to hold
the clients data.  This has variuos drawbacks, among which:

 * reuse of the storage  ("shades of heartbleed")
 * maximum fixed amount of clients connected at the same time
 * bugs are harder to debug

The last point in particular is important because if we mess the client
ids, or try to execute some functions (e.g. the various fcgi_*) after a
client has been disconnected, it's harder to "see" this "use after
free"-tier kind of bug.

Now I'm using a splay tree to hold the data about the live connections.
Each client' data is managed by malloc.  If we try to access a client
data after the disconnection we'll probably crash with a SIGSEGV and
find the bug is more easy.  

Performance-wise the connection phase should be faster since we don't
have to loop anymore to find an empty spot in the clients array, but
some operations could be slightly slower (compare the O(1) access in an
array with a SPLAY_FIND operation -- still be faster than O(n) thought.)
2021-10-07 11:20:34 +00:00
Omar Polo 4cd2520965 one FastCGI connection per client
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-07 10:47:02 +00:00
Omar Polo 3096da4ef4 allow to run only a subset of the runtime tests
with
	make TESTS='test_1 test_2 ...' regress

now it's possible to run only that specified subset of tests.  It's
really useful during debugging :)
2021-10-07 08:55:44 +00:00
Omar Polo e4daebe44a plug a memory leak
c->req is set in client_read but never deallocated
2021-10-06 17:38:37 +00:00