Commit Graph

208 Commits

Author SHA1 Message Date
Omar Polo 8aba5d8b21 remove dead code 2024-03-12 14:10:36 +00:00
Omar Polo e371817b34 fix configtest with chroot
The configtest checks try to open the root directories too, operation
that can fail when they're expected to be inside a chroot.
2024-01-09 14:15:58 +00:00
Omar Polo ac46710a4b fix ge^W gemexp version string 2024-01-08 08:34:36 +00:00
Omar Polo adaae5163c rework gencert(); make gemexp generate EC certs
Taking inspiration from acme-client.
2023-10-18 17:47:29 +00:00
Omar Polo 95500a936a remove not so useful starts_with()
replace its only usage with strncmp().  it's likely faster too.
2023-08-11 10:38:34 +00:00
Omar Polo 8bb1b23633 remove a long, long unused function 2023-08-11 10:33:40 +00:00
Omar Polo 390d312b22 don't call client_close() from fcgi/proxy bev handlers
We might end up calling client_close() from start_reply(), but that
will free the fcgi/proxy bufferevent while they're still used on the
stack.

Instead, start_reply() only sets REQUEST_DONE and exits, returning the
error eventually, so callers know when to stop.
2023-08-09 19:13:13 +00:00
Omar Polo 03d671e2aa implement fastcgi strip number 2023-08-08 17:35:11 +00:00
Omar Polo 08c0f676fd remove prototype for function killed long ago 2023-08-08 15:57:12 +00:00
Omar Polo d98ef73494 move strip_path to utils.c 2023-08-08 15:56:27 +00:00
Omar Polo 3b431c09d9 try hard at loading the configuration during conftest (-n)
Attempt to do also a few more steps that were previously done only
at runtime.  This can help verifying that the keypairs are matching
for example, but also that there are no typos in the path to the
root directories.

Was requested some time ago by Marian Mizik, thanks for the feature
request!
2023-08-07 12:40:44 +00:00
Omar Polo 9abba172b6 add `log syslog facility' to use a different syslog(3) facility
Was requested ages ago by Karl Jeacle, now that there is some better
support for configuring the logging there's no excuse to add this.
It helps with filtering from syslog.d / syslog.conf.
2023-08-07 09:34:19 +00:00
Omar Polo 26df50981f actually use the specified log style 2023-08-03 22:37:34 +00:00
Omar Polo 46bcc4ea95 add log syslog off; don't turn syslog off when log access is specified 2023-07-26 08:10:12 +00:00
Omar Polo cba01a8687 rename IMSG_LOG_TYPE to ACCESS 2023-07-26 07:55:51 +00:00
Omar Polo abd261d25b allow to change the logging style; introduce some new ones
add `log style <style>'; The old default is called `legacy' now, a
new default format is added called `condensed', and `common' and
`combined' to mimick Apache httpd and nginx (respectively) are also
added.
2023-07-25 20:07:26 +00:00
Omar Polo 226f13ece0 add ability to log to files with log access <path> 2023-07-24 08:50:49 +00:00
Omar Polo 692a9f5fea remove unused IMSG types 2023-07-23 21:43:18 +00:00
Omar Polo 6a8387e5f5 add `fastcgi off' to forceful skip fastcgi for a route 2023-07-23 19:04:37 +00:00
Omar Polo a1ba9650a9 revamp fastcgi configuration: make it per-location
this revamps the syntax in the configuration to better match httpd(8)
(and in general be less weird) and to allow per-location fastcgi
configurations.

the bare `param' is now deprecated, but for compatibility it acts
like `fastcgi param' would do now.  Same story for `fastcgi <pathÂ>'.
2023-07-23 18:45:05 +00:00
Omar Polo f36ba9be59 move struct envlist and alist up 2023-07-23 18:17:59 +00:00
Omar Polo 81bab00246 split out iri.h from gmid.h 2023-07-22 13:49:07 +00:00
Omar Polo 71b02f6390 rename do_accept() -> server_accept() 2023-07-01 22:00:08 +00:00
Omar Polo 2c3810687f change log_request to take the code and meta unpacked
don't know what i was smoking when I wrote log_request() like that...
2023-07-01 18:41:46 +00:00
Omar Polo 0f7fdd2105 parse (and log) the header from fastcgi 2023-07-01 18:37:59 +00:00
Omar Polo e2003e7e30 simplify request handling
get rid of check_path(), it's overly complicated.  Instead, inline
open_file() in client_read() and rework open_dir() to just use
openat() instead of the complicate dance it was doing.

Simplify open_dir() too in the process: if the directory entry for the
index is not a regular file, pretend it doesn't exist.
2023-07-01 14:11:18 +00:00
Omar Polo ed164e7221 call getnameinfo() only once per request 2023-06-26 09:44:46 +00:00
Omar Polo eac9287d29 copyright years++ 2023-06-24 10:07:17 +00:00
Omar Polo e50f85adcb load the certs per listening address 2023-06-24 09:50:30 +00:00
Omar Polo a0a42860d2 send host addresses to the server process 2023-06-24 09:14:35 +00:00
Omar Polo 509d0509a5 implement `listen on'
Listening by default on all the addresses is so bad I don't know
why I haven't changed this before.  Anyway.

Add a `listen on $hostname port $port' syntax to the config file
and deprecate the old "port" and "ipv6" global setting.  Still try
to honour them when no "listen on" directive is used for backward
compatibily, but this will go away in the next next version hopefully.

At the moment the `listen on' in server context don't filter the
host, i.e. one can still reach a host from a address not specified
in the corresponding `liste on', this will be added later.
2023-06-23 21:03:29 +00:00
Omar Polo 37df23d183 rename client->addr to raddr (remote address) and keep original length 2023-06-23 21:03:29 +00:00
Omar Polo 2cef5cf42a load_ca: get a buffer instead of a fd
We dup(1) the ca fd and send it to various processes, so they fail
loading it.  Instead, use load_file to get a buffer with the file
content and pass that to load_ca which then loads via BIO.
2023-06-12 21:27:24 +00:00
Omar Polo ba290ef3af disable the privsep crypto engine on !OpenBSD
it fails bandly at runtime on various linux distros and on freebsd.
Until a fix is found, disable it so I can move forward.
2023-06-11 12:18:27 +00:00
Omar Polo b8d68fc8e4 fixes for -Wpointer-sign 2023-06-11 11:31:22 +00:00
Omar Polo 86693a33ab add a privsep crypto engine
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-11 11:03:59 +00:00
Omar Polo 5af19830c3 move print_conf and make it take the config as argument 2023-06-09 17:29:52 +00:00
Omar Polo 68368f4c29 parse_conf: don't die on error, return -1
this avoids having the daemon dieing on SIGHUP with a bad config
file.
2023-06-09 17:24:37 +00:00
Omar Polo af1dab1870 don't have the config being a global 2023-06-09 17:18:04 +00:00
Omar Polo e45334e6ae move hosts into the config struct 2023-06-09 16:54:04 +00:00
Omar Polo 5d22294a59 move fastcgi from global var to the config struct
while here also make them a list rather than a fixed-size array.
2023-06-09 10:42:36 +00:00
Omar Polo deadd9e131 readd proxy certs and `require client ca' support
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-09 09:28:26 +00:00
Omar Polo 309dab3a90 fix typo 2023-06-08 19:41:38 +00:00
Omar Polo 1c6967b33a keep cert/key/ocsp path as strings and don't send them via imsg 2023-06-08 19:34:49 +00:00
Omar Polo ca84625a7f remove foreground / verbose from config
set them as global vars; rename foreground -> debug
2023-06-08 17:29:08 +00:00
Omar Polo cbb7f9fc28 move logger() prototype to gmid.h and delete logger.h 2023-06-08 17:03:13 +00:00
Omar Polo 3886afceec make server_init and server_configure_done 'public'
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-08 16:21:31 +00:00
Omar Polo 47b0ff105a move log_request to gmid.c
so that ge can provide its own log_request without requiring a
separate logger process.
2023-06-08 16:16:14 +00:00
Omar Polo 4f4937f06a move make_socket to config.c and make it private 2023-06-08 16:07:01 +00:00
Omar Polo fc9cc497e0 move some new_* functions from parse.y to utils.c 2023-06-08 15:59:53 +00:00