Commit Graph

15 Commits

Author SHA1 Message Date
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
4ad573d0d5 rework load_file to use pread()
avoids issues since the same file is sent to multiple processes
after being dup()'ed.  Since these files are meant to be regular
files, I don't expect short reads.
2023-06-11 09:21:34 +00:00
Omar Polo
1a99859b35 adjust how locations are received 2023-06-11 09:19:42 +00:00
Omar Polo
15e60fdf0c simplify ocsp sending using config_send_file
while here add an explicit flush to avoid a fd rampage.
2023-06-11 09:18:30 +00:00
Omar Polo
2e880a57f8 change config_send_file to take the process id as argument
i.e. not hardcode PROC_SERVER
2023-06-10 11:03:29 +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
9b2587bb33 safety measure, explicitly memset config in config_init 2023-06-08 19:35:05 +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
f5c8360ade fix previous 2023-06-08 19:24:37 +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
c26f2460e4 rework the daemon to do fork+exec
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-08 13:59:31 +00:00
Omar Polo
c68baad22a move config-related code to config.c
reuse it in ge too.
2023-06-06 08:18:57 +00:00