diff options
author | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2010-06-01 19:47:10 +0000 |
---|---|---|
committer | Jacek Masiulaniec <jacekm@cvs.openbsd.org> | 2010-06-01 19:47:10 +0000 |
commit | d481f4e5ff358273fff595ce92426d61e61f20ef (patch) | |
tree | 549f1b72b9d56ecb755a3a41b8249d6e1a46528d /usr.sbin/smtpd/control.c | |
parent | fdc0afec05f06bcbcb993907421d9070c9987324 (diff) |
New queue doesn't compile on gcc2, back out. Spotted by deraadt@
Diffstat (limited to 'usr.sbin/smtpd/control.c')
-rw-r--r-- | usr.sbin/smtpd/control.c | 85 |
1 files changed, 60 insertions, 25 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index 4776727d3a4..3129a9abc04 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.50 2010/05/31 23:38:56 jacekm Exp $ */ +/* $OpenBSD: control.c,v 1.51 2010/06/01 19:47:08 jacekm Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -36,7 +36,6 @@ #include <unistd.h> #include "smtpd.h" -#include "queue_backend.h" #define CONTROL_BACKLOG 5 @@ -64,7 +63,8 @@ control_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg) { struct ctl_conn *c; struct reload *reload; - int error; + struct remove *rem; + struct sched *sched; if (iev->proc == PROC_SMTP) { switch (imsg->hdr.type) { @@ -81,17 +81,23 @@ control_imsg(struct smtpd *env, struct imsgev *iev, struct imsg *imsg) if (iev->proc == PROC_QUEUE) { switch (imsg->hdr.type) { case IMSG_QUEUE_SCHEDULE: + sched = imsg->data; + c = control_connbyfd(sched->fd); + if (c == NULL) + return; + imsg_compose_event(&c->iev, + sched->ret ? IMSG_CTL_OK : IMSG_CTL_FAIL, 0, 0, -1, + NULL, 0); + return; + case IMSG_QUEUE_REMOVE: - c = control_connbyfd(imsg->hdr.peerid); + rem = imsg->data; + c = control_connbyfd(rem->fd); if (c == NULL) return; - memcpy(&error, imsg->data, sizeof error); - if (error) - imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, - -1, NULL, 0); - else - imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, - -1, NULL, 0); + imsg_compose_event(&c->iev, + rem->ret ? IMSG_CTL_OK : IMSG_CTL_FAIL, 0, 0, + -1, NULL, 0); return; } } @@ -388,14 +394,47 @@ control_dispatch_ext(int fd, short event, void *arg) imsg_compose_event(&c->iev, IMSG_STATS, 0, 0, -1, env->stats, sizeof(struct stats)); break; - case IMSG_QUEUE_SCHEDULE: - case IMSG_QUEUE_REMOVE: - if (euid || IMSG_DATA_SIZE(&imsg) != sizeof(u_int64_t)) + case IMSG_QUEUE_SCHEDULE: { + struct sched *s = imsg.data; + + if (euid) goto badcred; - imsg_compose_event(env->sc_ievs[PROC_QUEUE], - imsg.hdr.type, fd, 0, -1, imsg.data, - sizeof(u_int64_t)); + + if (IMSG_DATA_SIZE(&imsg) != sizeof(*s)) + goto badcred; + + s->fd = fd; + + if (! valid_message_id(s->mid) && ! valid_message_uid(s->mid)) { + imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1, + NULL, 0); + break; + } + + imsg_compose_event(env->sc_ievs[PROC_QUEUE], IMSG_QUEUE_SCHEDULE, 0, 0, -1, s, sizeof(*s)); break; + } + + case IMSG_QUEUE_REMOVE: { + struct remove *s = imsg.data; + + if (euid) + goto badcred; + + if (IMSG_DATA_SIZE(&imsg) != sizeof(*s)) + goto badcred; + + s->fd = fd; + + if (! valid_message_id(s->mid) && ! valid_message_uid(s->mid)) { + imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1, + NULL, 0); + break; + } + + imsg_compose_event(env->sc_ievs[PROC_QUEUE], IMSG_QUEUE_REMOVE, 0, 0, -1, s, sizeof(*s)); + break; + } /* case IMSG_CONF_RELOAD: { struct reload r; @@ -452,19 +491,17 @@ control_dispatch_ext(int fd, short event, void *arg) if (euid) goto badcred; -#if 0 if (env->sc_flags & SMTPD_MDA_PAUSED) { imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); break; } -#endif env->sc_flags |= SMTPD_MDA_PAUSED; imsg_compose_event(env->sc_ievs[PROC_QUEUE], IMSG_QUEUE_PAUSE_LOCAL, 0, 0, -1, NULL, 0); imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0); break; - case IMSG_QUEUE_PAUSE_RELAY: + case IMSG_QUEUE_PAUSE_OUTGOING: if (euid) goto badcred; @@ -475,7 +512,7 @@ control_dispatch_ext(int fd, short event, void *arg) } env->sc_flags |= SMTPD_MTA_PAUSED; imsg_compose_event(env->sc_ievs[PROC_QUEUE], - IMSG_QUEUE_PAUSE_RELAY, 0, 0, -1, NULL, 0); + IMSG_QUEUE_PAUSE_OUTGOING, 0, 0, -1, NULL, 0); imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0); break; case IMSG_SMTP_PAUSE: @@ -496,19 +533,17 @@ control_dispatch_ext(int fd, short event, void *arg) if (euid) goto badcred; -#if 0 if (! (env->sc_flags & SMTPD_MDA_PAUSED)) { imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); break; } -#endif env->sc_flags &= ~SMTPD_MDA_PAUSED; imsg_compose_event(env->sc_ievs[PROC_QUEUE], IMSG_QUEUE_RESUME_LOCAL, 0, 0, -1, NULL, 0); imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0); break; - case IMSG_QUEUE_RESUME_RELAY: + case IMSG_QUEUE_RESUME_OUTGOING: if (euid) goto badcred; @@ -519,7 +554,7 @@ control_dispatch_ext(int fd, short event, void *arg) } env->sc_flags &= ~SMTPD_MTA_PAUSED; imsg_compose_event(env->sc_ievs[PROC_QUEUE], - IMSG_QUEUE_RESUME_RELAY, 0, 0, -1, NULL, 0); + IMSG_QUEUE_RESUME_OUTGOING, 0, 0, -1, NULL, 0); imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0); break; case IMSG_SMTP_RESUME: |