X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=test%2Fruntest;h=3931b06d4018bfdcc9db9ae75320a593eb275983;hb=a7079166663db0d37e659f36e75589738873c18d;hp=900fc7bbbe68fdbfda462dea532144fdea6ceeca;hpb=7fa5764c203f2f4a900898a79ed02d674075313f;p=user%2Fhenk%2Fcode%2Fexim.git diff --git a/test/runtest b/test/runtest index 900fc7bbb..3931b06d4 100755 --- a/test/runtest +++ b/test/runtest @@ -385,11 +385,21 @@ $spid = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; LINE: while() { RESET_AFTER_EXTRA_LINE_READ: + if ($munge_skip) + { + # Munging is a no-op. + # Useful when testing exim_msgdate so that + # we compare unmunged dates and message-ids. + print MUNGED; + next; + } + # Custom munges if ($extra) { next if $extra =~ m%^/% && eval $extra; eval $extra if $extra =~ m/^s/; + eval substr($extra, 1) if $extra =~ m/^R/; } # Check for "*** truncated ***" @@ -918,6 +928,11 @@ RESET_AFTER_EXTRA_LINE_READ: # OpenSSL 3.0.0 s/TLS error \(D-H param setting .* error:\K.*dh key too small/xxxxxxxx:SSL routines::dh key too small/; + # OpenSSL 1.1.1 + s/error:\K0B080074:x509 certificate routines:X509_check_private_key(?=:key values mismatch$)/05800074:x509 certificate routines:/; + s/error:\K02001002:system library:fopen(?=:No such file or directory$)/80000002:system library:/; + s/error:\K0909006C:PEM routines:get_name(?=:no start line$)/0480006C:PEM routines:/; + # ======== Maildir things ======== # timestamp output in maildir processing s/(timestamp=|\(timestamp_only\): )\d+/$1ddddddd/g; @@ -1562,6 +1577,9 @@ RESET_AFTER_EXTRA_LINE_READ: s/signer: [^ ]* bits:\K 256/ 253/; s/public key too short:\K 256 bits/ 253 bits/; + # with GnuTLS we cannot log single bad ALPN. So ignore the with-OpenSSL log line. + # next if /TLS ALPN (http) rejected$/; + # port numbers s/(?:\[[^\]]*\]:|port )\K$parm_port_d/PORT_D/; s/(?:\[[^\]]*\]:|port )\K$parm_port_d2/PORT_D2/; @@ -1909,7 +1927,8 @@ return 2; # Usable files are: # paniclog, rejectlog, mainlog, stdout, stderr, msglog, mail # Search strings starting with 's' do substitutions; -# with '/' do line-skips. +# with '/' do line-skips, +# with 'R' run given code. # Triggered by a scriptfile line "munge " ################################################## $munges = @@ -1956,7 +1975,13 @@ $munges = }, 'optional_dsn_info' => - { 'mail' => '/^(X-(Remote-MTA-(smtp-greeting|helo-response)|Exim-Diagnostic|(body|message)-linecount):|Remote-MTA: X-ip;)/' + { 'mail' => 'Rif (/^(X-(Remote-MTA-(smtp-greeting|helo-response)|Exim-Diagnostic|(body|message)-linecount):|Remote-MTA: X-ip;)/) { + while (1) { + $_ = ; + next if /^ /; + goto RESET_AFTER_EXTRA_LINE_READ; + } + }' }, 'optional_config' => @@ -2975,6 +3000,245 @@ return $yield; # Ran command and waited +############################################################################### +############################################################################### + +################################################## +# Check for SpamAssassin and ClamAV # +################################################## + +# These are crude tests. If they aren't good enough, we'll have to improve +# them, for example by actually passing a message through spamc or clamscan. + +sub check_running_spamassassin +{ +my $sock = new FileHandle; + +if (system("spamc -h 2>/dev/null >/dev/null") == 0) + { + print "The spamc command works:\n"; + + # This test for an active SpamAssassin is courtesy of John Jetmore. + # The tests are hard coded to localhost:783, so no point in making + # this test flexible like the clamav test until the test scripts are + # changed. spamd doesn't have the nice PING/PONG protocol that + # clamd does, but it does respond to errors in an informative manner, + # so use that. + + my($sint,$sport) = ('127.0.0.1',783); + eval + { + my $sin = sockaddr_in($sport, inet_aton($sint)) + or die "** Failed packing $sint:$sport\n"; + socket($sock, PF_INET, SOCK_STREAM, getprotobyname('tcp')) + or die "** Unable to open socket $sint:$sport\n"; + + local $SIG{ALRM} = + sub { die "** Timeout while connecting to socket $sint:$sport\n"; }; + alarm(5); + connect($sock, $sin) + or die "** Unable to connect to socket $sint:$sport\n"; + alarm(0); + + select((select($sock), $| = 1)[0]); + print $sock "bad command\r\n"; + + $SIG{ALRM} = + sub { die "** Timeout while reading from socket $sint:$sport\n"; }; + alarm(10); + my $res = <$sock>; + alarm(0); + + $res =~ m|^SPAMD/| + or die "** Did not get SPAMD from socket $sint:$sport. " + ."It said: $res\n"; + }; + alarm(0); + if($@) + { + print " $@"; + print " Assume SpamAssassin (spamd) is not running\n"; + } + else + { + $parm_running{SpamAssassin} = ' '; + print " SpamAssassin (spamd) seems to be running\n"; + } + } +else + { + print "The spamc command failed: assume SpamAssassin (spamd) is not running\n"; + } +} + +sub check_running_clamav +{ +my $sock; + +# For ClamAV, we need to find the clamd socket for use in the Exim +# configuration. Search for the clamd configuration file. + +if (system("clamscan -h 2>/dev/null >/dev/null") == 0) + { + my($f, $clamconf, $test_prefix); + + print "The clamscan command works"; + + $test_prefix = $ENV{EXIM_TEST_PREFIX}; + $test_prefix = '' if !defined $test_prefix; + + foreach $f ("$test_prefix/etc/clamd.conf", + "$test_prefix/usr/local/etc/clamd.conf", + "$test_prefix/etc/clamav/clamd.conf", '') + { + if (-e $f) + { + $clamconf = $f; + last; + } + } + + # Read the ClamAV configuration file and find the socket interface. + + if ($clamconf ne '') + { + my $socket_domain; + open(IN, "$clamconf") || die "\n** Unable to open $clamconf: $!\n"; + while () + { + if (/^LocalSocket\s+(.*)/) + { + $parm_clamsocket = $1; + $socket_domain = AF_UNIX; + last; + } + if (/^TCPSocket\s+(\d+)/) + { + if (defined $parm_clamsocket) + { + $parm_clamsocket .= " $1"; + $socket_domain = AF_INET; + last; + } + else + { + $parm_clamsocket = " $1"; + } + } + elsif (/^TCPAddr\s+(\S+)/) + { + if (defined $parm_clamsocket) + { + $parm_clamsocket = $1 . $parm_clamsocket; + $socket_domain = AF_INET; + last; + } + else + { + $parm_clamsocket = $1; + } + } + } + close(IN); + + if (defined $socket_domain) + { + print ":\n The clamd socket is $parm_clamsocket\n"; + # This test for an active ClamAV is courtesy of Daniel Tiefnig. + eval + { + my $socket; + if ($socket_domain == AF_UNIX) + { + $socket = sockaddr_un($parm_clamsocket) or die "** Failed packing '$parm_clamsocket'\n"; + } + elsif ($socket_domain == AF_INET) + { + my ($ca_host, $ca_port) = split(/\s+/,$parm_clamsocket); + my $ca_hostent = gethostbyname($ca_host) or die "** Failed to get raw address for host '$ca_host'\n"; + $socket = sockaddr_in($ca_port, $ca_hostent) or die "** Failed packing '$parm_clamsocket'\n"; + } + else + { + die "** Unknown socket domain '$socket_domain' (should not happen)\n"; + } + socket($sock, $socket_domain, SOCK_STREAM, 0) or die "** Unable to open socket '$parm_clamsocket'\n"; + local $SIG{ALRM} = sub { die "** Timeout while connecting to socket '$parm_clamsocket'\n"; }; + alarm(5); + connect($sock, $socket) or die "** Unable to connect to socket '$parm_clamsocket'\n"; + alarm(0); + + my $ofh = select $sock; $| = 1; select $ofh; + print $sock "PING\n"; + + $SIG{ALRM} = sub { die "** Timeout while reading from socket '$parm_clamsocket'\n"; }; + alarm(10); + my $res = <$sock>; + alarm(0); + + $res =~ /PONG/ or die "** Did not get PONG from socket '$parm_clamsocket'. It said: $res\n"; + }; + alarm(0); + + if($@) + { + print " $@"; + print " Assume ClamAV is not running\n"; + } + else + { + $parm_running{ClamAV} = ' '; + print " ClamAV seems to be running\n"; + } + } + else + { + print ", but the socket for clamd could not be determined\n"; + print "Assume ClamAV is not running\n"; + } + } + + else + { + print ", but I can't find a configuration for clamd\n"; + print "Assume ClamAV is not running\n"; + } + } +} + + +sub check_running_redis +{ +if (defined $parm_lookups{redis}) + { + if (system("redis-server -v 2>/dev/null >/dev/null") == 0) + { + print "The redis-server command works\n"; + $parm_running{redis} = ' '; + } + else + { + print "The redis-server command failed: assume Redis not installed\n"; + } + } +} + +sub check_running_dovecot +{ +system('dovecot --version >/dev/null'); +if ($? == 0) + { + print "Dovecot appears to be available\n"; + $parm_running{dovecot} = ' '; + } +else + { + print "Dovecot not found\n"; + } +} + + + ############################################################################### ############################################################################### @@ -3327,220 +3591,15 @@ print "-" x 78, "\n"; unlink("$parm_cwd/test-config"); -################################################## -# Check for SpamAssassin and ClamAV # -################################################## -# These are crude tests. If they aren't good enough, we'll have to improve -# them, for example by actually passing a message through spamc or clamscan. if (defined $parm_support{Content_Scanning}) { - my $sock = new FileHandle; - - if (system("spamc -h 2>/dev/null >/dev/null") == 0) - { - print "The spamc command works:\n"; - - # This test for an active SpamAssassin is courtesy of John Jetmore. - # The tests are hard coded to localhost:783, so no point in making - # this test flexible like the clamav test until the test scripts are - # changed. spamd doesn't have the nice PING/PONG protocol that - # clamd does, but it does respond to errors in an informative manner, - # so use that. - - my($sint,$sport) = ('127.0.0.1',783); - eval - { - my $sin = sockaddr_in($sport, inet_aton($sint)) - or die "** Failed packing $sint:$sport\n"; - socket($sock, PF_INET, SOCK_STREAM, getprotobyname('tcp')) - or die "** Unable to open socket $sint:$sport\n"; - - local $SIG{ALRM} = - sub { die "** Timeout while connecting to socket $sint:$sport\n"; }; - alarm(5); - connect($sock, $sin) - or die "** Unable to connect to socket $sint:$sport\n"; - alarm(0); - - select((select($sock), $| = 1)[0]); - print $sock "bad command\r\n"; - - $SIG{ALRM} = - sub { die "** Timeout while reading from socket $sint:$sport\n"; }; - alarm(10); - my $res = <$sock>; - alarm(0); - - $res =~ m|^SPAMD/| - or die "** Did not get SPAMD from socket $sint:$sport. " - ."It said: $res\n"; - }; - alarm(0); - if($@) - { - print " $@"; - print " Assume SpamAssassin (spamd) is not running\n"; - } - else - { - $parm_running{SpamAssassin} = ' '; - print " SpamAssassin (spamd) seems to be running\n"; - } - } - else - { - print "The spamc command failed: assume SpamAssassin (spamd) is not running\n"; - } - - # For ClamAV, we need to find the clamd socket for use in the Exim - # configuration. Search for the clamd configuration file. - - if (system("clamscan -h 2>/dev/null >/dev/null") == 0) - { - my($f, $clamconf, $test_prefix); - - print "The clamscan command works"; - - $test_prefix = $ENV{EXIM_TEST_PREFIX}; - $test_prefix = '' if !defined $test_prefix; - - foreach $f ("$test_prefix/etc/clamd.conf", - "$test_prefix/usr/local/etc/clamd.conf", - "$test_prefix/etc/clamav/clamd.conf", '') - { - if (-e $f) - { - $clamconf = $f; - last; - } - } - - # Read the ClamAV configuration file and find the socket interface. - - if ($clamconf ne '') - { - my $socket_domain; - open(IN, "$clamconf") || die "\n** Unable to open $clamconf: $!\n"; - while () - { - if (/^LocalSocket\s+(.*)/) - { - $parm_clamsocket = $1; - $socket_domain = AF_UNIX; - last; - } - if (/^TCPSocket\s+(\d+)/) - { - if (defined $parm_clamsocket) - { - $parm_clamsocket .= " $1"; - $socket_domain = AF_INET; - last; - } - else - { - $parm_clamsocket = " $1"; - } - } - elsif (/^TCPAddr\s+(\S+)/) - { - if (defined $parm_clamsocket) - { - $parm_clamsocket = $1 . $parm_clamsocket; - $socket_domain = AF_INET; - last; - } - else - { - $parm_clamsocket = $1; - } - } - } - close(IN); - - if (defined $socket_domain) - { - print ":\n The clamd socket is $parm_clamsocket\n"; - # This test for an active ClamAV is courtesy of Daniel Tiefnig. - eval - { - my $socket; - if ($socket_domain == AF_UNIX) - { - $socket = sockaddr_un($parm_clamsocket) or die "** Failed packing '$parm_clamsocket'\n"; - } - elsif ($socket_domain == AF_INET) - { - my ($ca_host, $ca_port) = split(/\s+/,$parm_clamsocket); - my $ca_hostent = gethostbyname($ca_host) or die "** Failed to get raw address for host '$ca_host'\n"; - $socket = sockaddr_in($ca_port, $ca_hostent) or die "** Failed packing '$parm_clamsocket'\n"; - } - else - { - die "** Unknown socket domain '$socket_domain' (should not happen)\n"; - } - socket($sock, $socket_domain, SOCK_STREAM, 0) or die "** Unable to open socket '$parm_clamsocket'\n"; - local $SIG{ALRM} = sub { die "** Timeout while connecting to socket '$parm_clamsocket'\n"; }; - alarm(5); - connect($sock, $socket) or die "** Unable to connect to socket '$parm_clamsocket'\n"; - alarm(0); - - my $ofh = select $sock; $| = 1; select $ofh; - print $sock "PING\n"; - - $SIG{ALRM} = sub { die "** Timeout while reading from socket '$parm_clamsocket'\n"; }; - alarm(10); - my $res = <$sock>; - alarm(0); - - $res =~ /PONG/ or die "** Did not get PONG from socket '$parm_clamsocket'. It said: $res\n"; - }; - alarm(0); - - if($@) - { - print " $@"; - print " Assume ClamAV is not running\n"; - } - else - { - $parm_running{ClamAV} = ' '; - print " ClamAV seems to be running\n"; - } - } - else - { - print ", but the socket for clamd could not be determined\n"; - print "Assume ClamAV is not running\n"; - } - } - - else - { - print ", but I can't find a configuration for clamd\n"; - print "Assume ClamAV is not running\n"; - } - } - } - - -################################################## -# Check for redis # -################################################## -if (defined $parm_lookups{redis}) - { - if (system("redis-server -v 2>/dev/null >/dev/null") == 0) - { - print "The redis-server command works\n"; - $parm_running{redis} = ' '; - } - else - { - print "The redis-server command failed: assume Redis not installed\n"; - } + check_running_spamassassin(); + check_running_clamav(); } +check_running_redis(); +check_running_dovecot(); ################################################## # Test for the basic requirements # @@ -3852,7 +3911,7 @@ if (defined $parm_lookups{dbm} && not cp("$parm_exim_dir/exim_dbmbuild", "eximdi $dbm_build_deleted = 1; } -foreach my $tool (qw(exim_dumpdb exim_lock exinext exigrep eximstats exiqgrep)) { +foreach my $tool (qw(exim_dumpdb exim_lock exinext exigrep eximstats exiqgrep exim_msgdate)) { cp("$parm_exim_dir/$tool" => "eximdir/$tool") or tests_exit(-1, "Failed to make a copy of $tool: $!"); } @@ -4315,6 +4374,7 @@ foreach $test (@test_list) $next_port = 1111; $message_skip = 0; $msglog_skip = 0; + $munge_skip = 0; $stderr_skip = 0; $stdout_skip = 0; $rmfiltertest = 0; @@ -4334,6 +4394,7 @@ foreach $test (@test_list) { if (/^no_message_check/) { $message_skip = 1; next; } if (/^no_msglog_check/) { $msglog_skip = 1; next; } + if (/^no_munge/) { $munge_skip = 1; next; } if (/^no_stderr_check/) { $stderr_skip = 1; next; } if (/^no_stdout_check/) { $stdout_skip = 1; next; } if (/^rmfiltertest/) { $rmfiltertest = 1; next; } @@ -4368,6 +4429,7 @@ foreach $test (@test_list) # set above, but doesn't hurt to leave them here. if (/^no_message_check/) { $message_skip = 1; next; } if (/^no_msglog_check/) { $msglog_skip = 1; next; } + if (/^no_munge/) { $munge_skip = 1; next; } if (/^no_stderr_check/) { $stderr_skip = 1; next; } if (/^no_stdout_check/) { $stdout_skip = 1; next; } if (/^rmfiltertest/) { $rmfiltertest = 1; next; }