aboutsummaryrefslogtreecommitdiff
path: root/gmid.h
AgeCommit message (Collapse)Author
2023-06-11fixes for -Wpointer-signOmar Polo
2023-06-11add a privsep crypto engineOmar Polo
Incorporate the OpenSMTPD' privsep crypto engine. The idea behind it is to never load the certificate' private keys in a networked process, instead they are loaded in a separate process (the `crypto' one) which signs payloads on the behalf of the server processes. This way, we greatly reduce the risk of leaking the certificate' private key should the server process be compromised. This currently compiles only on LibreSSL (portable fix is in the way).
2023-06-09move print_conf and make it take the config as argumentOmar Polo
2023-06-09parse_conf: don't die on error, return -1Omar Polo
this avoids having the daemon dieing on SIGHUP with a bad config file.
2023-06-09don't have the config being a globalOmar Polo
2023-06-09move hosts into the config structOmar Polo
2023-06-09move fastcgi from global var to the config structOmar Polo
while here also make them a list rather than a fixed-size array.
2023-06-09readd proxy certs and `require client ca' supportOmar Polo
Was temporarly disabled during the transition to real privsep. While here, fix a memory leak when using `require client ca'. Also, avoid leaking info about the parent address space layout to server processes by not sending pointer values.
2023-06-08fix typoOmar Polo
2023-06-08keep cert/key/ocsp path as strings and don't send them via imsgOmar Polo
2023-06-08remove foreground / verbose from configOmar Polo
set them as global vars; rename foreground -> debug
2023-06-08move logger() prototype to gmid.h and delete logger.hOmar Polo
2023-06-08make server_init and server_configure_done 'public'Omar Polo
server_configure_done is the code we ran in IMSG_RECONF_END splitted in a separate functions. This is all needed for ge.c which doesn't do privsep but needs to bootstrap the server process.
2023-06-08move log_request to gmid.cOmar Polo
so that ge can provide its own log_request without requiring a separate logger process.
2023-06-08move make_socket to config.c and make it privateOmar Polo
2023-06-08move some new_* functions from parse.y to utils.cOmar Polo
2023-06-08drop now unused dispatch_imsgOmar Polo
2023-06-08rework the daemon to do fork+execOmar Polo
It uses the 'common' proc.c from various OpenBSD-daemons. gmid grew organically bit by bit and it was also the first place where I tried to implement privsep. It wasn't done very well, in fact the parent process (that retains root privileges) just fork()s a generation of servers, all sharing *exactly* the same address space. No good! Now, we fork() and re-exec() ourselves, so that each process has a fresh address space. Some features (require client ca for example) are temporarly disabled, will be fixed in subsequent commits. The "ge" program is also temporarly disabled as it needs tweaks to do privsep too.
2023-06-06rename PROC_MAX to PREFORK_MAXOmar Polo
2023-06-06adjust commentsOmar Polo
2023-06-06move config-related code to config.cOmar Polo
reuse it in ge too.
2023-06-05remove unused defineOmar Polo
2023-06-05move and dedup the tls initalization in server.cOmar Polo
2023-06-05provide a more usual fatalOmar Polo
fatal usually appends the error string. Add 'fatalx' that doesn't. Fix callers and move the prototypes to log.h
2023-06-05move some server-related code to server.cOmar Polo
2023-05-08send capsicum/landlock/seccomp hack to ValhallaOmar Polo
2022-10-05make the various strings in the config fixed-lengthOmar Polo
will help in future restructuring to have fixed-size objects.
2022-10-05retire fcgi' prog fieldOmar Polo
spawning programs was a hidden feature used only for testing. It's gross and when got removed, I forgot to remove the field as well.
2022-09-10specify custom version strings for the various cmdsOmar Polo
2022-09-10remove remnats tentacles of the executor processOmar Polo
2022-09-10remove unused entrypoint fieldOmar Polo
ventige of the cgi support (and lack of url rewriting)
2022-09-10drop cgi vestiges from the struct hostOmar Polo
The `env' list is no longer used since CGI scripts were removed
2022-09-10retire the deprecated `mime' and `map' config optionsOmar Polo
2022-09-10make the mime types fixed-sized tooOmar Polo
2022-09-10make config fields `chroot' and `user' fixed-sizeOmar Polo
2022-09-06optionally disable the sandbox on some systemsOmar Polo
The FreeBSD and Linux' sandbox can't deal with `fastcgi' and `proxy' configuration rules: new sockets needs to be opened and it's either impossible (the former) or a huge pain in the arse (the latter). The sandbox is still always used in case only static files are served.
2022-09-06gc FILE_EXECUTABLEOmar Polo
2022-09-06gc sandbox_executor_processOmar Polo
2022-09-06get rid of the CGI supportOmar Polo
I really want to get rid of the `executor' process hack for CGI scripts and its escalation to allow fastcgi and proxying to work on non-OpenBSD. This drops the CGI support and the `executor' process entirely and is the first step towards gmid 2.0. It also allows to have more secure defaults. On non-OpenBSD systems this means that the sandbox will be deactivated as soon as fastcgi or proxying are used: you can't open sockets under FreeBSD' capsicum(4) and I don't want to go thru the pain of making it work under linux' seccomp/landlock. Patches are always welcome however. For folks using CGI scripts (hey, I'm one of you!) not all hope is lost: fcgiwrap or OpenBSD' slowcgi(8) are ways to run CGI scripts as they were FastCGI applications. fixes for the documentation and to the non-OpenBSD sandboxes will follow.
2022-07-04encode file names in the directory indexOmar Polo
Spotted the hard way by cage
2022-04-08sort the MIME mappings and do a binary search to matchOmar Polo
2022-04-08don't load the built-in list when using `types'Omar Polo
2022-04-08allow add_mime to failOmar Polo
add_mime nows allocate dinamically copies of the passed strings, so that we can actually free what we parse from the config file. This matters a lot especially with lengthy `types' block: strings that reach the internal mapping are never free'd, so every manual addition is leaked.
2022-03-27fix an out-of-bound access in start_cgiOmar Polo
Long time ago, client->req was a static buffer so the memcpy was safe. However, it's been since moved to a dynamically allocated string, so it's very often smaller than sizeof(req.buf) (1024), hence the out of bound access which results in a SIGSEGV very often on OpenBSD thanks to Otto' malloc. The situation with the iri parser, client->req and how the request is forwarded to the other process needs to be improved: this is just a fix to address the issue quickly, a better one would be to restructure the iri parser APIs and rethink how the info is forwarded to the ex process.
2022-03-26swap try_client_by_id with client_by_idOmar Polo
i.e. allow client_by_id to fail and return NULL. Initially I thought it was a good idea to shut down a server process if we receive an invalid client id as reply from one of our requests to the executor process. This turned out not to be correct since a client can (read: will) disconnect in the delay beteewn we acknowledge their request and the cgi script execution. The fastcgi and proxy handler already handled this situation, so they're unaffected. This allows an attacker to make gmid unresponsible by just making enough requests until they hit the right timing.
2022-01-30allow using a custom hostname for SNI during proxyingOmar Polo
add a `sni' option for the `proxy' block: the given name is used instead of the one extracted by the `relay-to' rule.
2022-01-27improve proxy error pathOmar Polo
properly release everything when during client_close if the request was managed by a proxy.
2022-01-04add `require client ca' for proxy blocksOmar Polo
refactor the code that calls validate_against_ca into an helper function to reuse it in both apply_require_ca and (optionally) in apply_reverse_proxy.
2022-01-02proxy: allow multiple proxy blocks, matching options and validationsOmar Polo
as a side effect the order of the content of a server block is relaxed: options, location or proxy blocks can be put in any order.
2022-01-01allow to disable TLS when proxying requestsOmar Polo