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.
This commit is contained in:
Omar Polo 2023-06-08 16:21:31 +00:00
parent 47b0ff105a
commit 3886afceec
2 changed files with 21 additions and 11 deletions

2
gmid.h
View File

@ -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 *);

View File

@ -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;