diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/httpd/config.c | 24 | ||||
-rw-r--r-- | usr.sbin/httpd/httpd.c | 11 | ||||
-rw-r--r-- | usr.sbin/httpd/httpd.h | 10 | ||||
-rw-r--r-- | usr.sbin/httpd/logger.c | 6 | ||||
-rw-r--r-- | usr.sbin/httpd/proc.c | 26 | ||||
-rw-r--r-- | usr.sbin/httpd/server.c | 5 |
6 files changed, 46 insertions, 36 deletions
diff --git a/usr.sbin/httpd/config.c b/usr.sbin/httpd/config.c index 853602869a0..0187ad5fad7 100644 --- a/usr.sbin/httpd/config.c +++ b/usr.sbin/httpd/config.c @@ -1,4 +1,4 @@ -/* $OpenBSD: config.c,v 1.43 2015/08/20 13:00:23 reyk Exp $ */ +/* $OpenBSD: config.c,v 1.44 2015/12/02 15:13:00 reyk Exp $ */ /* * Copyright (c) 2011 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -113,7 +113,7 @@ config_setreset(struct httpd *env, unsigned int reset) if ((reset & ps->ps_what[id]) == 0 || id == privsep_process) continue; - proc_compose_imsg(ps, id, -1, IMSG_CTL_RESET, -1, + proc_compose(ps, id, IMSG_CTL_RESET, &reset, sizeof(reset)); } @@ -151,8 +151,8 @@ config_getcfg(struct httpd *env, struct imsg *imsg) what = ps->ps_what[privsep_process]; if (privsep_process != PROC_PARENT) - proc_compose_imsg(env->sc_ps, PROC_PARENT, -1, - IMSG_CFG_DONE, -1, NULL, 0); + proc_compose(env->sc_ps, PROC_PARENT, + IMSG_CFG_DONE, NULL, 0); return (0); } @@ -205,7 +205,7 @@ config_setserver(struct httpd *env, struct server *srv) else if ((fd = dup(srv->srv_s)) == -1) return (-1); if (proc_composev_imsg(ps, id, n, - IMSG_CFG_SERVER, fd, iov, c) != 0) { + IMSG_CFG_SERVER, -1, fd, iov, c) != 0) { log_warn("%s: failed to compose " "IMSG_CFG_SERVER imsg for `%s'", __func__, srv->srv_conf.name); @@ -216,7 +216,7 @@ config_setserver(struct httpd *env, struct server *srv) /* Configure TLS if necessary. */ config_settls(env, srv); } else { - if (proc_composev_imsg(ps, id, -1, IMSG_CFG_SERVER, -1, + if (proc_composev(ps, id, IMSG_CFG_SERVER, iov, c) != 0) { log_warn("%s: failed to compose " "IMSG_CFG_SERVER imsg for `%s'", @@ -259,8 +259,7 @@ config_settls(struct httpd *env, struct server *srv) iov[c].iov_base = srv->srv_conf.tls_cert; iov[c++].iov_len = srv->srv_conf.tls_cert_len; - if (proc_composev_imsg(ps, PROC_SERVER, -1, IMSG_CFG_TLS, -1, - iov, c) != 0) { + if (proc_composev(ps, PROC_SERVER, IMSG_CFG_TLS, iov, c) != 0) { log_warn("%s: failed to compose IMSG_CFG_TLS imsg for " "`%s'", __func__, srv->srv_conf.name); return (-1); @@ -284,8 +283,7 @@ config_settls(struct httpd *env, struct server *srv) iov[c].iov_base = srv->srv_conf.tls_key; iov[c++].iov_len = srv->srv_conf.tls_key_len; - if (proc_composev_imsg(ps, PROC_SERVER, -1, IMSG_CFG_TLS, -1, - iov, c) != 0) { + if (proc_composev(ps, PROC_SERVER, IMSG_CFG_TLS, iov, c) != 0) { log_warn("%s: failed to compose IMSG_CFG_TLS imsg for " "`%s'", __func__, srv->srv_conf.name); return (-1); @@ -628,8 +626,7 @@ config_setmedia(struct httpd *env, struct media_type *media) DPRINTF("%s: sending media \"%s\" to %s", __func__, media->media_name, ps->ps_title[id]); - proc_compose_imsg(ps, id, -1, IMSG_CFG_MEDIA, -1, - media, sizeof(*media)); + proc_compose(ps, id, IMSG_CFG_MEDIA, media, sizeof(*media)); } return (0); @@ -676,8 +673,7 @@ config_setauth(struct httpd *env, struct auth *auth) DPRINTF("%s: sending auth \"%s[%u]\" to %s", __func__, auth->auth_htpasswd, auth->auth_id, ps->ps_title[id]); - proc_compose_imsg(ps, id, -1, IMSG_CFG_AUTH, -1, - auth, sizeof(*auth)); + proc_compose(ps, id, IMSG_CFG_AUTH, auth, sizeof(*auth)); } return (0); diff --git a/usr.sbin/httpd/httpd.c b/usr.sbin/httpd/httpd.c index 59c4f57c9eb..6b9b25bd7af 100644 --- a/usr.sbin/httpd/httpd.c +++ b/usr.sbin/httpd/httpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.c,v 1.50 2015/11/23 20:56:14 reyk Exp $ */ +/* $OpenBSD: httpd.c,v 1.51 2015/12/02 15:13:00 reyk Exp $ */ /* * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> @@ -339,8 +339,7 @@ parent_configure(struct httpd *env) cf.cf_opts = env->sc_opts; cf.cf_flags = env->sc_flags; - proc_compose_imsg(env->sc_ps, id, -1, IMSG_CFG_DONE, -1, - &cf, sizeof(cf)); + proc_compose(env->sc_ps, id, IMSG_CFG_DONE, &cf, sizeof(cf)); } ret = 0; @@ -385,8 +384,7 @@ parent_reload(struct httpd *env, unsigned int reset, const char *filename) void parent_reopen(struct httpd *env) { - proc_compose_imsg(env->sc_ps, PROC_LOGGER, -1, IMSG_CTL_REOPEN, - -1, NULL, 0); + proc_compose(env->sc_ps, PROC_LOGGER, IMSG_CTL_REOPEN, NULL, 0); } void @@ -405,8 +403,7 @@ parent_configure_done(struct httpd *env) if (id == privsep_process) continue; - proc_compose_imsg(env->sc_ps, id, -1, IMSG_CTL_START, - -1, NULL, 0); + proc_compose(env->sc_ps, id, IMSG_CTL_START, NULL, 0); } } } diff --git a/usr.sbin/httpd/httpd.h b/usr.sbin/httpd/httpd.h index 0e8e3925a6b..c1e78c9e8cb 100644 --- a/usr.sbin/httpd/httpd.h +++ b/usr.sbin/httpd/httpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: httpd.h,v 1.101 2015/11/23 20:56:14 reyk Exp $ */ +/* $OpenBSD: httpd.h,v 1.102 2015/12/02 15:13:00 reyk Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -694,9 +694,13 @@ pid_t proc_run(struct privsep *, struct privsep_proc *, void (*)(struct privsep *, struct privsep_proc *, void *), void *); void proc_range(struct privsep *, enum privsep_procid, int *, int *); int proc_compose_imsg(struct privsep *, enum privsep_procid, int, - uint16_t, int, void *, uint16_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, - uint16_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/httpd/logger.c b/usr.sbin/httpd/logger.c index 8ed55576602..a212fb13068 100644 --- a/usr.sbin/httpd/logger.c +++ b/usr.sbin/httpd/logger.c @@ -1,4 +1,4 @@ -/* $OpenBSD: logger.c,v 1.14 2015/11/05 18:00:43 florian Exp $ */ +/* $OpenBSD: logger.c,v 1.15 2015/12/02 15:13:00 reyk Exp $ */ /* * Copyright (c) 2014 Reyk Floeter <reyk@openbsd.org> @@ -121,7 +121,7 @@ logger_open_file(const char *name) iov[1].iov_base = log->log_name; iov[1].iov_len = strlen(log->log_name) + 1; - if (proc_composev_imsg(env->sc_ps, PROC_PARENT, -1, IMSG_LOG_OPEN, -1, + if (proc_composev(env->sc_ps, PROC_PARENT, IMSG_LOG_OPEN, iov, 2) != 0) { log_warn("%s: failed to compose IMSG_LOG_OPEN imsg", __func__); goto err; @@ -191,7 +191,7 @@ logger_open_priv(struct imsg *imsg) return (-1); } - proc_compose_imsg(env->sc_ps, PROC_LOGGER, -1, IMSG_LOG_OPEN, fd, + proc_compose_imsg(env->sc_ps, PROC_LOGGER, -1, IMSG_LOG_OPEN, -1, fd, &id, sizeof(id)); DPRINTF("%s: opened log file %s, fd %d", __func__, path, fd); diff --git a/usr.sbin/httpd/proc.c b/usr.sbin/httpd/proc.c index b93d74abb02..f3561f0de52 100644 --- a/usr.sbin/httpd/proc.c +++ b/usr.sbin/httpd/proc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.c,v 1.12 2015/11/23 20:56:14 reyk Exp $ */ +/* $OpenBSD: proc.c,v 1.13 2015/12/02 15:13:00 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/httpd/server.c b/usr.sbin/httpd/server.c index 5811a6308e9..13bbcd1ad52 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.82 2015/11/23 20:56:14 reyk Exp $ */ +/* $OpenBSD: server.c,v 1.83 2015/12/02 15:13:00 reyk Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -1020,8 +1020,7 @@ server_sendlog(struct server_config *srv_conf, int cmd, const char *emsg, ...) iov[1].iov_base = msg; iov[1].iov_len = strlen(msg) + 1; - if (proc_composev_imsg(env->sc_ps, PROC_LOGGER, -1, cmd, -1, iov, - 2) != 0) { + if (proc_composev(env->sc_ps, PROC_LOGGER, cmd, iov, 2) != 0) { log_warn("%s: failed to compose imsg", __func__); return; } |