-/* $OpenBSD: ca.c,v 1.90 2023/03/04 22:22:50 tobhe Exp $ */
+/* $OpenBSD: ca.c,v 1.91 2023/03/05 22:17:22 tobhe Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
#include "ikev2.h"
void ca_run(struct privsep *, struct privsep_proc *, void *);
-void ca_shutdown(struct privsep_proc *);
+void ca_shutdown(void);
void ca_reset(struct privsep *);
int ca_reload(struct iked *);
void
ca_run(struct privsep *ps, struct privsep_proc *p, void *arg)
{
- struct iked *env = ps->ps_env;
+ struct iked *env = iked_env;
struct ca_store *store;
/*
}
void
-ca_shutdown(struct privsep_proc *p)
+ca_shutdown(void)
{
- struct iked *env;
+ struct iked *env = iked_env;
struct ca_store *store;
- if (p->p_ps == NULL)
- return;
-
- env = p->p_ps->ps_env;
- if (env == NULL)
- return;
ibuf_release(env->sc_certreq);
if ((store = env->sc_priv) == NULL)
return;
void
ca_getkey(struct privsep *ps, struct iked_id *key, enum imsg_type type)
{
- struct iked *env = ps->ps_env;
+ struct iked *env = iked_env;
struct ca_store *store = env->sc_priv;
struct iked_id *id = NULL;
const char *name;
void
ca_reset(struct privsep *ps)
{
- struct iked *env = ps->ps_env;
+ struct iked *env = iked_env;
struct ca_store *store = env->sc_priv;
if (store->ca_privkey.id_type == IKEV2_ID_NONE ||
int
ca_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
unsigned int mode;
switch (imsg->hdr.type) {
int
ca_dispatch_ikev2(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
switch (imsg->hdr.type) {
case IMSG_CERTREQ:
int
ca_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
struct ca_store *store = env->sc_priv;
switch (imsg->hdr.type) {
-/* $OpenBSD: control.c,v 1.35 2023/03/04 22:22:50 tobhe Exp $ */
+/* $OpenBSD: control.c,v 1.36 2023/03/05 22:17:22 tobhe Exp $ */
/*
* Copyright (c) 2010-2013 Reyk Floeter <reyk@openbsd.org>
int
control_init(struct privsep *ps, struct control_sock *cs)
{
- struct iked *env = ps->ps_env;
+ struct iked *env = iked_env;
struct sockaddr_un s_un;
int fd;
mode_t old_umask, mode;
-/* $OpenBSD: iked.c,v 1.63 2023/03/04 22:22:50 tobhe Exp $ */
+/* $OpenBSD: iked.c,v 1.64 2023/03/05 22:17:22 tobhe Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
int parent_dispatch_ikev2(int, struct privsep_proc *, struct imsg *);
int parent_configure(struct iked *);
+struct iked *iked_env;
+
static struct privsep_proc procs[] = {
{ "ca", PROC_CERT, parent_dispatch_ca, caproc, IKED_CA },
{ "control", PROC_CONTROL, parent_dispatch_control, control },
if ((env = calloc(1, sizeof(*env))) == NULL)
fatal("calloc: env");
+ iked_env = env;
env->sc_opts = opts;
env->sc_nattmode = natt_mode;
env->sc_nattport = port;
int
parent_dispatch_ca(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
switch (imsg->hdr.type) {
case IMSG_OCSP_FD:
int
parent_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
int v;
char *str = NULL;
unsigned int type = imsg->hdr.type;
int
parent_dispatch_ikev2(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
switch (imsg->hdr.type) {
case IMSG_IF_ADDADDR:
-/* $OpenBSD: iked.h,v 1.209 2023/03/04 22:22:50 tobhe Exp $ */
+/* $OpenBSD: iked.h,v 1.210 2023/03/05 22:17:22 tobhe Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
const char *p_chroot;
struct passwd *p_pw;
struct privsep *p_ps;
- void (*p_shutdown)(struct privsep_proc *);
+ void (*p_shutdown)(void);
};
struct privsep_fd {
/* iked.c */
void parent_reload(struct iked *, int, const char *);
+extern struct iked *iked_env;
+
/* control.c */
void control(struct privsep *, struct privsep_proc *);
int control_init(struct privsep *, struct control_sock *);
-/* $OpenBSD: ikev2.c,v 1.363 2023/03/04 22:22:50 tobhe Exp $ */
+/* $OpenBSD: ikev2.c,v 1.364 2023/03/05 22:17:22 tobhe Exp $ */
/*
* Copyright (c) 2019 Tobias Heider <tobias.heider@stusta.de>
void ikev2_log_cert_info(const char *, struct iked_id *);
void ikev2_run(struct privsep *, struct privsep_proc *, void *);
-void ikev2_shutdown(struct privsep_proc *);
+void ikev2_shutdown(void);
int ikev2_dispatch_parent(int, struct privsep_proc *, struct imsg *);
int ikev2_dispatch_cert(int, struct privsep_proc *, struct imsg *);
int ikev2_dispatch_control(int, struct privsep_proc *, struct imsg *);
}
void
-ikev2_shutdown(struct privsep_proc *p)
+ikev2_shutdown(void)
{
- struct iked *env;
-
- if (p->p_ps == NULL)
- return;
-
- env = p->p_ps->ps_env;
- if (env == NULL)
- return;
+ struct iked *env = iked_env;
ibuf_release(env->sc_certreq);
env->sc_certreq = NULL;
int
ikev2_dispatch_parent(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
struct iked_sa *sa, *satmp;
struct iked_policy *pol, *old;
int
ikev2_dispatch_cert(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
struct iked_sahdr sh;
struct iked_sa *sa;
uint8_t type;
int
ikev2_dispatch_control(int fd, struct privsep_proc *p, struct imsg *imsg)
{
- struct iked *env = p->p_ps->ps_env;
+ struct iked *env = iked_env;
switch (imsg->hdr.type) {
case IMSG_CTL_RESET_ID:
-/* $OpenBSD: proc.c,v 1.37 2023/03/04 22:22:51 tobhe Exp $ */
+/* $OpenBSD: proc.c,v 1.38 2023/03/05 22:17:22 tobhe Exp $ */
/*
* Copyright (c) 2010 - 2016 Reyk Floeter <reyk@openbsd.org>
struct privsep *ps = p->p_ps;
if (p->p_shutdown != NULL)
- (*p->p_shutdown)(p);
+ (*p->p_shutdown)();
proc_close(ps);