summaryrefslogtreecommitdiff
path: root/usr.sbin/smtpd/lka.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/smtpd/lka.c')
-rw-r--r--usr.sbin/smtpd/lka.c84
1 files changed, 48 insertions, 36 deletions
diff --git a/usr.sbin/smtpd/lka.c b/usr.sbin/smtpd/lka.c
index 17e53aa6bed..5542b9937d0 100644
--- a/usr.sbin/smtpd/lka.c
+++ b/usr.sbin/smtpd/lka.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lka.c,v 1.58 2009/06/05 20:43:57 pyr Exp $ */
+/* $OpenBSD: lka.c,v 1.59 2009/06/06 04:14:21 pyr Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -98,18 +98,20 @@ void
lka_dispatch_parent(int sig, short event, void *p)
{
struct smtpd *env = p;
+ struct imsgev *iev;
struct imsgbuf *ibuf;
struct imsg imsg;
ssize_t n;
- ibuf = env->sc_ibufs[PROC_PARENT];
+ iev = env->sc_ievs[PROC_PARENT];
+ ibuf = &iev->ibuf;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
/* this pipe is dead, so remove the event handler */
- event_del(&ibuf->ev);
+ event_del(&iev->ev);
event_loopexit(NULL);
return;
}
@@ -260,12 +262,12 @@ lka_dispatch_parent(int sig, short event, void *p)
log_debug("expansion failed...");
}
- imsg_compose_event(env->sc_ibufs[PROC_QUEUE],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_SUBMIT_ENVELOPE, 0, 0, -1,
&message, sizeof(struct message));
if (! lkasession->pending)
- imsg_compose_event(env->sc_ibufs[PROC_QUEUE],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_COMMIT_ENVELOPES, 0, 0, -1,
&message, sizeof(struct message));
break;
@@ -288,25 +290,27 @@ lka_dispatch_parent(int sig, short event, void *p)
}
imsg_free(&imsg);
}
- imsg_event_add(ibuf);
+ imsg_event_add(iev);
}
void
lka_dispatch_mfa(int sig, short event, void *p)
{
struct smtpd *env = p;
+ struct imsgev *iev;
struct imsgbuf *ibuf;
struct imsg imsg;
ssize_t n;
- ibuf = env->sc_ibufs[PROC_MFA];
+ iev = env->sc_ievs[PROC_MFA];
+ ibuf = &iev->ibuf;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
/* this pipe is dead, so remove the event handler */
- event_del(&ibuf->ev);
+ event_del(&iev->ev);
event_loopexit(NULL);
return;
}
@@ -337,7 +341,7 @@ lka_dispatch_mfa(int sig, short event, void *p)
if (lka_verify_mail(env, &ss->u.path))
ss->code = 250;
- imsg_compose_event(ibuf, IMSG_LKA_MAIL, 0, 0, -1,
+ imsg_compose_event(iev, IMSG_LKA_MAIL, 0, 0, -1,
ss, sizeof(*ss));
break;
@@ -357,17 +361,17 @@ lka_dispatch_mfa(int sig, short event, void *p)
ss->code = 250;
message = ss->msg;
message.recipient = ss->u.path;
- imsg_compose_event(env->sc_ibufs[PROC_QUEUE],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_SUBMIT_ENVELOPE, 0, 0, -1,
&message, sizeof(struct message));
- imsg_compose_event(env->sc_ibufs[PROC_QUEUE],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_COMMIT_ENVELOPES, 0, 0, -1,
&message, sizeof(struct message));
break;
}
if (! lka_resolve_path(env, &ss->u.path)) {
- imsg_compose_event(ibuf, IMSG_LKA_RCPT, 0, 0, -1,
+ imsg_compose_event(iev, IMSG_LKA_RCPT, 0, 0, -1,
ss, sizeof(*ss));
break;
}
@@ -390,7 +394,7 @@ lka_dispatch_mfa(int sig, short event, void *p)
if (lkasession->path.flags & F_PATH_ACCOUNT) {
fwreq.id = lkasession->id;
(void)strlcpy(fwreq.pw_name, ss->u.path.pw_name, sizeof(fwreq.pw_name));
- imsg_compose_event(env->sc_ibufs[PROC_PARENT], IMSG_PARENT_FORWARD_OPEN, 0, 0, -1,
+ imsg_compose_event(env->sc_ievs[PROC_PARENT], IMSG_PARENT_FORWARD_OPEN, 0, 0, -1,
&fwreq, sizeof(fwreq));
++lkasession->pending;
break;
@@ -407,7 +411,7 @@ lka_dispatch_mfa(int sig, short event, void *p)
if (ret == 0) {
/* No aliases ... */
ss->code = 530;
- imsg_compose_event(ibuf, IMSG_LKA_RCPT, 0, 0,
+ imsg_compose_event(iev, IMSG_LKA_RCPT, 0, 0,
-1, ss, sizeof(*ss));
break;
}
@@ -423,25 +427,27 @@ lka_dispatch_mfa(int sig, short event, void *p)
}
imsg_free(&imsg);
}
- imsg_event_add(ibuf);
+ imsg_event_add(iev);
}
void
lka_dispatch_mta(int sig, short event, void *p)
{
struct smtpd *env = p;
+ struct imsgev *iev;
struct imsgbuf *ibuf;
struct imsg imsg;
ssize_t n;
- ibuf = env->sc_ibufs[PROC_MTA];
+ iev = env->sc_ievs[PROC_MTA];
+ ibuf = &iev->ibuf;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
/* this pipe is dead, so remove the event handler */
- event_del(&ibuf->ev);
+ event_del(&iev->ev);
event_loopexit(NULL);
return;
}
@@ -482,7 +488,7 @@ lka_dispatch_mta(int sig, short event, void *p)
query->host, map);
}
- imsg_compose_event(ibuf, IMSG_LKA_SECRET, 0, 0, -1, query,
+ imsg_compose_event(iev, IMSG_LKA_SECRET, 0, 0, -1, query,
sizeof(*query));
free(secret);
break;
@@ -493,7 +499,7 @@ lka_dispatch_mta(int sig, short event, void *p)
struct dns *query = imsg.data;
IMSG_SIZE_CHECK(query);
- dns_async(env, ibuf, imsg.hdr.type, query);
+ dns_async(env, iev, imsg.hdr.type, query);
break;
}
@@ -504,25 +510,27 @@ lka_dispatch_mta(int sig, short event, void *p)
}
imsg_free(&imsg);
}
- imsg_event_add(ibuf);
+ imsg_event_add(iev);
}
void
lka_dispatch_smtp(int sig, short event, void *p)
{
struct smtpd *env = p;
+ struct imsgev *iev;
struct imsgbuf *ibuf;
struct imsg imsg;
ssize_t n;
- ibuf = env->sc_ibufs[PROC_SMTP];
+ iev = env->sc_ievs[PROC_SMTP];
+ ibuf = &iev->ibuf;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
/* this pipe is dead, so remove the event handler */
- event_del(&ibuf->ev);
+ event_del(&iev->ev);
event_loopexit(NULL);
return;
}
@@ -544,7 +552,7 @@ lka_dispatch_smtp(int sig, short event, void *p)
struct dns *query = imsg.data;
IMSG_SIZE_CHECK(query);
- dns_async(env, ibuf, IMSG_DNS_PTR, query);
+ dns_async(env, iev, IMSG_DNS_PTR, query);
break;
}
default:
@@ -554,25 +562,27 @@ lka_dispatch_smtp(int sig, short event, void *p)
}
imsg_free(&imsg);
}
- imsg_event_add(ibuf);
+ imsg_event_add(iev);
}
void
lka_dispatch_queue(int sig, short event, void *p)
{
struct smtpd *env = p;
+ struct imsgev *iev;
struct imsgbuf *ibuf;
struct imsg imsg;
ssize_t n;
- ibuf = env->sc_ibufs[PROC_QUEUE];
+ iev = env->sc_ievs[PROC_QUEUE];
+ ibuf = &iev->ibuf;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
/* this pipe is dead, so remove the event handler */
- event_del(&ibuf->ev);
+ event_del(&iev->ev);
event_loopexit(NULL);
return;
}
@@ -597,25 +607,27 @@ lka_dispatch_queue(int sig, short event, void *p)
}
imsg_free(&imsg);
}
- imsg_event_add(ibuf);
+ imsg_event_add(iev);
}
void
lka_dispatch_runner(int sig, short event, void *p)
{
struct smtpd *env = p;
+ struct imsgev *iev;
struct imsgbuf *ibuf;
struct imsg imsg;
ssize_t n;
- ibuf = env->sc_ibufs[PROC_RUNNER];
+ iev = env->sc_ievs[PROC_RUNNER];
+ ibuf = &iev->ibuf;
if (event & EV_READ) {
if ((n = imsg_read(ibuf)) == -1)
fatal("imsg_read_error");
if (n == 0) {
/* this pipe is dead, so remove the event handler */
- event_del(&ibuf->ev);
+ event_del(&iev->ev);
event_loopexit(NULL);
return;
}
@@ -640,7 +652,7 @@ lka_dispatch_runner(int sig, short event, void *p)
}
imsg_free(&imsg);
}
- imsg_event_add(ibuf);
+ imsg_event_add(iev);
}
void
@@ -968,16 +980,16 @@ lka_expand_rcpt(struct smtpd *env, struct aliaseslist *aliases, struct lkasessio
if (lkasession->flags & F_ERROR) {
lka_clear_aliaseslist(&lkasession->aliaseslist);
- imsg_compose_event(env->sc_ibufs[PROC_MFA], IMSG_LKA_RCPT, 0, 0,
+ imsg_compose_event(env->sc_ievs[PROC_MFA], IMSG_LKA_RCPT, 0, 0,
-1, &lkasession->ss, sizeof(struct submit_status));
}
else if (TAILQ_FIRST(&lkasession->aliaseslist) == NULL) {
message = lkasession->message;
message.recipient = lkasession->path;
- imsg_compose_event(env->sc_ibufs[PROC_QUEUE],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_SUBMIT_ENVELOPE, 0, 0, -1,
&message, sizeof(struct message));
- imsg_compose_event(env->sc_ibufs[PROC_QUEUE],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_COMMIT_ENVELOPES, 0, 0, -1,
&message, sizeof(struct message));
}
@@ -990,14 +1002,14 @@ lka_expand_rcpt(struct smtpd *env, struct aliaseslist *aliases, struct lkasessio
lka_resolve_alias(env, &message.recipient, alias);
lka_rcpt_action(env, &message.recipient);
- imsg_compose_event(env->sc_ibufs[PROC_QUEUE],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_SUBMIT_ENVELOPE, 0, 0, -1,
&message, sizeof(struct message));
TAILQ_REMOVE(&lkasession->aliaseslist, alias, entry);
free(alias);
}
- imsg_compose_event(env->sc_ibufs[PROC_QUEUE],
+ imsg_compose_event(env->sc_ievs[PROC_QUEUE],
IMSG_QUEUE_COMMIT_ENVELOPES, 0, 0, -1, &message,
sizeof(struct message));
}
@@ -1037,7 +1049,7 @@ lka_expand_rcpt_iteration(struct smtpd *env, struct aliaseslist *aliases, struct
done = 0;
fwreq.id = lkasession->id;
(void)strlcpy(fwreq.pw_name, alias->u.username, sizeof(fwreq.pw_name));
- imsg_compose_event(env->sc_ibufs[PROC_PARENT], IMSG_PARENT_FORWARD_OPEN, 0, 0, -1,
+ imsg_compose_event(env->sc_ievs[PROC_PARENT], IMSG_PARENT_FORWARD_OPEN, 0, 0, -1,
&fwreq, sizeof(fwreq));
++lkasession->pending;
rmalias = alias;