aboutsummaryrefslogtreecommitdiff
path: root/ge.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2023-06-08 13:59:31 +0000
committerOmar Polo <op@omarpolo.com>2023-06-08 13:59:31 +0000
commitc26f2460e42aa0822c283c805958989f339e7d8b (patch)
tree423410fae4de90b2b753ccad621d364c4641bed2 /ge.c
parent99f1fbb0c73b6f62b966760181b3d97f54bbe73b (diff)
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.
Diffstat (limited to 'ge.c')
-rw-r--r--ge.c32
1 files changed, 1 insertions, 31 deletions
diff --git a/ge.c b/ge.c
index d43f446..554fd21 100644
--- a/ge.c
+++ b/ge.c
@@ -32,7 +32,7 @@
#include "logger.h"
#include "log.h"
-struct imsgbuf ibuf, logibuf;
+struct imsgbuf ibuf;
struct conf conf;
struct fcgi fcgi[FCGI_MAX]; /* just because it's referenced */
@@ -45,12 +45,6 @@ static const struct option opts[] = {
};
void
-drop_priv(void)
-{
- return;
-}
-
-void
load_local_cert(struct vhost *h, const char *hostname, const char *dir)
{
char *cert, *key;
@@ -114,29 +108,6 @@ data_dir(void)
return t;
}
-static void
-logger_init(void)
-{
- int p[2];
-
- if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, p) == -1)
- fatal("socketpair");
-
- switch (fork()) {
- case -1:
- fatal("fork");
- case 0:
- close(p[0]);
- setproctitle("logger");
- imsg_init(&logibuf, p[1]);
- _exit(logger_main(p[1], &logibuf));
- default:
- close(p[1]);
- imsg_init(&logibuf, p[0]);
- return;
- }
-}
-
static int
serve(const char *host, int port, const char *dir)
{
@@ -213,7 +184,6 @@ main(int argc, char **argv)
log_init(1, LOG_DAEMON);
log_setverbose(0);
- logger_init();
config_init();
while ((ch = getopt_long(argc, argv, "d:H:hp:Vv", opts, NULL)) != -1) {