-$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.413 2006/10/23 13:24:21 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/ChangeLog,v 1.414 2006/10/24 12:56:06 ph10 Exp $
Change log file for Exim from version 4.21
-------------------------------------------
PH/25 Applied John Jetmore's -Mset patch.
+PH/26 Added -bem to be like -Mset, but loading a message from a file.
+
Exim version 4.63
-----------------
-$Cambridge: exim/doc/doc-txt/NewStuff,v 1.118 2006/10/23 13:24:21 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/NewStuff,v 1.119 2006/10/24 12:56:06 ph10 Exp $
New Features in Exim
--------------------
7. There is a new command-line option called -Mset. It is useful only in
conjunction with -be (that is, when testing string expansions). It must be
- followed by a message id; Exim loads the given message before doing the
- expansions, thus setting message-specific variables such as $message_size
- and the header variables. This feature is provided to make it easier to test
- expansions that make use of these variables. However, Exim must be called by
- an admin user when -Mset is used.
+ followed by a message id; Exim loads the given message from its spool before
+ doing the expansions, thus setting message-specific variables such as
+ $message_size and the header variables. The $recipients variable is
+ available. This feature is provided to make it easier to test expansions
+ that make use of these variables. However, Exim must be called by an admin
+ user when -Mset is used.
+
+8. Another similar new command-line option is called -bem. It operates like -be
+ except that it must be followed by the name of a file. For example:
+
+ exim -bem /tmp/testmessage
+
+ The file is read as a message (as if receiving a locally-submitted non-SMTP
+ message) before any of the test expansions are done. Thus, message-specific
+ variables such as $message_size and $h_from: are available. However, no
+ Received: header is added to the message. If the -t option is set,
+ recipients are read from the headers in the normal way, and are shown in the
+ $recipients variable. Note that recipients cannot be given on the command
+ line, because further arguments are taken as strings to expand (just like
+ -be).
Version 4.63
-$Cambridge: exim/doc/doc-txt/OptionLists.txt,v 1.25 2006/10/16 15:44:36 ph10 Exp $
+$Cambridge: exim/doc/doc-txt/OptionLists.txt,v 1.26 2006/10/24 12:56:06 ph10 Exp $
LISTS OF EXIM OPTIONS
---------------------
-bd + Start daemon
-bdf + Start daemon and run it in the foreground
-be Test string expansion
+-bem Test string expansion, read test message first
-bF Test system filter file
-bf Test user filter file
-bfd Set domain for filter testing
-Mmad + Mark all recipients delivered
-Mmd + Mark one recipient delivered
-Mrm + Remove message(s) (no bounce)
+-Mset + Load message's variables when testing with -be
-Mt + Thaw message(s)
-Mvb + View message body
-Mvh + View message header
-/* $Cambridge: exim/src/src/exim.c,v 1.45 2006/10/23 13:24:21 ph10 Exp $ */
+/* $Cambridge: exim/src/src/exim.c,v 1.46 2006/10/24 12:56:06 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
int ptr = 0;
uschar *yield = NULL;
-if (fn_readline == NULL) printf("> ");
+if (fn_readline == NULL) { printf("> "); fflush(stdout); }
for (i = 0;; i++)
{
uschar *called_as = US"";
uschar *start_queue_run_id = NULL;
uschar *stop_queue_run_id = NULL;
+uschar *expansion_test_message = NULL;
uschar *ftest_domain = NULL;
uschar *ftest_localpart = NULL;
uschar *ftest_prefix = NULL;
else if (*argrest != 0) { badarg = TRUE; break; }
}
- /* -be: Run in expansion test mode */
+ /* -be: Run in expansion test mode
+ -bem: Ditto, but read a message from a file first
+ */
else if (*argrest == 'e')
+ {
expansion_test = checking = TRUE;
+ if (argrest[1] == 'm')
+ {
+ if (++i >= argc) { badarg = TRUE; break; }
+ expansion_test_message = argv[i];
+ argrest++;
+ }
+ if (argrest[1] != 0) { badarg = TRUE; break; }
+ }
/* -bF: Run system filter test */
) ||
(
deliver_selectstring != NULL && queue_interval < 0
+ ) ||
+ (
+ msg_action == MSG_LOAD &&
+ (!expansion_test || expansion_test_message != NULL)
)
)
{
/* Handle expansion checking. Either expand items on the command line, or read
from stdin if there aren't any. If -Mset was specified, load the message so
-that its variables can be used, but restrict this facility to admin users. */
+that its variables can be used, but restrict this facility to admin users.
+Otherwise, if -bem was used, read a message from stdin. */
if (expansion_test)
{
printf ("Failed to load message %s\n", message_id);
}
+ /* Read a test message from a file. We fudge it up to be on stdin, saving
+ stdin itself for later reading of expansion strings. */
+
+ else if (expansion_test_message != NULL)
+ {
+ int save_stdin = dup(0);
+ int fd = Uopen(expansion_test_message, O_RDONLY, 0);
+ if (fd < 0)
+ {
+ fprintf(stderr, "exim: failed to open %s: %s\n", expansion_test_message,
+ strerror(errno));
+ return EXIT_FAILURE;
+ }
+ (void) dup2(fd, 0);
+ filter_test = FTEST_USER; /* Fudge to make it look like filter test */
+ message_ended = END_NOTENDED;
+ read_message_body(receive_msg(extract_recipients));
+ (void)dup2(save_stdin, 0);
+ (void)close(save_stdin);
+ }
+
+ /* Allow $recipients for this testing */
+
+ enable_dollar_recipients = TRUE;
+
/* Expand command line items */
if (recipients_arg < argc)
-/* $Cambridge: exim/src/src/filtertest.c,v 1.8 2006/02/07 11:19:00 ph10 Exp $ */
+/* $Cambridge: exim/src/src/filtertest.c,v 1.9 2006/10/24 12:56:06 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
we can set up the message_body variables at the same time (in normal use, the
message_body variables are not set up unless needed). The reading code is
written out here rather than having options in read_message_data, in order to
-keep that function as efficient as possible. Handling message_body_end is
-somewhat more tedious. Pile it all into a circular buffer and sort out at the
-end.
+keep that function as efficient as possible. (Later: this function is now
+global because it is also used by the -bem testing option.) Handling
+message_body_end is somewhat more tedious. Pile it all into a circular buffer
+and sort out at the end.
Arguments:
dot_ended TRUE if message already terminated by '.'
Returns: nothing
*/
-static void
+void
read_message_body(BOOL dot_ended)
{
register int ch;
-/* $Cambridge: exim/src/src/functions.h,v 1.29 2006/10/16 15:44:36 ph10 Exp $ */
+/* $Cambridge: exim/src/src/functions.h,v 1.30 2006/10/24 12:56:06 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
extern int readconf_readtime(uschar *, int, BOOL);
extern void readconf_rest(BOOL);
extern uschar *readconf_retry_error(uschar *, uschar *, int *, int *);
+extern void read_message_body(BOOL);
extern void receive_bomb_out(uschar *);
extern BOOL receive_check_fs(int);
extern BOOL receive_check_set_sender(uschar *);
-# -Mset
+# -Mset and -bem
exim userx@test.x usery@test.ex
From: Himself <himself@there.tld>
To: Yourself <you@here.tld>
message_size=$message_size
message_id=$message_id
message_exim_id=$message_exim_id
+recipients=$recipients
+****
+write test-data
+From: A Person <a.person@a.domain.tld>
+To: First <first@test.ex>, Second <second@test.ex>
+Subject: The subject is moot
+
+And now we have the body of the message,
+containing a small number of lines.
+****
+exim -bem DIR/test-data
+from: $h_from:
+to: $h_to:
+subject: $h_subject:
+message_size=$message_size
+message_body_size=$message_body_size
+message_exim_id=$message_exim_id
+message_linecount=$message_linecount
+message_body_linecount=$body_linecount
+headers -----------------
+$message_headers
+
+body --------------------
+$message_body
+
+body end ----------------
+$message_body_end
+****
+exim -bem DIR/test-data -t
+recipients=$recipients
****
no_msglog_check
>>> using ACL "rcpt"
>>> processing "require"
>>> check verify = helo
->>> verifying EHLO/HELO argument "[V4NET.0.0.1]"
>>> require: condition test failed
LOG: H=([V4NET.0.0.1]) [V4NET.0.0.2] F=<a@b> rejected RCPT <c@d>: helo not verified
>>> host in hosts_connection_nolog? no (option unset)
> message_size=416
> message_id=10HmaX-0005vi-00
> message_exim_id=10HmaX-0005vi-00
+> recipients=userx@test.x, usery@test.ex
+>
+> from: A Person <a.person@a.domain.tld>
+> to: First <first@test.ex>, Second <second@test.ex>
+> subject: The subject is moot
+> message_size=197
+> message_body_size=77
+> message_exim_id=10HmaY-0005vi-00
+> message_linecount=4
+> message_body_linecount=2
+> headers -----------------
+> From: A Person <a.person@a.domain.tld>
+To: First <first@test.ex>, Second <second@test.ex>
+Subject: The subject is moot
+Message-Id: <E10HmaY-0005vi-00@myhost.test.ex>
+Date: Tue, 2 Mar 1999 09:44:33 +0000
+>
+> body --------------------
+> And now we have the body of the message, containing a small number of lines.
+>
+> body end ----------------
+> And now we have the body of the message, containing a small number of lines.
+>
+> recipients=first@test.ex, second@test.ex
>