summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.sbin/smtpd/ioev.c7
-rw-r--r--usr.sbin/smtpd/ioev.h4
-rw-r--r--usr.sbin/smtpd/mta_session.c4
3 files changed, 9 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/ioev.c b/usr.sbin/smtpd/ioev.c
index 2b6f5bc65d0..69e9c93ce8e 100644
--- a/usr.sbin/smtpd/ioev.c
+++ b/usr.sbin/smtpd/ioev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioev.c,v 1.5 2012/09/14 19:20:52 eric Exp $ */
+/* $OpenBSD: ioev.c,v 1.6 2012/10/10 19:38:04 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -575,7 +575,7 @@ io_callback(struct io *io, int evt)
}
int
-io_connect(struct io *io, const struct sockaddr *sa)
+io_connect(struct io *io, const struct sockaddr *sa, const struct sockaddr *bsa)
{
int sock, errno_save;
@@ -585,6 +585,9 @@ io_connect(struct io *io, const struct sockaddr *sa)
io_set_blocking(sock, 0);
io_set_linger(sock, 0);
+ if (bsa && bind(sock, bsa, bsa->sa_len) == -1)
+ goto fail;
+
if (connect(sock, sa, sa->sa_len) == -1)
if (errno != EINPROGRESS)
goto fail;
diff --git a/usr.sbin/smtpd/ioev.h b/usr.sbin/smtpd/ioev.h
index 721a1aa925e..ffd9a0e9837 100644
--- a/usr.sbin/smtpd/ioev.h
+++ b/usr.sbin/smtpd/ioev.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioev.h,v 1.1 2012/01/29 00:32:51 eric Exp $ */
+/* $OpenBSD: ioev.h,v 1.2 2012/10/10 19:38:04 eric Exp $ */
/*
* Copyright (c) 2012 Eric Faurot <eric@openbsd.org>
*
@@ -61,7 +61,7 @@ void io_set_lowat(struct io *, size_t);
void io_pause(struct io *, int);
void io_resume(struct io *, int);
void io_reload(struct io *);
-int io_connect(struct io *, const struct sockaddr *);
+int io_connect(struct io *, const struct sockaddr *, const struct sockaddr *);
int io_start_tls(struct io *, void *);
const char* io_strio(struct io *);
const char* io_strevent(int);
diff --git a/usr.sbin/smtpd/mta_session.c b/usr.sbin/smtpd/mta_session.c
index fbaa86c6f1c..4f90b1d67ca 100644
--- a/usr.sbin/smtpd/mta_session.c
+++ b/usr.sbin/smtpd/mta_session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mta_session.c,v 1.22 2012/10/07 15:46:38 chl Exp $ */
+/* $OpenBSD: mta_session.c,v 1.23 2012/10/10 19:38:04 eric Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -360,7 +360,7 @@ mta_enter_state(struct mta_session *s, int newstate)
iobuf_xinit(&s->iobuf, 0, 0, "mta_enter_state");
io_init(&s->io, -1, s, mta_io, &s->iobuf);
io_set_timeout(&s->io, 10000);
- if (io_connect(&s->io, sa) == -1) {
+ if (io_connect(&s->io, sa, NULL) == -1) {
log_debug("mta: %p: connection failed: %s", s,
strerror(errno));
iobuf_clear(&s->iobuf);