diff options
author | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-01-28 00:19:28 +0000 |
---|---|---|
committer | Gilles Chehade <gilles@cvs.openbsd.org> | 2009-01-28 00:19:28 +0000 |
commit | 4c132b4638ab8ba0c506c526fdb9061a615e7919 (patch) | |
tree | 83a80d15db72ec91bfa98ed0839feb7e71255887 | |
parent | 7e93894e94f3da1e3af1326c337d0479afb94a22 (diff) |
a bit of enqueue cleanup, and while at it set the sender local address to
::1 (fallback to 127.0.0.1) before sending the enqueue request.
-rw-r--r-- | usr.sbin/smtpd/enqueue.c | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/usr.sbin/smtpd/enqueue.c b/usr.sbin/smtpd/enqueue.c index 2438534dc44..e8c0470eeb4 100644 --- a/usr.sbin/smtpd/enqueue.c +++ b/usr.sbin/smtpd/enqueue.c @@ -1,4 +1,4 @@ -/* $OpenBSD: enqueue.c,v 1.2 2009/01/28 00:09:54 gilles Exp $ */ +/* $OpenBSD: enqueue.c,v 1.3 2009/01/28 00:19:27 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -92,12 +92,13 @@ enqueue(int argc, char *argv[]) argv += optind; bzero(&message, sizeof(struct message)); - + /* build sender */ if (! recipient_to_path(&message.sender, sender)) errx(1, "invalid sender address."); - + if (! enqueue_init(&message)) { + errx(1, "failed to initialize enqueue message."); return 1; } @@ -137,6 +138,7 @@ enqueue_add_recipient(struct message *messagep, char *recipient) { char buffer[MAX_PATH_SIZE]; struct message_recipient mr; + struct sockaddr_in6 *ssin6; struct sockaddr_in *ssin; struct message message; int done = 0; @@ -157,12 +159,16 @@ enqueue_add_recipient(struct message *messagep, char *recipient) return 0; } - /* NEEDS_FIX */ - mr.ss.ss_family = AF_INET; - mr.ss.ss_len = sizeof(ssin); - ssin = (struct sockaddr_in *)&mr.ss; - if (inet_pton(AF_INET, "127.0.0.1", &ssin->sin_addr) != 1) - return 0; + mr.ss.ss_family = AF_INET6; + mr.ss.ss_len = sizeof(ssin6); + ssin6 = (struct sockaddr_in6 *)&mr.ss; + if (inet_pton(AF_INET6, "::1", &ssin6->sin6_addr) != 1) { + mr.ss.ss_family = AF_INET; + mr.ss.ss_len = sizeof(ssin); + ssin = (struct sockaddr_in *)&mr.ss; + if (inet_pton(AF_INET, "127.0.0.1", &ssin->sin_addr) != 1) + return 0; + } mr.path = message.recipient; mr.id = message.session_id; |