From 3886afceec08126fede93edee884cbd13078cbec Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Thu, 8 Jun 2023 16:21:31 +0000 Subject: 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. --- gmid.h | 2 ++ server.c | 30 +++++++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/gmid.h b/gmid.h index c7b1c4e..2078a2c 100644 --- a/gmid.h +++ b/gmid.h @@ -370,6 +370,8 @@ void start_reply(struct client*, int, const char*); void client_close(struct client *); struct client *client_by_id(int); void do_accept(int, short, void *); +void server_init(struct privsep *, struct privsep_proc *, void *); +int server_configure_done(struct conf *); void server(struct privsep *ps, struct privsep_proc *); int client_tree_cmp(struct client *, struct client *); diff --git a/server.c b/server.c index ae46559..eba98da 100644 --- a/server.c +++ b/server.c @@ -73,7 +73,6 @@ static void client_close_ev(int, short, void *); static void handle_siginfo(int, short, void*); -static void server_init(struct privsep *, struct privsep_proc *, void *); static int server_dispatch_parent(int, struct privsep_proc *, struct imsg *); static int server_dispatch_logger(int, struct privsep_proc *, struct imsg *); @@ -1432,7 +1431,7 @@ server(struct privsep *ps, struct privsep_proc *p) proc_run(ps, p, procs, nitems(procs), server_init, NULL); } -static void +void server_init(struct privsep *ps, struct privsep_proc *p, void *arg) { SPLAY_INIT(&clients); @@ -1448,6 +1447,22 @@ server_init(struct privsep *ps, struct privsep_proc *p, void *arg) sandbox_server_process(); } +int +server_configure_done(struct conf *conf) +{ + if (load_default_mime(&conf->mime) == -1) + fatal("can't load default mime"); + sort_mime(&conf->mime); + setup_tls(); + load_vhosts(); + if (conf->sock4 != -1) + event_add(&conf->evsock4, NULL); + if (conf->sock6 != -1) + event_add(&conf->evsock6, NULL); + + return 0; +} + static int server_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) { @@ -1474,15 +1489,8 @@ server_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg) case IMSG_RECONF_END: if (config_recv(conf, imsg) == -1) return -1; - if (load_default_mime(&conf->mime) == -1) - fatal("can't load default mime"); - sort_mime(&conf->mime); - setup_tls(); - load_vhosts(); - if (conf->sock4 != -1) - event_add(&conf->evsock4, NULL); - if (conf->sock6 != -1) - event_add(&conf->evsock6, NULL); + if (server_configure_done(conf) == -1) + return -1; break; default: return -1; -- cgit v1.2.3