diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2010-01-10 16:42:36 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2010-01-10 16:42:36 +0000 |
commit | 6da0bc7f38345d7dd3b9755ca396488764f8a274 (patch) | |
tree | 224f5d8e066b53562cac30eb68f414a99b1d2ee8 /usr.sbin/smtpd/control.c | |
parent | b39b103c9261484e58be3bd3bc32f86fca82d39d (diff) |
- teach runner how to remove a message from queue given a message id/uid
and assuming message is not in processing/scheduled state
- teach smtpctl how to request message removal from runner
discussed with todd@, idea ok jacekm@
Diffstat (limited to 'usr.sbin/smtpd/control.c')
-rw-r--r-- | usr.sbin/smtpd/control.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/usr.sbin/smtpd/control.c b/usr.sbin/smtpd/control.c index dae67ae6aae..53d94339755 100644 --- a/usr.sbin/smtpd/control.c +++ b/usr.sbin/smtpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.45 2010/01/03 14:37:37 chl Exp $ */ +/* $OpenBSD: control.c,v 1.46 2010/01/10 16:42:35 gilles Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org> @@ -363,6 +363,27 @@ control_dispatch_ext(int fd, short event, void *arg) imsg_compose_event(env->sc_ievs[PROC_RUNNER], IMSG_RUNNER_SCHEDULE, 0, 0, -1, s, sizeof(*s)); break; } + + case IMSG_RUNNER_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_RUNNER], IMSG_RUNNER_REMOVE, 0, 0, -1, s, sizeof(*s)); + break; + } /* case IMSG_CONF_RELOAD: { struct reload r; @@ -766,6 +787,24 @@ control_dispatch_runner(int sig, short event, void *p) imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); break; } + case IMSG_RUNNER_REMOVE: { + struct remove *s = imsg.data; + struct ctl_conn *c; + + IMSG_SIZE_CHECK(s); + + if ((c = control_connbyfd(s->fd)) == NULL) { + log_warn("control_dispatch_runner: fd %d not found", s->fd); + imsg_free(&imsg); + return; + } + + if (s->ret) + imsg_compose_event(&c->iev, IMSG_CTL_OK, 0, 0, -1, NULL, 0); + else + imsg_compose_event(&c->iev, IMSG_CTL_FAIL, 0, 0, -1, NULL, 0); + break; + } default: log_warnx("control_dispatch_runner: got imsg %d", imsg.hdr.type); |