summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/snmpd/proc.c26
-rw-r--r--usr.sbin/snmpd/snmpd.h10
-rw-r--r--usr.sbin/snmpd/traphandler.c6
3 files changed, 30 insertions, 12 deletions
diff --git a/usr.sbin/snmpd/proc.c b/usr.sbin/snmpd/proc.c
index 9b135411889..5f1647bc878 100644
--- a/usr.sbin/snmpd/proc.c
+++ b/usr.sbin/snmpd/proc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.c,v 1.18 2015/12/05 13:14:40 claudio Exp $ */
+/* $OpenBSD: proc.c,v 1.19 2015/12/07 12:33:08 reyk Exp $ */
/*
* Copyright (c) 2010 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -576,14 +576,14 @@ proc_range(struct privsep *ps, enum privsep_procid id, int *n, int *m)
int
proc_compose_imsg(struct privsep *ps, enum privsep_procid id, int n,
- uint16_t type, int fd, void *data, uint16_t datalen)
+ uint16_t type, uint32_t peerid, int fd, void *data, uint16_t datalen)
{
int m;
proc_range(ps, id, &n, &m);
for (; n < m; n++) {
if (imsg_compose_event(&ps->ps_ievs[id][n],
- type, -1, 0, fd, data, datalen) == -1)
+ type, peerid, 0, fd, data, datalen) == -1)
return (-1);
}
@@ -591,26 +591,40 @@ proc_compose_imsg(struct privsep *ps, enum privsep_procid id, int n,
}
int
+proc_compose(struct privsep *ps, enum privsep_procid id,
+ uint16_t type, void *data, uint16_t datalen)
+{
+ return (proc_compose_imsg(ps, id, -1, type, -1, -1, data, datalen));
+}
+
+int
proc_composev_imsg(struct privsep *ps, enum privsep_procid id, int n,
- uint16_t type, int fd, const struct iovec *iov, int iovcnt)
+ uint16_t type, uint32_t peerid, int fd, const struct iovec *iov, int iovcnt)
{
int m;
proc_range(ps, id, &n, &m);
for (; n < m; n++)
if (imsg_composev_event(&ps->ps_ievs[id][n],
- type, -1, 0, fd, iov, iovcnt) == -1)
+ type, peerid, 0, fd, iov, iovcnt) == -1)
return (-1);
return (0);
}
int
+proc_composev(struct privsep *ps, enum privsep_procid id,
+ uint16_t type, const struct iovec *iov, int iovcnt)
+{
+ return (proc_composev_imsg(ps, id, -1, type, -1, -1, iov, iovcnt));
+}
+
+int
proc_forward_imsg(struct privsep *ps, struct imsg *imsg,
enum privsep_procid id, int n)
{
return (proc_compose_imsg(ps, id, n, imsg->hdr.type,
- imsg->fd, imsg->data, IMSG_DATA_SIZE(imsg)));
+ imsg->hdr.peerid, imsg->fd, imsg->data, IMSG_DATA_SIZE(imsg)));
}
struct imsgbuf *
diff --git a/usr.sbin/snmpd/snmpd.h b/usr.sbin/snmpd/snmpd.h
index 77c580569d3..32fa84134e5 100644
--- a/usr.sbin/snmpd/snmpd.h
+++ b/usr.sbin/snmpd/snmpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: snmpd.h,v 1.65 2015/11/23 19:31:52 reyk Exp $ */
+/* $OpenBSD: snmpd.h,v 1.66 2015/12/07 12:33:08 reyk Exp $ */
/*
* Copyright (c) 2007, 2008, 2012 Reyk Floeter <reyk@openbsd.org>
@@ -737,9 +737,13 @@ int imsg_composev_event(struct imsgev *, u_int16_t, u_int32_t,
pid_t, int, const struct iovec *, int);
void proc_range(struct privsep *, enum privsep_procid, int *, int *);
int proc_compose_imsg(struct privsep *, enum privsep_procid, int,
- u_int16_t, int, void *, u_int16_t);
+ u_int16_t, u_int32_t, int, void *, u_int16_t);
+int proc_compose(struct privsep *, enum privsep_procid,
+ uint16_t, void *, uint16_t);
int proc_composev_imsg(struct privsep *, enum privsep_procid, int,
- u_int16_t, int, const struct iovec *, int);
+ u_int16_t, u_int32_t, int, const struct iovec *, int);
+int proc_composev(struct privsep *, enum privsep_procid,
+ uint16_t, const struct iovec *, int);
int proc_forward_imsg(struct privsep *, struct imsg *,
enum privsep_procid, int);
struct imsgbuf *
diff --git a/usr.sbin/snmpd/traphandler.c b/usr.sbin/snmpd/traphandler.c
index 18451f3a699..7b3f42da127 100644
--- a/usr.sbin/snmpd/traphandler.c
+++ b/usr.sbin/snmpd/traphandler.c
@@ -1,4 +1,5 @@
-/* $OpenBSD: traphandler.c,v 1.3 2015/11/22 13:27:13 reyk Exp $ */
+/* $OpenBSD: traphandler.c,v 1.4 2015/12/07 12:33:08 reyk Exp $ */
+
/*
* Copyright (c) 2014 Bret Stephen Lambert <blambert@openbsd.org>
*
@@ -177,8 +178,7 @@ traphandler_recvmsg(int fd, short events, void *arg)
iov[1].iov_len = n;
/* Forward it to the parent process */
- if (proc_composev_imsg(ps, PROC_PARENT, -1, IMSG_ALERT,
- -1, iov, 2) == -1)
+ if (proc_composev(ps, PROC_PARENT, IMSG_ALERT, iov, 2) == -1)
goto done;
done: