summaryrefslogtreecommitdiffstats
path: root/usr.sbin/vmd/proc.h
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2016-09-29 22:42:04 +0000
committerreyk <reyk@openbsd.org>2016-09-29 22:42:04 +0000
commitbcc679a146056243a2fd52a28182621f893fed4b (patch)
tree5be3c94554beeeaeb20db751361da0da536e63cb /usr.sbin/vmd/proc.h
parentfix DEBUG build after ps->ps_instance change (diff)
downloadwireguard-openbsd-bcc679a146056243a2fd52a28182621f893fed4b.tar.xz
wireguard-openbsd-bcc679a146056243a2fd52a28182621f893fed4b.zip
Implement fork+exec for vmd, using the same framework from httpd etc.
No objections from mlarkin@ sunil@
Diffstat (limited to 'usr.sbin/vmd/proc.h')
-rw-r--r--usr.sbin/vmd/proc.h34
1 files changed, 24 insertions, 10 deletions
diff --git a/usr.sbin/vmd/proc.h b/usr.sbin/vmd/proc.h
index 59ac73b1f1d..b8ebdcc5085 100644
--- a/usr.sbin/vmd/proc.h
+++ b/usr.sbin/vmd/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.6 2015/12/03 13:08:44 reyk Exp $ */
+/* $OpenBSD: proc.h,v 1.7 2016/09/29 22:42:04 reyk Exp $ */
/*
* Copyright (c) 2010-2015 Reyk Floeter <reyk@openbsd.org>
@@ -34,6 +34,7 @@ enum {
IMSG_CTL_END,
IMSG_CTL_NOTIFY,
IMSG_CTL_RESET,
+ IMSG_CTL_PROCFD,
IMSG_PROC_MAX
};
@@ -105,7 +106,6 @@ struct privsep {
struct imsgev *ps_ievs[PROC_MAX];
const char *ps_title[PROC_MAX];
- pid_t ps_pid[PROC_MAX];
uint8_t ps_what[PROC_MAX];
struct passwd *ps_pw;
@@ -115,7 +115,6 @@ struct privsep {
struct control_socks ps_rcsocks;
unsigned int ps_instances[PROC_MAX];
- unsigned int ps_ninstances;
unsigned int ps_instance;
/* Event and signal handlers */
@@ -134,21 +133,34 @@ struct privsep_proc {
enum privsep_procid p_id;
int (*p_cb)(int, struct privsep_proc *,
struct imsg *);
- pid_t (*p_init)(struct privsep *,
+ void (*p_init)(struct privsep *,
struct privsep_proc *);
const char *p_chroot;
struct privsep *p_ps;
- void *p_env;
void (*p_shutdown)(void);
- unsigned int p_instance;
};
+struct privsep_fd {
+ enum privsep_procid pf_procid;
+ unsigned int pf_instance;
+};
+
+#if DEBUG
+#define DPRINTF log_debug
+#else
+#define DPRINTF(x...) do {} while(0)
+#endif
+
+#define PROC_PARENT_SOCK_FILENO 3
+#define PROC_MAX_INSTANCES 32
+
/* proc.c */
-void proc_init(struct privsep *, struct privsep_proc *, unsigned int);
+void proc_init(struct privsep *, struct privsep_proc *, unsigned int,
+ int, char **, enum privsep_procid);
void proc_kill(struct privsep *);
-void proc_listen(struct privsep *, struct privsep_proc *, size_t);
+void proc_connect(struct privsep *ps);
void proc_dispatch(int, short event, void *);
-pid_t proc_run(struct privsep *, struct privsep_proc *,
+void proc_run(struct privsep *, struct privsep_proc *,
struct privsep_proc *, unsigned int,
void (*)(struct privsep *, struct privsep_proc *, void *), void *);
void imsg_event_add(struct imsgev *);
@@ -170,9 +182,11 @@ struct imsgbuf *
proc_ibuf(struct privsep *, enum privsep_procid, int);
struct imsgev *
proc_iev(struct privsep *, enum privsep_procid, int);
+enum privsep_procid
+ proc_getid(struct privsep_proc *, unsigned int, const char *);
/* control.c */
-pid_t control(struct privsep *, struct privsep_proc *);
+void control(struct privsep *, struct privsep_proc *);
int control_init(struct privsep *, struct control_sock *);
int control_listen(struct control_sock *);
void control_cleanup(struct control_sock *);