summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Hazel <ph10@hermes.cam.ac.uk>2006-10-24 12:56:06 +0000
committerPhilip Hazel <ph10@hermes.cam.ac.uk>2006-10-24 12:56:06 +0000
commit328895cc07b8caf8c18003569431a02129989289 (patch)
treed63fd2d73d25cefa6e803846040023253c80d1a7
parent0ef732d996b5f37b28410c5efe132fbbe5c686ef (diff)
Added -bem option.
-rw-r--r--doc/doc-txt/ChangeLog4
-rw-r--r--doc/doc-txt/NewStuff27
-rw-r--r--doc/doc-txt/OptionLists.txt4
-rw-r--r--src/src/exim.c50
-rw-r--r--src/src/filtertest.c11
-rw-r--r--src/src/functions.h3
-rw-r--r--test/scripts/0000-Basic/054232
-rw-r--r--test/stderr/00701
-rw-r--r--test/stdout/054224
9 files changed, 136 insertions, 20 deletions
diff --git a/doc/doc-txt/ChangeLog b/doc/doc-txt/ChangeLog
index c8e74b5f7..6d51cd882 100644
--- a/doc/doc-txt/ChangeLog
+++ b/doc/doc-txt/ChangeLog
@@ -1,4 +1,4 @@
-$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
-------------------------------------------
@@ -164,6 +164,8 @@ PH/24 Exim crashed if verify=helo was activated during an incoming -bs
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
-----------------
diff --git a/doc/doc-txt/NewStuff b/doc/doc-txt/NewStuff
index e96087601..95a207516 100644
--- a/doc/doc-txt/NewStuff
+++ b/doc/doc-txt/NewStuff
@@ -1,4 +1,4 @@
-$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
--------------------
@@ -133,11 +133,26 @@ Version 4.64
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
diff --git a/doc/doc-txt/OptionLists.txt b/doc/doc-txt/OptionLists.txt
index 69f2370e0..f0ef3c2f8 100644
--- a/doc/doc-txt/OptionLists.txt
+++ b/doc/doc-txt/OptionLists.txt
@@ -1,4 +1,4 @@
-$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
---------------------
@@ -580,6 +580,7 @@ provide compatibility with Sendmail.
-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 @@ provide compatibility with Sendmail.
-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
diff --git a/src/src/exim.c b/src/src/exim.c
index 0a1f2b8c1..9cef9226b 100644
--- a/src/src/exim.c
+++ b/src/src/exim.c
@@ -1,4 +1,4 @@
-/* $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 *
@@ -1177,7 +1177,7 @@ int size = 0;
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 *alias_arg = NULL;
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 @@ for (i = 1; i < argc; i++)
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 @@ if ((
) ||
(
deliver_selectstring != NULL && queue_interval < 0
+ ) ||
+ (
+ msg_action == MSG_LOAD &&
+ (!expansion_test || expansion_test_message != NULL)
)
)
{
@@ -4181,7 +4197,8 @@ if (verify_address_mode || address_test_mode)
/* 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)
{
@@ -4201,6 +4218,31 @@ 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)
diff --git a/src/src/filtertest.c b/src/src/filtertest.c
index 3275cd0d4..10af6b596 100644
--- a/src/src/filtertest.c
+++ b/src/src/filtertest.c
@@ -1,4 +1,4 @@
-/* $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 *
@@ -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 @@ Arguments:
Returns: nothing
*/
-static void
+void
read_message_body(BOOL dot_ended)
{
register int ch;
diff --git a/src/src/functions.h b/src/src/functions.h
index 170a84411..b91ca274d 100644
--- a/src/src/functions.h
+++ b/src/src/functions.h
@@ -1,4 +1,4 @@
-/* $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 *
@@ -206,6 +206,7 @@ extern uschar *readconf_readname(uschar *, int, uschar *);
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 *);
diff --git a/test/scripts/0000-Basic/0542 b/test/scripts/0000-Basic/0542
index 90645d746..090c2bf34 100644
--- a/test/scripts/0000-Basic/0542
+++ b/test/scripts/0000-Basic/0542
@@ -1,4 +1,4 @@
-# -Mset
+# -Mset and -bem
exim userx@test.x usery@test.ex
From: Himself <himself@there.tld>
To: Yourself <you@here.tld>
@@ -13,5 +13,35 @@ message_body_size=$message_body_size
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
diff --git a/test/stderr/0070 b/test/stderr/0070
index ccb6d3f67..ebcc21390 100644
--- a/test/stderr/0070
+++ b/test/stderr/0070
@@ -56,7 +56,6 @@ MUNGED: ::1 will be omitted in what follows
>>> 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)
diff --git a/test/stdout/0542 b/test/stdout/0542
index aecedca72..4bce403cc 100644
--- a/test/stdout/0542
+++ b/test/stdout/0542
@@ -4,4 +4,28 @@
> 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
>