diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | NEWS | 11 | ||||
-rw-r--r-- | doc/Makefile.am | 5 | ||||
-rw-r--r-- | doc/macros.texi | 6 | ||||
-rw-r--r-- | doc/mailfromd.texi | 78 | ||||
-rw-r--r-- | doc/mtasim.texi | 110 | ||||
-rw-r--r-- | mflib/heloarg_test.mf | 4 | ||||
-rw-r--r-- | mflib/spf.mf | 12 | ||||
-rw-r--r-- | src/lex.l | 13 |
9 files changed, 161 insertions, 88 deletions
@@ -1,3 +1,13 @@ +2007-04-25 Sergey Poznyakoff <gray@gnu.org.ua> + + * NEWS: Update + * src/lex.l (parse_require): Bugfix + * mflib/heloarg_test.mf, mflib/spf.mf: Begin the names of the static + functions with __ + * doc/Makefile.am (check-refs): Scan all texi sources + (check-mflib): Ignore static names (__.*) + * doc/mailfromd.texi, doc/mtasim.texi, doc/macros.texi: Update. + 2007-04-24 Sergey Poznyakoff <gray@gnu.org.ua> * src/lex.l (parse_require): Bugfix @@ -1,4 +1,4 @@ -Mailfromd NEWS -- history of user-visible changes. 2007-04-24 +Mailfromd NEWS -- history of user-visible changes. 2007-04-25 Copyright (C) 2005, 2006, 2007 Sergey Poznyakoff See the end of file for copying conditions. @@ -8,6 +8,15 @@ Please send mailfromd bug reports to <bug-mailfromd@gnu.org.ua> Version 3.1.92, SVN +* mtasim + + The `mtasim' utility is an MTA simulator for testing and debugging +mailfromd filter scripts. It supports stdio (-bs) and daemon (-bd) +modes, has GNU readline support and `expect' facility, which makes it +useful in automated test cases. + + See the documentation, chapter `mtasim'. + Version 3.1.91, 2007-04-23 diff --git a/doc/Makefile.am b/doc/Makefile.am index e85247e6..9ac968a8 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -68,7 +68,8 @@ check-builtins: check-mflib: @check-docs.sh "library functions" \ - '/^[ \t]*func/s/[ \t]*func[ \t][ \t]*\(.[^ \t(]*\).*/\1/p' \ + '/^[ \t]*func[ \t][ \t]*__/b;\ + /^[ \t]*func/s/[ \t]*func[ \t][ \t]*\(.[^ \t(]*\).*/\1/p' \ 's/@deftypefn {Library Function} *[^ ][^ ]* *\([^ ]*\).*/\1/p' \ $(top_srcdir)/mflib/*.mf -- \ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -E - \ @@ -83,7 +84,7 @@ check-exceptions: $(info_TEXINFOS) check-refs: - @sed -e = $(info_TEXINFOS) | \ + @sed -e = $(info_TEXINFOS) $(mailfromd_TEXINFOS) | \ sed -n 'N;/@FIXME-.*ref/{s/\(^[0-9][0-9]*\).*@FIXME-.*ref{\([^}]*\)}.*/$(info_TEXINFOS):\1: \2/gp}' > $@-t; \ if [ -s $@-t ]; then echo "Unresolved cross-references:"; cat $@-t;\ fi diff --git a/doc/macros.texi b/doc/macros.texi index d1d7ec4e..a26ad0ca 100644 --- a/doc/macros.texi +++ b/doc/macros.texi @@ -23,3 +23,9 @@ @end smallexample @end macro +@macro mtasimopt{option,text} +@mtindex \option\, --\option\, @r{@command{mtasim} option, \text\} +@end macro + + + diff --git a/doc/mailfromd.texi b/doc/mailfromd.texi index 7f369b36..77f552c8 100644 --- a/doc/mailfromd.texi +++ b/doc/mailfromd.texi @@ -8,12 +8,15 @@ @defcodeindex pr @defcodeindex op +@c mt is the same as op, but used for mtasim options. +@defcodeindex mt @defcodeindex kw @defcodeindex fl @syncodeindex fn cp @syncodeindex vr cp @syncodeindex ky cp +@syncodeindex mt cp @syncodeindex pg cp @syncodeindex tp cp @syncodeindex op cp @@ -2529,73 +2532,14 @@ or @kbd{mailfromd -thelo}. @cindex @command{mtasim}, introduced This method allows to test one handler at a time. To test the -script as a whole, use @command{mtasim} utility. It is described in -detail in @FIXME-ref{}. It is an @dfn{@acronym{MTA} simulator}, useful -for testing purposes. When started it enters interactive mode, -similar to that of @command{sendmail -bs}, where it expects -@acronym{SMTP} commands on its standard input and sends answers to the -standard output. The @option{--port=auto} command line option -instructs it to start @command{mailfromd} and to create a unique -socket for communication with it. Thus, the simplest way to -run it is: - -@smallexample -$ @kbd{mtasim --port=auto} -@end smallexample - - When you exit @command{mtasim} (by typing @code{quit} command or -simply by entering the end-of-file symbol), it will stop the mailfromd -instance it created. This allows to test filter scripts without -interrupting the running @command{mailfromd} instance, if you already -have one. - - Additional arguments to the @command{mailfromd} utility may be -supplied on the command line after @samp{--} marker: - -@smallexample -$ @kbd{mtasim --port=auto -- -I. --stderr newconf.rc} -@end smallexample - - To illustrate this, suppose you wish to test the greylisting -functionality of the filter script described in @ref{Filter Script -Example}. To do this, you start @command{mtasim}: - -@smallexample -$ @kbd{mtasim -Xauto -- -I. -I../mflib test.rc} -220 localhost bitbucket ready -(mtasim) -@end smallexample - - The string @samp{(mtasim) } is the input prompt. - - The script in @file{test.rc} needs to know @code{client_addr} macro. -You have to define it manually. The @command{mtasim} utility provides -a special command for this (@code{\D}, @FIXME-pxref{mtasim escapes}): - -@smallexample -(mtasim) \Dclient_addr=213.130.0.1 -@end smallexample - -Now, let's start @acronym{SMTP} session: - -@smallexample -(mtasim) ehlo yahoo.com -250-pleased to meet you -250 HELP -(mtasim) mail from: <gray@@yahoo.com> -250 Sender OK -(mtasim) rcpt to: <gray@@localhost> -450 4.7.0 You are greylisted for 300 seconds -@end smallexample - -OK, this shows that the greylisting works. Now quit the session: - -@smallexample -(mtasim) quit -221 Done -@end smallexample - - The @command{mtasim} utility is discussed in detail in @FIXME-ref{}. +script as a whole, use @command{mtasim} utility. When +started it enters interactive mode, similar to that of +@command{sendmail -bs}, where it expects @acronym{SMTP} commands on +its standard input and sends answers to the standard output. The +@option{--port=auto} command line option instructs it to start +@command{mailfromd} and to create a unique socket for communication +with it. For the detailed description of the program and the ways to +use it, @xref{mtasim}. @node Logging and Debugging @section Logging and Debugging diff --git a/doc/mtasim.texi b/doc/mtasim.texi index 4417c90a..cf792c8a 100644 --- a/doc/mtasim.texi +++ b/doc/mtasim.texi @@ -45,7 +45,7 @@ ready for input. The prompt appears only if the package is compiled with GNU Readline and @command{mtasim} determines that its standard input is connected to the terminal. This is called @dfn{interactive mode} and is intended to save the human user some typing by offering -line editing and history facilities (@FIXME-pxref{}). If the package +line editing and history facilities (@FIXME-pxref{readline}). If the package is compiled without GNU Readline, you will see: @smallexample @@ -102,7 +102,8 @@ to: Notice, that @command{mtasim} does no domain checking, so such thing as @samp{rcpt to: <him@@domain>} was eaten without complains. -@cindex port: @option{--port}, @command{mailfromd} options +@anchor{mtasim milter port} +@mtasimopt{port, described} So far so good, but what all this has to do with @command{mailfromd}? Well, that's what we are going to explain. To make @command{mtasim} consult any milter, use @option{--port} @@ -164,7 +165,8 @@ $ @kbd{mtasim -Xauto -- -I. -I../mflib test.rc} @end group @end smallexample -@cindex statedir: @option{--statedir}, @command{mailfromd} option +@anchor{statedir mtasim option} +@mtasimopt{statedir, described} The @file{/tmp/mtasim-j6tRLC} directory and any files within it will exist as long as @command{mtasim} is running and will be removed if you exit from it.@footnote{However, this is true only if the program @@ -214,6 +216,7 @@ must follow the command letter without intervening whitespace. Subsequent arguments can be delimited by arbitrary amount of whitespace. +@anchor{\D command} @cindex D, @code{\D}, a @command{mtasim} command @cindex @command{mtasim}, defining Sendmail macros For example, the @code{\D} command defines Sendmail macros: @@ -372,7 +375,7 @@ This is called @dfn{session tracing}. Two options are provided for this purpose: @table @option -@cindex trace-file, @option{--trace-file}, @command{mtasim} option +@mtasimopt{trace-file, described} @item --trace-file=@var{file} Sets the name of the trace file, i.e. a file to which the session transcript will be written. Both the input commands, and the @@ -380,7 +383,7 @@ transcript will be written. Both the input commands, and the it will be truncated before logging. This, however, can be changed using the following option: -@cindex append, @option{--append}, @command{mtasim} option +@mtasimopt{append, described} @item -a @itemx --append If the trace file exists, append new trace data to it. @@ -388,12 +391,105 @@ using the following option: @node daemon mode @section Daemon Mode -@UNREVISED{} + +@mtasimopt{daemon, described} +@cindex @command{mtasim} daemon mode + To start @command{mtasim} in @dfn{daemon} mode, use the +@option{--daemon} (or @option{-bd}) command line option. This mode +is not quite the same as Sendmail @option{-bd} mode. When started in +@dfn{daemon} mode, @command{mtasim} selects the first available +@acronym{TCP} port to use from the range @samp{1024 -- 65535}. +It prints the port number it selected on standard output and +starts listening on it. When a connection comes, it serves a +@emph{single} @acronym{SMTP} session and exits immediately when it is +ended. + + This mode is designed for use in shell scripts and automated test +cases. @node option summary @section @command{mtasim} command line options -@UNREVISED{} This section summarizes all available @command{mtasim} command line options. +@table @option +@mtasimopt{append, summary} +@mtindex a, -a, @command{mtasim} option, summary +@item --append +@itemx -a + Append to the trace file. @xref{traces}. + +@mtasimopt{body-chunk, summary} +@item --body-chunk=@var{number} + Set the body chunk length (bytes) for xxfi_body calls. + +@mtasimopt{daemon, summary} +@mtindex bs, -bd, @command{mtasim} option, summary +@item --daemon +@itemx -bd + Run as daemon. @xref{daemon mode}. + +@mtasimopt{define, summary} +@mtindex D, -D, @command{mtasim} option, summary +@item --define=@var{macro}=@var{value} +@itemx -D @var{macro}=@var{value} + Define Sendmail macro @var{macro} to the given @var{value}. It is +similar to @code{\D} administrative command (@pxref{\D command}) + +@item --help +@itemx -? + Display a short help summary + +@mtasimopt{milter-version, summary} +@item --milter-version=@var{number} + Force using the given Milter protocol version number. This option +is intended for development and testing of the Gacopyz library +(@pxref{Gacopyz}). + +@mtasimopt{no-interactive, summary} +@item --no-interactive + Not-interactive mode (disable readline). @FIXME-pxref{readline}. + +@mtasimopt{port, summary} +@mtindex X, -X, @command{mtasim} option, summary +@item --port=@var{port} +@itemx -X @var{port} + Communicate with given Milter @var{port}. @xref{mtasim milter +port}. + +@mtasimopt{prompt, summary} +@item --prompt=@var{string} + Set readline prompt. The default prompt string is @samp{(mtasim) }. + +@mtasimopt{statedir, summary} +@item --statedir + When using @option{-Xauto}, use the temporary directory name as +@command{mailfromd} state directory (@pxref{statedir mtasim option}). + +@mtasimopt{stdio, summary} +@mtindex bs, -bs, @command{mtasim} option, summary +@item --stdio +@itemx -bs + Use the @acronym{SMTP} protocol on standard input and output. This +is the default mode for @command{mtasim}. @xref{interactive mode}. + +@mtasimopt{trace-file, summary} +@item --trace-file=@var{file} + Set name of the trace file. @xref{traces}. + +@item --usage + Display option summary + +@mtasimopt{verbose, summary} +@mtindex v, -v, @command{mtasim} option, summary +@item --verbose +@itemx -v + Increase verbosity level. + +@item --version +@itemx -V + Print program version + +@end table + diff --git a/mflib/heloarg_test.mf b/mflib/heloarg_test.mf index ce4eda5a..48b31f81 100644 --- a/mflib/heloarg_test.mf +++ b/mflib/heloarg_test.mf @@ -34,7 +34,7 @@ const HELO_IPMISMATCH 7 # ARG does not resolve to the remote client #pragma regex push +extended -func domainof(string arg) returns string +func __domainof(string arg) returns string do if %arg matches '[^.]+\.(.*)' return \1 @@ -75,7 +75,7 @@ do # `HELO' arg in brackets is not an IP return HELO_ARGNOIP elif ismx(%helo_arg, %remote_ip) - or domainof(hostname(%remote_ip)) = %helo_arg + or __domainof(hostname(%remote_ip)) = %helo_arg return HELO_SUCCESS elif (resolve %helo_arg = "0") # `HELO' arg does not resolve to an IP diff --git a/mflib/spf.mf b/mflib/spf.mf index 9bd35317..44584904 100644 --- a/mflib/spf.mf +++ b/mflib/spf.mf @@ -46,7 +46,7 @@ do return "UNKNOWN (" %code ")" done -func spf_get_cache(string ip, string domain, string sender) +func __spf_get_cache(string ip, string domain, string sender) returns number do string record safedbget(%spf_database, "%ip-%domain-%sender") @@ -73,14 +73,14 @@ do return %result done -func spf_put_cache(number result, string ip, string domain, string sender) +func __spf_put_cache(number result, string ip, string domain, string sender) do safedbput(%spf_database, "%ip-%domain-%sender", (time() + %spf_ttl) " %result <%spf_mechanism> <%spf_explanation>") done -func spf_log(number result, string ip, string domain, string sender) +func __spf_log(number result, string ip, string domain, string sender) do string logmsg "SPF check_host(%ip, %domain, %sender) = " spf_status_string(%result) @@ -101,7 +101,7 @@ done func check_host(string ip, string domain, string sender, string helo) returns number do - number result spf_get_cache(%ip, %domain, %sender) + number result __spf_get_cache(%ip, %domain, %sender) if %result == -1 set result spf_check_host(%ip, %domain, %sender, %helo, @@ -111,11 +111,11 @@ do if %result = None set spf_ttl %spf_negative_ttl fi - spf_put_cache(%result, %ip, %domain, %sender) + __spf_put_cache(%result, %ip, %domain, %sender) else set spf_cached 1 fi - spf_log(%result, %ip, %domain, %sender) + __spf_log(%result, %ip, %domain, %sender) return %result done @@ -411,9 +411,16 @@ parse_require() } else fname = NULL; - if (p[0] != '/' && try_file(p, 0, &tmp)) - p = tmp; - free(fname); + if (p[0] != '/') { + if (try_file(p, 0, &tmp)) + p = tmp; + else + p = NULL; + free(fname); + } else if (fname) { + tmp = fname; + fname = NULL; + } } locus.line++; if (p) |