ph10 2006/10/24 13:56:07 BST
Modified files:
exim-doc/doc-txt ChangeLog NewStuff OptionLists.txt
exim-src/src exim.c filtertest.c functions.h
exim-test/scripts/0000-Basic 0542
exim-test/stderr 0070
exim-test/stdout 0542
Log:
Added -bem option.
Revision Changes Path
1.414 +2 -0 exim/exim-doc/doc-txt/ChangeLog
1.119 +20 -5 exim/exim-doc/doc-txt/NewStuff
1.26 +2 -0 exim/exim-doc/doc-txt/OptionLists.txt
1.46 +45 -3 exim/exim-src/src/exim.c
1.9 +5 -4 exim/exim-src/src/filtertest.c
1.30 +1 -0 exim/exim-src/src/functions.h
1.2 +31 -1 exim/exim-test/scripts/0000-Basic/0542
1.2 +0 -1 exim/exim-test/stderr/0070
1.2 +24 -0 exim/exim-test/stdout/0542
Index: ChangeLog
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/ChangeLog,v
retrieving revision 1.413
retrieving revision 1.414
diff -u -r1.413 -r1.414
--- ChangeLog 23 Oct 2006 13:24:21 -0000 1.413
+++ ChangeLog 24 Oct 2006 12:56:06 -0000 1.414
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/ChangeLog,v 1.413 2006/10/23 13:24:21 ph10 Exp $
+$Cambridge: exim/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
-------------------------------------------
@@ -163,6 +163,8 @@
situation, the verify now always succeeds.
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
Index: NewStuff
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/NewStuff,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -r1.118 -r1.119
--- NewStuff 23 Oct 2006 13:24:21 -0000 1.118
+++ NewStuff 24 Oct 2006 12:56:06 -0000 1.119
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.118 2006/10/23 13:24:21 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/NewStuff,v 1.119 2006/10/24 12:56:06 ph10 Exp $
New Features in Exim
--------------------
@@ -133,11 +133,26 @@
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
Index: OptionLists.txt
===================================================================
RCS file: /home/cvs/exim/exim-doc/doc-txt/OptionLists.txt,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- OptionLists.txt 16 Oct 2006 15:44:36 -0000 1.25
+++ OptionLists.txt 24 Oct 2006 12:56:06 -0000 1.26
@@ -1,4 +1,4 @@
-$Cambridge: exim/exim-doc/doc-txt/OptionLists.txt,v 1.25 2006/10/16 15:44:36 ph10 Exp $
+$Cambridge: exim/exim-doc/doc-txt/OptionLists.txt,v 1.26 2006/10/24 12:56:06 ph10 Exp $
LISTS OF EXIM OPTIONS
---------------------
@@ -580,6 +580,7 @@
-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
@@ -634,6 +635,7 @@
-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
Index: exim.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/exim.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- exim.c 23 Oct 2006 13:24:21 -0000 1.45
+++ exim.c 24 Oct 2006 12:56:06 -0000 1.46
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/exim.c,v 1.45 2006/10/23 13:24:21 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/exim.c,v 1.46 2006/10/24 12:56:06 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -1177,7 +1177,7 @@
int ptr = 0;
uschar *yield = NULL;
-if (fn_readline == NULL) printf("> ");
+if (fn_readline == NULL) { printf("> "); fflush(stdout); }
for (i = 0;; i++)
{
@@ -1300,6 +1300,7 @@
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;
@@ -1680,10 +1681,21 @@
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 */
@@ -2924,6 +2936,10 @@
) ||
(
deliver_selectstring != NULL && queue_interval < 0
+ ) ||
+ (
+ msg_action == MSG_LOAD &&
+ (!expansion_test || expansion_test_message != NULL)
)
)
{
@@ -4181,7 +4197,8 @@
/* 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)
{
@@ -4200,6 +4217,31 @@
if (spool_read_header(spoolname, TRUE, FALSE) != spool_read_OK)
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 */
Index: filtertest.c
===================================================================
RCS file: /home/cvs/exim/exim-src/src/filtertest.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- filtertest.c 7 Feb 2006 11:19:00 -0000 1.8
+++ filtertest.c 24 Oct 2006 12:56:06 -0000 1.9
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/filtertest.c,v 1.8 2006/02/07 11:19:00 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/filtertest.c,v 1.9 2006/10/24 12:56:06 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -22,9 +22,10 @@
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 '.'
@@ -32,7 +33,7 @@
Returns: nothing
*/
-static void
+void
read_message_body(BOOL dot_ended)
{
register int ch;
Index: functions.h
===================================================================
RCS file: /home/cvs/exim/exim-src/src/functions.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- functions.h 16 Oct 2006 15:44:36 -0000 1.29
+++ functions.h 24 Oct 2006 12:56:06 -0000 1.30
@@ -1,4 +1,4 @@
-/* $Cambridge: exim/exim-src/src/functions.h,v 1.29 2006/10/16 15:44:36 ph10 Exp $ */
+/* $Cambridge: exim/exim-src/src/functions.h,v 1.30 2006/10/24 12:56:06 ph10 Exp $ */
/*************************************************
* Exim - an Internet mail transport agent *
@@ -206,6 +206,7 @@
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 *);
Index: 0542
===================================================================
RCS file: /home/cvs/exim/exim-test/scripts/0000-Basic/0542,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 0542 23 Oct 2006 13:24:21 -0000 1.1
+++ 0542 24 Oct 2006 12:56:07 -0000 1.2
@@ -1,4 +1,4 @@
-# -Mset
+# -Mset and -bem
exim userx@??? usery@???
From: Himself <himself@???>
To: Yourself <you@???>
@@ -13,5 +13,35 @@
message_size=$message_size
message_id=$message_id
message_exim_id=$message_exim_id
+recipients=$recipients
+****
+write test-data
+From: A Person <a.person@???>
+To: First <first@???>, Second <second@???>
+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
Index: 0070
===================================================================
RCS file: /home/cvs/exim/exim-test/stderr/0070,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 0070 7 Feb 2006 10:47:31 -0000 1.1
+++ 0070 24 Oct 2006 12:56:07 -0000 1.2
@@ -56,7 +56,6 @@
>>> 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)
Index: 0542
===================================================================
RCS file: /home/cvs/exim/exim-test/stdout/0542,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- 0542 23 Oct 2006 13:24:22 -0000 1.1
+++ 0542 24 Oct 2006 12:56:07 -0000 1.2
@@ -4,4 +4,28 @@
> message_size=416
> message_id=10HmaX-0005vi-00
> message_exim_id=10HmaX-0005vi-00
+> recipients=userx@???, usery@???
+>
+> from: A Person <a.person@???>
+> to: First <first@???>, Second <second@???>
+> 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@???>
+To: First <first@???>, Second <second@???>
+Subject: The subject is moot
+Message-Id: <E10HmaY-0005vi-00@???>
+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@???, second@???
>