diff options
author | 2009-07-28 13:53:51 +0000 | |
---|---|---|
committer | 2009-07-28 13:53:51 +0000 | |
commit | a45e2add76c9e79f1a353d5be1ba80eb2c305d06 (patch) | |
tree | 2a9f27e715c00724496448b7a8871b05d51db535 | |
parent | Recommit rev. 1.446 it is again possible to use DSCP names in tos and settos (diff) | |
download | wireguard-openbsd-a45e2add76c9e79f1a353d5be1ba80eb2c305d06.tar.xz wireguard-openbsd-a45e2add76c9e79f1a353d5be1ba80eb2c305d06.zip |
add missing bit to correctly spot loops in all cases.
at the moment we only break out of the loop, but do not generate
mailer daemon, this will come soon.
ok pyr@, tested by me with help from gui at iroqwa dot org
-rw-r--r-- | usr.sbin/smtpd/store.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/usr.sbin/smtpd/store.c b/usr.sbin/smtpd/store.c index d96e32a71f4..1d901084cff 100644 --- a/usr.sbin/smtpd/store.c +++ b/usr.sbin/smtpd/store.c @@ -1,4 +1,4 @@ -/* $OpenBSD: store.c,v 1.19 2009/06/05 21:55:40 jacekm Exp $ */ +/* $OpenBSD: store.c,v 1.20 2009/07/28 13:53:51 gilles Exp $ */ /* * Copyright (c) 2008 Gilles Chehade <gilles@openbsd.org> @@ -26,6 +26,7 @@ #include <netinet/in.h> #include <arpa/inet.h> +#include <ctype.h> #include <err.h> #include <errno.h> #include <event.h> @@ -37,15 +38,16 @@ #include "smtpd.h" -int file_copy(FILE *, FILE *, enum action_type); +int file_copy(FILE *, FILE *, struct path *, enum action_type); int -file_copy(FILE *dest, FILE *src, enum action_type type) +file_copy(FILE *dest, FILE *src, struct path *path, enum action_type type) { char *buf, *lbuf; size_t len; char *escape; - + int inheaders = 1; + lbuf = NULL; while ((buf = fgetln(src, &len))) { if (buf[len - 1] == '\n') { @@ -61,6 +63,18 @@ file_copy(FILE *dest, FILE *src, enum action_type type) buf = lbuf; } + /* If we are NOT dealing with a mailer daemon copy, we have + * path set to the original recipient. In that case, we can + * add the X-OpenSMTPD-Loop header to help loop detection. + */ + if (path != NULL && inheaders && + strchr(buf, ':') == NULL && !isspace(*buf)) { + if (fprintf(dest, "X-OpenSMTPD-Loop: %s@%s\n", + path->user, path->domain) == -1) + return 0; + inheaders = 0; + } + if (type == A_MBOX) { escape = buf; while (*escape == '>') @@ -160,7 +174,8 @@ store_write_daemon(struct batch *batchp, struct message *messagep) if (fprintf(mboxfp, "Below is a copy of the original message:\n\n") == -1) goto bad; - if (! file_copy(mboxfp, messagefp, messagep->recipient.rule.r_action)) + if (! file_copy(mboxfp, messagefp, NULL, + messagep->recipient.rule.r_action)) goto bad; fflush(mboxfp); @@ -193,7 +208,8 @@ store_write_message(struct batch *batchp, struct message *messagep) if (messagefp == NULL) goto bad; - if (! file_copy(mboxfp, messagefp, messagep->recipient.rule.r_action)) + if (! file_copy(mboxfp, messagefp, &messagep->session_rcpt, + messagep->recipient.rule.r_action)) goto bad; fflush(mboxfp); |