diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-05-06 10:23:10 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-05-06 10:23:10 +0000 |
commit | 6dd31a8c59b4092600d614381da9d84d2b014663 (patch) | |
tree | 0bcfaf9d2e28a240964413df6841043cecf163c1 | |
parent | 362926c7d0b90773f5dd9f60772063fb78e2c087 (diff) | |
download | mailfromd-6dd31a8c59b4092600d614381da9d84d2b014663.tar.gz mailfromd-6dd31a8c59b4092600d614381da9d84d2b014663.tar.bz2 |
Update
git-svn-id: file:///svnroot/mailfromd/trunk@1414 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | acinclude.m4 | 34 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | doc/mailfromd.texi | 14 | ||||
-rw-r--r-- | doc/mtasim.texi | 5 | ||||
-rw-r--r-- | gacopyz/gacopyz.c | 2 | ||||
-rw-r--r-- | gacopyz/gacopyz.h | 2 | ||||
-rw-r--r-- | gacopyz/server.c | 12 | ||||
-rw-r--r-- | src/mtasim.c | 67 |
9 files changed, 107 insertions, 43 deletions
@@ -1,3 +1,14 @@ +2007-05-06 Sergey Poznyakoff <gray@gnu.org.ua> + + * src/mtasim.c: \E can take 1 and 2 digit codes. + Correctly close the milter server before exiting + * configure.ac: Call MU_DEBUG_MODE + * doc/mailfromd.texi, doc/mtasim.texi: Update + * acinclude.m4: New file + * gacopyz/gacopyz.h, gacopyz/server.c (gacopyz_srv_abort) + (gacopyz_srv_quit): New functions + * gacopyz/gacopyz.c: Do not complain if the socket does not exist. + 2007-05-05 Sergey Poznyakoff <gray@gnu.org.ua> * src/mailfromd.h (DEFAULT_PIDFILE): Use file name relative to diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 00000000..840f88be --- /dev/null +++ b/acinclude.m4 @@ -0,0 +1,34 @@ +dnl This file is part of GNU mailutils. +dnl Copyright (C) 2001 Free Software Foundation, Inc. +dnl +dnl This file is free software; as a special exception the author gives +dnl unlimited permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl +dnl This program is distributed in the hope that it will be useful, but +dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the +dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +dnl +dnl Check for --enable-debug switch. When the switch is specified, add +dnl -ggdb to CFLAGS and remove any optimization options from there. +dnl + +AC_DEFUN([MU_DEBUG_MODE], + [AC_ARG_ENABLE(debug, + [ --enable-debug enable debugging mode], + [if test x"$enableval" = xyes; then + if test x"$GCC" = xyes; then + AC_MSG_CHECKING(whether gcc accepts -ggdb) + save_CFLAGS=$CFLAGS + CFLAGS="-ggdb -Wall" + AC_TRY_COMPILE([],void f(){}, + AC_MSG_RESULT(yes), + [if test x"$ac_cv_prog_cc_g" = xyes; then + CFLAGS="-g -Wall" + else + CFLAGS= + fi + AC_MSG_RESULT(no)]) + CFLAGS="`echo $save_CFLAGS | sed 's/-O[[0-9]]//g'` $CFLAGS" + fi + fi])]) diff --git a/configure.ac b/configure.ac index c0f27118..b35a0178 100644 --- a/configure.ac +++ b/configure.ac @@ -491,6 +491,9 @@ case `echo $VERSION|sed 's/[[^.]]//g'` in *) RENDITION=PROOF;; esac +# Debugging mode +MU_DEBUG_MODE + # Initialize the test suite. AC_CONFIG_TESTDIR(tests) AC_CONFIG_FILES([tests/Makefile tests/etc/Makefile tests/atlocal]) diff --git a/doc/mailfromd.texi b/doc/mailfromd.texi index fbbf7a58..07a0d8ad 100644 --- a/doc/mailfromd.texi +++ b/doc/mailfromd.texi @@ -1112,7 +1112,7 @@ The diagram below shows the control flow when processing an @acronym{SMTP} transaction. Lines marked with @code{C:} show @acronym{SMTP} commands issued by the remote machine (the @dfn{client}), those marked with @samp{@result{}} show called handlers -with their arguments. An @r{[R]} appearing at the start of a line +with their arguments. An @samp{[R]} appearing at the start of a line indicates that this part of the transaction can be repeated any number of times: @@ -1129,25 +1129,25 @@ do C: MAIL FROM @var{sender} @result{} envfrom(@var{sender}) -@r{[R]} C: RCPT TO @var{recipient} +[R] C: RCPT TO @var{recipient} @result{} envrcpt(@var{recipient}) C: DATA -@r{[R]} C: @var{header}: @var{value} +[R] C: @var{header}: @var{value} @result{} header(@var{header}, @var{value}) C: @result{} eoh() -@r{[R]} C: @var{body-line} - @result{} /* @r{Collect lines into blocks @var{blk} of - @result{} * at most @var{len} bytes and call:} +[R] C: @var{body-line} + @result{} /* @r{Collect lines into blocks @var{blk} of} + @result{} * @r{at most @var{len} bytes and call:} @result{} */ @result{} body(@var{blk}, @var{len}) C: . @result{} eom() - done +done @result{} end() @end group @end smallexample diff --git a/doc/mtasim.texi b/doc/mtasim.texi index 580689c7..8e5f66f8 100644 --- a/doc/mtasim.texi +++ b/doc/mtasim.texi @@ -334,6 +334,11 @@ terminates with exit code 1. The error message it prints looks like: Expected 250 but got 470 @end smallexample + The expect code given with the @code{\E} command may have less than +3 digits. In this case it specifies the first digits of expected +reply. For example, the command @samp{\E2} matches replies +@samp{200}, @samp{220}, etc. + This feature can be used to automate your tests. For example, the following script tests the greylisting functionality (see the previous section): diff --git a/gacopyz/gacopyz.c b/gacopyz/gacopyz.c index c3aeb453..81ed394d 100644 --- a/gacopyz/gacopyz.c +++ b/gacopyz/gacopyz.c @@ -138,7 +138,7 @@ parse_connection(gacopyz_conn_t conn, static void cleanup_unix_socket(gacopyz_conn_t conn, void *data) { - if (unlink(data)) + if (unlink(data) && errno != ENOENT) gacopyz_log(conn, SMI_LOG_ERR, "%s: %s: cannot unlink: %s", conn->desc.xxfi_name, (char*)data, diff --git a/gacopyz/gacopyz.h b/gacopyz/gacopyz.h index 0e40e171..a043b1ae 100644 --- a/gacopyz/gacopyz.h +++ b/gacopyz/gacopyz.h @@ -342,6 +342,8 @@ void gacopyz_srv_count_macros (gacopyz_srv_t srv, size_t *count); int gacopyz_srv_connect (gacopyz_srv_t srv); int gacopyz_srv_init(gacopyz_srv_t srv); int gacopyz_srv_negotiate(gacopyz_srv_t srv); +int gacopyz_srv_abort(gacopyz_srv_t srv); +int gacopyz_srv_quit(gacopyz_srv_t srv); int gacopyz_srv_helo (gacopyz_srv_t p, const char *domain); int gacopyz_srv_envfrom (gacopyz_srv_t p, char **argv); diff --git a/gacopyz/server.c b/gacopyz/server.c index 7baac052..57cd90de 100644 --- a/gacopyz/server.c +++ b/gacopyz/server.c @@ -1066,7 +1066,17 @@ gacopyz_srv_reply (gacopyz_srv_t srv, char **msg, size_t *size) int gacopyz_srv_abort(gacopyz_srv_t srv) { - return not_implemented(srv); + GACOPYZ_ASSERT(srv); + gacopyz_io_log(&srv->iod, SMI_LOG_DEBUG, "gacopyz_srv_abort"); + return gacopyz_send_command(&srv->iod, SMFIC_ABORT, NULL, 0); +} + +int +gacopyz_srv_quit(gacopyz_srv_t srv) +{ + GACOPYZ_ASSERT(srv); + gacopyz_io_log(&srv->iod, SMI_LOG_DEBUG, "gacopyz_srv_quit"); + return gacopyz_send_command(&srv->iod, SMFIC_QUIT, NULL, 0); } int diff --git a/src/mtasim.c b/src/mtasim.c index a34d5a20..f48c1ec0 100644 --- a/src/mtasim.c +++ b/src/mtasim.c @@ -20,28 +20,6 @@ compiling, linking, and/or using OpenSSL is allowed. */ -/* This is a "fake" mta designed for testing purposes. It imitates - sendmail SMTP modes (daemon and stdin). It does not actually send anything, - instead it just outputs the transcript of the SMTP session. - - Invocation: - - 1. mta -bs [--trace FILE] - - Use the SMTP protocol on standard input and output. - - 2. mta -bd [--trace FILE] - - Operates as daemon. If port is given, mta will listen on that port. - Otherwise, it will use the first free port in the range 1024-65535. - In this case, mta prints the port number on the stdout, prior to - starting operation. Notice, that in this mode mta does not disconnect - itself from the controlling terminal, it always stays on the foreground. - - Option --trace in both cases sets the name of the output trace file. - -*/ - #ifdef HAVE_CONFIG_H # include <config.h> #endif @@ -190,26 +168,46 @@ free_expected_code () int set_expected_code (const char *str) { - if (strlen (str) != 3 - || !strchr ("12345", str[0]) - || !isdigit (str[1]) - || !isdigit (str[2])) + size_t len = strlen (str); + if (len == 0 || !strchr ("12345", str[0])) return 1; - strncpy (expected_code, str, 3); + if (len > 1) + { + if (!isdigit (str[1]) + || (len > 2 && !isdigit (str[2]))) + return 1; + } + + if (len > 3) + len = 3; + memcpy (expected_code, str, len); + expected_code[len] = 0; return 0; } void check_expected_code (char *str) { - if (expected_code[0] == 0) - return; - if (memcmp (expected_code, str, 3)) - { - error ("Expected %s but got %3.3s", expected_code, str); - exit (1); - } + int i; + + for (i = 0; i < 3 && expected_code[i]; i++) + if (str[i] != expected_code[i]) + { + /* fill in the expected code */ + for (i = strlen(expected_code); i < 3; i++) + expected_code[i] = '.'; + error ("Expected %s but got %3.3s", expected_code, str); + + if (gsrv) + { + gacopyz_srv_abort (gsrv); + gacopyz_srv_quit (gsrv); + gacopyz_srv_close (gsrv); + gacopyz_srv_destroy (&gsrv); + } + exit (1); + } expected_code[0] = 0; } @@ -1893,6 +1891,7 @@ smtp (void) } if (gsrv) { + gacopyz_srv_quit (gsrv); gacopyz_srv_close (gsrv); gacopyz_srv_destroy (&gsrv); } |