diff options
author | Phil Pennock <pdp@exim.org> | 2011-02-20 23:44:50 -0500 |
---|---|---|
committer | Phil Pennock <pdp@exim.org> | 2011-02-20 23:45:22 -0500 |
commit | 332f5cf3ddb43e1a85d70039211e73aa1a753ebd (patch) | |
tree | dcff58d76b286cdd4c4b54addcb116d712f1d889 | |
parent | cd59ab18b06626887aecef760c416ae7936924da (diff) |
Update $message_linecount for maildir_tag.
Patch from Mark Zealey.
Fixes bug 1055.
-rw-r--r-- | doc/doc-docbook/spec.xfpt | 11 | ||||
-rw-r--r-- | doc/doc-txt/ChangeLog | 3 | ||||
-rw-r--r-- | doc/doc-txt/NewStuff | 4 | ||||
-rw-r--r-- | src/src/globals.c | 1 | ||||
-rw-r--r-- | src/src/globals.h | 1 | ||||
-rw-r--r-- | src/src/transport.c | 1 | ||||
-rw-r--r-- | src/src/transports/appendfile.c | 21 |
7 files changed, 36 insertions, 6 deletions
diff --git a/doc/doc-docbook/spec.xfpt b/doc/doc-docbook/spec.xfpt index bc9dd2e14..15f104d2b 100644 --- a/doc/doc-docbook/spec.xfpt +++ b/doc/doc-docbook/spec.xfpt @@ -11137,8 +11137,15 @@ number of lines received. Before delivery happens (that is, before filters, routers, and transports run) the count is increased to include the &'Received:'& header line that Exim standardly adds, and also any other header lines that are added by ACLs. The blank line that separates the message header -from the body is not counted. Here is an example of the use of this variable in -a DATA ACL: +from the body is not counted. + +As with the special case of &$message_size$&, during the expansion of the +appendfile transport's maildir_tag option in maildir format, the value of +&$message_linecount$& is the precise size of the number of newlines in the +file that has been written (minus one for the blank line between the +header and the body). + +Here is an example of the use of this variable in a DATA ACL: .code deny message = Too many lines in message header condition = \ diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog index 862f1b887..1fd7bd3cf 100644 --- a/doc/doc-txt/ChangeLog +++ b/doc/doc-txt/ChangeLog @@ -60,6 +60,9 @@ PP/10 Use sig_atomic_t for flags set from signal handlers. Fixed developed for diagnosis in bug 927 (which turned out to be a kernel bug). +PP/11 Bugzilla 1055: Update $message_linecount for maildir_tag. + Patch from Mark Zealey. + Exim version 4.74 ----------------- diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff index 6159bf443..7ae550bb4 100644 --- a/doc/doc-txt/NewStuff +++ b/doc/doc-txt/NewStuff @@ -25,6 +25,10 @@ Version 4.75 3. Log filenames may now use %M as an escape, instead of %D (still available). The %M pattern expands to yyyymm, providing month-level resolution. + 4. The $message_linecount variable is now updated for the maildir_tag option, + in the same way as $message_size, to reflect the real number of lines, + including any header additions or removals from transport. + Version 4.74 ------------ diff --git a/src/src/globals.c b/src/src/globals.c index 60ef8e0a8..fe3a2eeb5 100644 --- a/src/src/globals.c +++ b/src/src/globals.c @@ -1254,6 +1254,7 @@ transport_instance transport_defaults = { }; int transport_count; +int transport_newlines; uschar **transport_filter_argv = NULL; int transport_filter_timeout; BOOL transport_filter_timed_out = FALSE; diff --git a/src/src/globals.h b/src/src/globals.h index 1f0463264..b0c26c425 100644 --- a/src/src/globals.h +++ b/src/src/globals.h @@ -785,6 +785,7 @@ extern int thismessage_size_limit; /* Limit for this message */ extern int timeout_frozen_after; /* Max time to keep frozen messages */ extern BOOL timestamps_utc; /* Use UTC for all times */ extern int transport_count; /* Count of bytes transported */ +extern int transport_newlines; /* Accurate count of number of newline chars transported */ extern uschar **transport_filter_argv; /* For on-the-fly filtering */ extern int transport_filter_timeout; /* Timeout for same */ extern BOOL transport_filter_timed_out; /* True if it did */ diff --git a/src/src/transport.c b/src/src/transport.c index e68a24dcb..504ef9e06 100644 --- a/src/src/transport.c +++ b/src/src/transport.c @@ -426,6 +426,7 @@ for (ptr = start; ptr < end; ptr++) if (use_crlf) *chunk_ptr++ = '\r'; *chunk_ptr++ = '\n'; + transport_newlines++; /* The check_string test (formerly "from hack") replaces the specific string at the start of a line with an escape string (e.g. "From " becomes diff --git a/src/src/transports/appendfile.c b/src/src/transports/appendfile.c index e53761582..6dbb35262 100644 --- a/src/src/transports/appendfile.c +++ b/src/src/transports/appendfile.c @@ -2782,6 +2782,7 @@ if (yield == OK && ob->mbx_format) functions. */ transport_count = 0; +transport_newlines = 0; /* Write any configured prefix text first */ @@ -2807,21 +2808,26 @@ file, use its parent in the RCPT TO. */ if (yield == OK && ob->use_bsmtp) { transport_count = 0; + transport_newlines = 0; if (ob->use_crlf) cr = US"\r"; if (!transport_write_string(fd, "MAIL FROM:<%s>%s\n", return_path, cr)) yield = DEFER; else { address_item *a; + transport_newlines++; for (a = addr; a != NULL; a = a->next) { address_item *b = testflag(a, af_pfr)? a->parent: a; if (!transport_write_string(fd, "RCPT TO:<%s>%s\n", transport_rcpt_address(b, tblock->rcpt_include_affixes), cr)) { yield = DEFER; break; } + transport_newlines++; } if (yield == OK && !transport_write_string(fd, "DATA%s\n", cr)) yield = DEFER; + else + transport_newlines++; } } @@ -2854,8 +2860,10 @@ if (yield == OK && ob->message_suffix != NULL && ob->message_suffix[0] != 0) /* If batch smtp, write the terminating dot. */ -if (yield == OK && ob->use_bsmtp && - !transport_write_string(fd, ".%s\n", cr)) yield = DEFER; +if (yield == OK && ob->use_bsmtp ) { + if(!transport_write_string(fd, ".%s\n", cr)) yield = DEFER; + else transport_newlines++; +} /* If MBX format is being used, all that writing was to the temporary file. However, if there was an earlier failure (Exim quota exceeded, for example), @@ -2873,6 +2881,8 @@ if (temp_file != NULL && ob->mbx_format) if (yield == OK) { transport_count = 0; /* Reset transport count for actual write */ + /* No need to reset transport_newlines as we're just using a block copy + * routine so the number won't be affected */ yield = copy_mbx_message(fd, fileno(temp_file), saved_size); } else if (errno >= 0) dataname = US"temporary file"; @@ -2890,10 +2900,13 @@ fsync() to be called for a FIFO. */ if (yield == OK && !isfifo && EXIMfsync(fd) < 0) yield = DEFER; -/* Update message_size to the accurate count of bytes written, including -added headers. */ +/* Update message_size and message_linecount to the accurate count of bytes +written, including added headers. Note; we subtract 1 from message_linecount as +this variable doesn't count the new line between the header and the body of the +message. */ message_size = transport_count; +message_linecount = transport_newlines - 1; /* If using a maildir++ quota file, add this message's size to it, and close the file descriptor, except when the quota has been disabled because we |