-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntest
More file actions
executable file
·3774 lines (3043 loc) · 116 KB
/
runtest
File metadata and controls
executable file
·3774 lines (3043 loc) · 116 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#! /usr/bin/perl -w
###############################################################################
# This is the controlling script for the "new" test suite for Exim. It should #
# be possible to export this suite for running on a wide variety of hosts, in #
# contrast to the old suite, which was very dependent on the environment of #
# Philip Hazel's desktop computer. This implementation inspects the version #
# of Exim that it finds, and tests only those features that are included. The #
# surrounding environment is also tested to discover what is available. See #
# the README file for details of how it all works. #
# #
# Implementation started: 03 August 2005 by Philip Hazel #
# Placed in the Exim CVS: 06 February 2006 #
###############################################################################
#use strict;
use Errno;
use FileHandle;
use Socket;
use Time::Local;
use Cwd;
use File::Basename;
use if $ENV{DEBUG} && $ENV{DEBUG} =~ /\bruntest\b/ => ('Smart::Comments' => '####');
# Start by initializing some global variables
$testversion = "4.80 (08-May-12)";
# This gets embedded in the D-H params filename, and the value comes
# from asking GnuTLS for "normal", but there appears to be no way to
# use certtool/... to ask what that value currently is. *sigh*
# We also clamp it because of NSS interop, see addition of tls_dh_max_bits.
# This value is correct as of GnuTLS 2.12.18 as clamped by tls_dh_max_bits.
# normal = 2432 tls_dh_max_bits = 2236
$gnutls_dh_bits_normal = 2236;
$cf = "bin/cf -exact";
$cr = "\r";
$debug = 0;
$force_continue = 0;
$force_update = 0;
$log_failed_filename = "failed-summary.log";
$more = "less -XF";
$optargs = "";
$save_output = 0;
$server_opts = "";
$flavour = 'FOO';
$have_ipv4 = 1;
$have_ipv6 = 1;
$have_largefiles = 0;
$test_start = 1;
$test_end = $test_top = 8999;
$test_special_top = 9999;
@test_list = ();
@test_dirs = ();
# Networks to use for DNS tests. We need to choose some networks that will
# never be used so that there is no chance that the host on which we are
# running is actually in one of the test networks. Private networks such as
# the IPv4 10.0.0.0/8 network are no good because hosts may well use them.
# Rather than use some unassigned numbers (that might become assigned later),
# I have chosen some multicast networks, in the belief that such addresses
# won't ever be assigned to hosts. This is the only place where these numbers
# are defined, so it is trivially possible to change them should that ever
# become necessary.
$parm_ipv4_test_net = "224";
$parm_ipv6_test_net = "ff00";
# Port numbers are currently hard-wired
$parm_port_n = 1223; # Nothing listening on this port
$parm_port_s = 1224; # Used for the "server" command
$parm_port_d = 1225; # Used for the Exim daemon
$parm_port_d2 = 1226; # Additional for daemon
$parm_port_d3 = 1227; # Additional for daemon
$parm_port_d4 = 1228; # Additional for daemon
# Manually set locale
$ENV{'LC_ALL'} = 'C';
# In some environments USER does not exists, but we
# need it for some test(s)
$ENV{USER} = getpwuid($>)
if not exists $ENV{USER};
###############################################################################
###############################################################################
# Define a number of subroutines
###############################################################################
###############################################################################
##################################################
# Handle signals #
##################################################
sub pipehandler { $sigpipehappened = 1; }
sub inthandler { print "\n"; tests_exit(-1, "Caught SIGINT"); }
##################################################
# Do global macro substitutions #
##################################################
# This function is applied to configurations, command lines and data lines in
# scripts, and to lines in the files of the aux-var-src and the dnszones-src
# directory. It takes one argument: the current test number, or zero when
# setting up files before running any tests.
sub do_substitute{
s?\bCALLER\b?$parm_caller?g;
s?\bCALLERGROUP\b?$parm_caller_group?g;
s?\bCALLER_UID\b?$parm_caller_uid?g;
s?\bCALLER_GID\b?$parm_caller_gid?g;
s?\bCLAMSOCKET\b?$parm_clamsocket?g;
s?\bDIR/?$parm_cwd/?g;
s?\bEXIMGROUP\b?$parm_eximgroup?g;
s?\bEXIMUSER\b?$parm_eximuser?g;
s?\bHOSTIPV4\b?$parm_ipv4?g;
s?\bHOSTIPV6\b?$parm_ipv6?g;
s?\bHOSTNAME\b?$parm_hostname?g;
s?\bPORT_D\b?$parm_port_d?g;
s?\bPORT_D2\b?$parm_port_d2?g;
s?\bPORT_D3\b?$parm_port_d3?g;
s?\bPORT_D4\b?$parm_port_d4?g;
s?\bPORT_N\b?$parm_port_n?g;
s?\bPORT_S\b?$parm_port_s?g;
s?\bTESTNUM\b?$_[0]?g;
s?(\b|_)V4NET([\._])?$1$parm_ipv4_test_net$2?g;
s?\bV6NET:?$parm_ipv6_test_net:?g;
}
##################################################
# Any state to be preserved across tests #
##################################################
my $TEST_STATE = {};
##################################################
# Subroutine to tidy up and exit #
##################################################
# In all cases, we check for any Exim daemons that have been left running, and
# kill them. Then remove all the spool data, test output, and the modified Exim
# binary if we are ending normally.
# Arguments:
# $_[0] = 0 for a normal exit; full cleanup done
# $_[0] > 0 for an error exit; no files cleaned up
# $_[0] < 0 for a "die" exit; $_[1] contains a message
sub tests_exit{
my($rc) = $_[0];
my($spool);
# Search for daemon pid files and kill the daemons. We kill with SIGINT rather
# than SIGTERM to stop it outputting "Terminated" to the terminal when not in
# the background.
if (exists $TEST_STATE->{exim_pid})
{
$pid = $TEST_STATE->{exim_pid};
print "Tidyup: killing wait-mode daemon pid=$pid\n";
system("sudo kill -INT $pid");
}
if (opendir(DIR, "spool"))
{
my(@spools) = sort readdir(DIR);
closedir(DIR);
foreach $spool (@spools)
{
next if $spool !~ /^exim-daemon./;
open(PID, "spool/$spool") || die "** Failed to open \"spool/$spool\": $!\n";
chomp($pid = <PID>);
close(PID);
print "Tidyup: killing daemon pid=$pid\n";
system("sudo rm -f spool/$spool; sudo kill -INT $pid");
}
}
else
{ die "** Failed to opendir(\"spool\"): $!\n" unless $!{ENOENT}; }
# Close the terminal input and remove the test files if all went well, unless
# the option to save them is set. Always remove the patched Exim binary. Then
# exit normally, or die.
close(T);
system("sudo /bin/rm -rf ./spool test-* ./dnszones/*")
if ($rc == 0 && !$save_output);
system("sudo /bin/rm -rf ./eximdir/*")
if (!$save_output);
print "\nYou were in test $test at the end there.\n\n" if defined $test;
exit $rc if ($rc >= 0);
die "** runtest error: $_[1]\n";
}
##################################################
# Subroutines used by the munging subroutine #
##################################################
# This function is used for things like message ids, where we want to generate
# more than one value, but keep a consistent mapping throughout.
#
# Arguments:
# $oldid the value from the file
# $base a base string into which we insert a sequence
# $sequence the address of the current sequence counter
sub new_value {
my($oldid, $base, $sequence) = @_;
my($newid) = $cache{$oldid};
if (! defined $newid)
{
$newid = sprintf($base, $$sequence++);
$cache{$oldid} = $newid;
}
return $newid;
}
# This is used while munging the output from exim_dumpdb.
# May go wrong across DST changes.
sub date_seconds {
my($day,$month,$year,$hour,$min,$sec) =
$_[0] =~ /^(\d\d)-(\w\w\w)-(\d{4})\s(\d\d):(\d\d):(\d\d)/;
my($mon);
if ($month =~ /Jan/) {$mon = 0;}
elsif($month =~ /Feb/) {$mon = 1;}
elsif($month =~ /Mar/) {$mon = 2;}
elsif($month =~ /Apr/) {$mon = 3;}
elsif($month =~ /May/) {$mon = 4;}
elsif($month =~ /Jun/) {$mon = 5;}
elsif($month =~ /Jul/) {$mon = 6;}
elsif($month =~ /Aug/) {$mon = 7;}
elsif($month =~ /Sep/) {$mon = 8;}
elsif($month =~ /Oct/) {$mon = 9;}
elsif($month =~ /Nov/) {$mon = 10;}
elsif($month =~ /Dec/) {$mon = 11;}
return timelocal($sec,$min,$hour,$day,$mon,$year);
}
# This is a subroutine to sort maildir files into time-order. The second field
# is the microsecond field, and may vary in length, so must be compared
# numerically.
sub maildirsort {
return $a cmp $b if ($a !~ /^\d+\.H\d/ || $b !~ /^\d+\.H\d/);
my($x1,$y1) = $a =~ /^(\d+)\.H(\d+)/;
my($x2,$y2) = $b =~ /^(\d+)\.H(\d+)/;
return ($x1 != $x2)? ($x1 <=> $x2) : ($y1 <=> $y2);
}
##################################################
# Subroutine list files below a directory #
##################################################
# This is used to build up a list of expected mail files below a certain path
# in the directory tree. It has to be recursive in order to deal with multiple
# maildir mailboxes.
sub list_files_below {
my($dir) = $_[0];
my(@yield) = ();
my(@sublist, $file);
opendir(DIR, $dir) || tests_exit(-1, "Failed to open $dir: $!");
@sublist = sort maildirsort readdir(DIR);
closedir(DIR);
foreach $file (@sublist)
{
next if $file eq "." || $file eq ".." || $file eq "CVS";
if (-d "$dir/$file")
{ @yield = (@yield, list_files_below("$dir/$file")); }
else
{ push @yield, "$dir/$file"; }
}
return @yield;
}
##################################################
# Munge a file before comparing #
##################################################
# The pre-processing turns all dates, times, Exim versions, message ids, and so
# on into standard values, so that the compare works. Perl's substitution with
# an expression provides a neat way to do some of these changes.
# We keep a global associative array for repeatedly turning the same values
# into the same standard values throughout the data from a single test.
# Message ids get this treatment (can't be made reliable for times), and
# times in dumped retry databases are also handled in a special way, as are
# incoming port numbers.
# On entry to the subroutine, the file to write to is already opened with the
# name MUNGED. The input file name is the only argument to the subroutine.
# Certain actions are taken only when the name contains "stderr", "stdout",
# or "log". The yield of the function is 1 if a line matching "*** truncated
# ***" is encountered; otherwise it is 0.
sub munge {
my($file) = $_[0];
my($extra) = $_[1];
my($yield) = 0;
my(@saved) = ();
local $_;
open(IN, "$file") || tests_exit(-1, "Failed to open $file: $!");
my($is_log) = $file =~ /log/;
my($is_stdout) = $file =~ /stdout/;
my($is_stderr) = $file =~ /stderr/;
# Date pattern
$date = "\\d{2}-\\w{3}-\\d{4}\\s\\d{2}:\\d{2}:\\d{2}";
# Pattern for matching pids at start of stderr lines; initially something
# that won't match.
$spid = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx";
# Scan the file and make the changes. Near the bottom there are some changes
# that are specific to certain file types, though there are also some of those
# inline too.
while(<IN>)
{
RESET_AFTER_EXTRA_LINE_READ:
# Custom munges
if ($extra)
{
next if $extra =~ m%^/% && eval $extra;
eval $extra if $extra =~ m/^s/;
}
# Check for "*** truncated ***"
$yield = 1 if /\*\*\* truncated \*\*\*/;
# Replace the name of this host
s/\Q$parm_hostname\E/the.local.host.name/g;
# But convert "name=the.local.host address=127.0.0.1" to use "localhost"
s/name=the\.local\.host address=127\.0\.0\.1/name=localhost address=127.0.0.1/g;
# The name of the shell may vary
s/\s\Q$parm_shell\E\b/ ENV_SHELL/;
# Replace the path to the testsuite directory
s?\Q$parm_cwd\E?TESTSUITE?g;
# Replace the Exim version number (may appear in various places)
# patchexim should have fixed this for us
#s/(Exim) \d+\.\d+[\w_-]*/$1 x.yz/i;
# Replace Exim message ids by a unique series
s/((?:[^\W_]{6}-){2}[^\W_]{2})
/new_value($1, "10Hm%s-0005vi-00", \$next_msgid)/egx;
# The names of lock files appear in some error and debug messages
s/\.lock(\.[-\w]+)+(\.[\da-f]+){2}/.lock.test.ex.dddddddd.pppppppp/;
# Unless we are in an IPv6 test, replace IPv4 and/or IPv6 in "listening on
# port" message, because it is not always the same.
s/port (\d+) \([^)]+\)/port $1/g
if !$is_ipv6test && m/listening for SMTP(S?) on port/;
# Challenges in SPA authentication
s/TlRMTVNTUAACAAAAAAAAAAAoAAABgg[\w+\/]+/TlRMTVNTUAACAAAAAAAAAAAoAAABggAAAEbBRwqFwwIAAAAAAAAAAAAt1sgAAAAA/;
# PRVS values
s?prvs=([^/]+)/[\da-f]{10}@?prvs=$1/xxxxxxxxxx@?g; # Old form
s?prvs=[\da-f]{10}=([^@]+)@?prvs=xxxxxxxxxx=$1@?g; # New form
# Error lines on stdout from SSL contain process id values and file names.
# They also contain a source file name and line number, which may vary from
# release to release.
s/^\d+:error:/pppp:error:/;
s/:(?:\/[^\s:]+\/)?([^\/\s]+\.c):\d+:/:$1:dddd:/;
# There are differences in error messages between OpenSSL versions
s/SSL_CTX_set_cipher_list/SSL_connect/;
# One error test in expansions mentions base 62 or 36
s/is not a base (36|62) number/is not a base 36\/62 number/;
# This message sometimes has a different number of seconds
s/forced fail after \d seconds/forced fail after d seconds/;
# This message may contain a different DBM library name
s/Failed to open \S+( \([^\)]+\))? file/Failed to open DBM file/;
# The message for a non-listening FIFO varies
s/:[^:]+: while opening named pipe/: Error: while opening named pipe/;
# Debugging output of lists of hosts may have different sort keys
s/sort=\S+/sort=xx/ if /^\S+ (?:\d+\.){3}\d+ mx=\S+ sort=\S+/;
# Random local part in callout cache testing
s/myhost.test.ex-\d+-testing/myhost.test.ex-dddddddd-testing/;
s/the.local.host.name-\d+-testing/the.local.host.name-dddddddd-testing/;
# File descriptor numbers may vary
s/^writing data block fd=\d+/writing data block fd=dddd/;
s/running as transport filter: write=\d+ read=\d+/running as transport filter: write=dddd read=dddd/;
# ======== Dumpdb output ========
# This must be before the general date/date munging.
# Time data lines, which look like this:
# 25-Aug-2000 12:11:37 25-Aug-2000 12:11:37 26-Aug-2000 12:11:37
if (/^($date)\s+($date)\s+($date)(\s+\*)?\s*$/)
{
my($date1,$date2,$date3,$expired) = ($1,$2,$3,$4);
$expired = "" if !defined $expired;
my($increment) = date_seconds($date3) - date_seconds($date2);
# We used to use globally unique replacement values, but timing
# differences make this impossible. Just show the increment on the
# last one.
printf MUNGED ("first failed = time last try = time2 next try = time2 + %s%s\n",
$increment, $expired);
next;
}
# more_errno values in exim_dumpdb output which are times
s/T:(\S+)\s-22\s(\S+)\s/T:$1 -22 xxxx /;
# ======== Dates and times ========
# Dates and times are all turned into the same value - trying to turn
# them into different ones cannot be done repeatedly because they are
# real time stamps generated while running the test. The actual date and
# time used was fixed when I first started running automatic Exim tests.
# Date/time in header lines and SMTP responses
s/[A-Z][a-z]{2},\s\d\d?\s[A-Z][a-z]{2}\s\d\d\d\d\s\d\d\:\d\d:\d\d\s[-+]\d{4}
/Tue, 2 Mar 1999 09:44:33 +0000/gx;
# Date/time in logs and in one instance of a filter test
s/^\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d(\s[+-]\d\d\d\d)?/1999-03-02 09:44:33/gx;
s/^Logwrite\s"\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d/Logwrite "1999-03-02 09:44:33/gx;
# Date/time in message separators
s/(?:[A-Z][a-z]{2}\s){2}\d\d\s\d\d:\d\d:\d\d\s\d\d\d\d
/Tue Mar 02 09:44:33 1999/gx;
# Date of message arrival in spool file as shown by -Mvh
s/^\d{9,10}\s0$/ddddddddd 0/;
# Date/time in mbx mailbox files
s/\d\d-\w\w\w-\d\d\d\d\s\d\d:\d\d:\d\d\s[-+]\d\d\d\d,/06-Sep-1999 15:52:48 +0100,/gx;
# Dates/times in debugging output for writing retry records
if (/^ first failed=(\d+) last try=(\d+) next try=(\d+) (.*)$/)
{
my($next) = $3 - $2;
$_ = " first failed=dddd last try=dddd next try=+$next $4\n";
}
s/^(\s*)now=\d+ first_failed=\d+ next_try=\d+ expired=(\d)/$1now=tttt first_failed=tttt next_try=tttt expired=$2/;
s/^(\s*)received_time=\d+ diff=\d+ timeout=(\d+)/$1received_time=tttt diff=tttt timeout=$2/;
# Time to retry may vary
s/time to retry = \S+/time to retry = tttt/;
s/retry record exists: age=\S+/retry record exists: age=ttt/;
s/failing_interval=\S+ message_age=\S+/failing_interval=ttt message_age=ttt/;
# Date/time in exim -bV output
s/\d\d-[A-Z][a-z]{2}-\d{4}\s\d\d:\d\d:\d\d/07-Mar-2000 12:21:52/g;
# Time on queue tolerance
s/(QT|D)=1s/$1=0s/;
# Eximstats heading
s/Exim\sstatistics\sfrom\s\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d\sto\s
\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d/Exim statistics from <time> to <time>/x;
# Treat ECONNRESET the same as ECONNREFUSED. At least some systems give
# us the former on a new connection.
s/(could not connect to .*: Connection) reset by peer$/$1 refused/;
# ======== TLS certificate algorithms ========
# Test machines might have various different TLS library versions supporting
# different protocols; can't rely upon TLS 1.2's AES256-GCM-SHA384, so we
# treat the standard algorithms the same.
# So far, have seen:
# TLSv1:AES128-GCM-SHA256:128
# TLSv1:AES256-SHA:256
# TLSv1.1:AES256-SHA:256
# TLSv1.2:AES256-GCM-SHA384:256
# TLSv1.2:DHE-RSA-AES256-SHA:256
# TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128
# We also need to handle the ciphersuite without the TLS part present, for
# client-ssl's output. We also see some older forced ciphersuites, but
# negotiating TLS 1.2 instead of 1.0.
# Mail headers (...), log-lines X=..., client-ssl output ...
# (and \b doesn't match between ' ' and '(' )
s/( (?: (?:\b|\s) [\(=] ) | \s )TLSv1\.[12]:/$1TLSv1:/xg;
s/\bAES128-GCM-SHA256:128\b/AES256-SHA:256/g;
s/\bAES128-GCM-SHA256\b/AES256-SHA/g;
s/\bAES256-GCM-SHA384\b/AES256-SHA/g;
s/\bDHE-RSA-AES256-SHA\b/AES256-SHA/g;
# GnuTLS have seen:
# TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256
# TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128
# TLS1.2:RSA_AES_256_CBC_SHA1:256 (canonical)
# TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128
#
# X=TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256
# X=TLS1.2:RSA_AES_256_CBC_SHA1:256
# X=TLS1.1:RSA_AES_256_CBC_SHA1:256
# X=TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256
# and as stand-alone cipher:
# ECDHE-RSA-AES256-SHA
# DHE-RSA-AES256-SHA256
# DHE-RSA-AES256-SHA
# picking latter as canonical simply because regex easier that way.
s/\bDHE_RSA_AES_128_CBC_SHA1:128/RSA_AES_256_CBC_SHA1:256/g;
s/TLS1.[012]:((EC)?DHE_)?RSA_AES_(256|128)_(CBC|GCM)_SHA(1|256|384):(256|128)/TLS1.x:xxxxRSA_AES_256_CBC_SHAnnn:256/g;
s/\b(ECDHE-RSA-AES256-SHA|DHE-RSA-AES256-SHA256)\b/AES256-SHA/g;
# GnuTLS library error message changes
s/No certificate was found/The peer did not send any certificate/g;
#(dodgy test?) s/\(certificate verification failed\): invalid/\(gnutls_handshake\): The peer did not send any certificate./g;
s/\(gnutls_priority_set\): No or insufficient priorities were set/\(gnutls_handshake\): Could not negotiate a supported cipher suite/g;
# (this new one is a generic channel-read error, but the testsuite
# only hits it in one place)
s/TLS error on connection \(gnutls_handshake\): Error in the pull function\./a TLS session is required but an attempt to start TLS failed/g;
# (replace old with new, hoping that old only happens in one situation)
s/TLS error on connection to \d{1,3}(.\d{1,3}){3} \[\d{1,3}(.\d{1,3}){3}\] \(gnutls_handshake\): A TLS packet with unexpected length was received./a TLS session is required for ip4.ip4.ip4.ip4 [ip4.ip4.ip4.ip4], but an attempt to start TLS failed/g;
s/TLS error on connection from \[127.0.0.1\] \(recv\): A TLS packet with unexpected length was received./TLS error on connection from [127.0.0.1] (recv): The TLS connection was non-properly terminated./g;
# signature algorithm names
s/RSA-SHA1/RSA-SHA/;
# ======== Caller's login, uid, gid, home, gecos ========
s/\Q$parm_caller_home\E/CALLER_HOME/g; # NOTE: these must be done
s/\b\Q$parm_caller\E\b/CALLER/g; # in this order!
s/\b\Q$parm_caller_group\E\b/CALLER/g; # In case group name different
s/\beuid=$parm_caller_uid\b/euid=CALLER_UID/g;
s/\begid=$parm_caller_gid\b/egid=CALLER_GID/g;
s/\buid=$parm_caller_uid\b/uid=CALLER_UID/g;
s/\bgid=$parm_caller_gid\b/gid=CALLER_GID/g;
s/\bname="?$parm_caller_gecos"?/name=CALLER_GECOS/g;
# When looking at spool files with -Mvh, we will find not only the caller
# login, but also the uid and gid. It seems that $) in some Perls gives all
# the auxiliary gids as well, so don't bother checking for that.
s/^CALLER $> \d+$/CALLER UID GID/;
# There is one case where the caller's login is forced to something else,
# in order to test the processing of logins that contain spaces. Weird what
# some people do, isn't it?
s/^spaced user $> \d+$/CALLER UID GID/;
# ======== Exim's login ========
# For messages received by the daemon, this is in the -H file, which some
# tests inspect. For bounce messages, this will appear on the U= lines in
# logs and also after Received: and in addresses. In one pipe test it appears
# after "Running as:". It also appears in addresses, and in the names of lock
# files.
s/U=$parm_eximuser/U=EXIMUSER/;
s/user=$parm_eximuser/user=EXIMUSER/;
s/login=$parm_eximuser/login=EXIMUSER/;
s/Received: from $parm_eximuser /Received: from EXIMUSER /;
s/Running as: $parm_eximuser/Running as: EXIMUSER/;
s/\b$parm_eximuser@/EXIMUSER@/;
s/\b$parm_eximuser\.lock\./EXIMUSER.lock./;
s/\beuid=$parm_exim_uid\b/euid=EXIM_UID/g;
s/\begid=$parm_exim_gid\b/egid=EXIM_GID/g;
s/\buid=$parm_exim_uid\b/uid=EXIM_UID/g;
s/\bgid=$parm_exim_gid\b/gid=EXIM_GID/g;
s/^$parm_eximuser $parm_exim_uid $parm_exim_gid/EXIMUSER EXIM_UID EXIM_GID/;
# ======== General uids, gids, and pids ========
# Note: this must come after munges for caller's and exim's uid/gid
# These are for systems where long int is 64
s/\buid=4294967295/uid=-1/;
s/\beuid=4294967295/euid=-1/;
s/\bgid=4294967295/gid=-1/;
s/\begid=4294967295/egid=-1/;
s/\bgid=\d+/gid=gggg/;
s/\begid=\d+/egid=gggg/;
s/\bpid=\d+/pid=pppp/;
s/\buid=\d+/uid=uuuu/;
s/\beuid=\d+/euid=uuuu/;
s/set_process_info:\s+\d+/set_process_info: pppp/;
s/queue run pid \d+/queue run pid ppppp/;
s/process \d+ running as transport filter/process pppp running as transport filter/;
s/process \d+ writing to transport filter/process pppp writing to transport filter/;
s/reading pipe for subprocess \d+/reading pipe for subprocess pppp/;
s/remote delivery process \d+ ended/remote delivery process pppp ended/;
# Pid in temp file in appendfile transport
s"test-mail/temp\.\d+\."test-mail/temp.pppp.";
# Optional pid in log lines
s/^(\d{4}-\d\d-\d\d\s\d\d:\d\d:\d\d)(\s[+-]\d\d\d\d|)(\s\[\d+\])/
"$1$2 [" . new_value($3, "%s", \$next_pid) . "]"/gxe;
# Detect a daemon stderr line with a pid and save the pid for subsequent
# removal from following lines.
$spid = $1 if /^(\s*\d+) (?:listening|LOG: MAIN|(?:daemon_smtp_port|local_interfaces) overridden by)/;
s/^$spid //;
# Queue runner waiting messages
s/waiting for children of \d+/waiting for children of pppp/;
s/waiting for (\S+) \(\d+\)/waiting for $1 (pppp)/;
# ======== Port numbers ========
# Incoming port numbers may vary, but not in daemon startup line.
s/^Port: (\d+)/"Port: " . new_value($1, "%s", \$next_port)/e;
s/\(port=(\d+)/"(port=" . new_value($1, "%s", \$next_port)/e;
# This handles "connection from" and the like, when the port is given
if (!/listening for SMTP on/ && !/Connecting to/ && !/=>/ && !/->/
&& !/\*>/ && !/Connection refused/)
{
s/\[([a-z\d:]+|\d+(?:\.\d+){3})\]:(\d+)/"[".$1."]:".new_value($2,"%s",\$next_port)/ie;
}
# Port in host address in spool file output from -Mvh
s/^-host_address (.*)\.\d+/-host_address $1.9999/;
# ======== Local IP addresses ========
# The amount of space between "host" and the address in verification output
# depends on the length of the host name. We therefore reduce it to one space
# for all of them.
# Also, the length of space at the end of the host line is dependent
# on the length of the longest line, so strip it also on otherwise
# un-rewritten lines like localhost
s/^\s+host\s(\S+)\s+(\S+)/ host $1 $2/;
s/^\s+(host\s\S+\s\S+)\s+(port=.*)/ host $1 $2/;
s/^\s+(host\s\S+\s\S+)\s+(?=MX=)/ $1 /;
s/^\s+host\s.*?\K\s+(ad=\S+)/ $1/;
s/host\s\Q$parm_ipv4\E\s\[\Q$parm_ipv4\E\]/host ipv4.ipv4.ipv4.ipv4 [ipv4.ipv4.ipv4.ipv4]/;
s/host\s\Q$parm_ipv6\E\s\[\Q$parm_ipv6\E\]/host ip6:ip6:ip6:ip6:ip6:ip6:ip6:ip6 [ip6:ip6:ip6:ip6:ip6:ip6:ip6:ip6]/;
s/\b\Q$parm_ipv4\E\b/ip4.ip4.ip4.ip4/g;
s/(^|\W)\K\Q$parm_ipv6\E/ip6:ip6:ip6:ip6:ip6:ip6:ip6:ip6/g;
s/\b\Q$parm_ipv4r\E\b/ip4-reverse/g;
s/(^|\W)\K\Q$parm_ipv6r\E/ip6-reverse/g;
s/^(\s+host\s\S+\s+\[\S+\]) +$/$1 /;
# ======== Test network IP addresses ========
s/(\b|_)\Q$parm_ipv4_test_net\E(?=\.\d+\.\d+\.\d+\b|_|\.rbl|\.in-addr|\.test\.again\.dns)/$1V4NET/g;
s/\b\Q$parm_ipv6_test_net\E(?=:[\da-f]+:[\da-f]+:[\da-f]+)/V6NET/gi;
# ======== IP error numbers and messages ========
# These vary between operating systems
s/Can't assign requested address/Network Error/;
s/Cannot assign requested address/Network Error/;
s/Operation timed out/Connection timed out/;
s/Address family not supported by protocol family/Network Error/;
s/Network is unreachable/Network Error/;
s/Invalid argument/Network Error/;
s/\(\d+\): Network/(dd): Network/;
s/\(\d+\): Connection refused/(dd): Connection refused/;
s/\(\d+\): Connection timed out/(dd): Connection timed out/;
s/\d+ 65 Connection refused/dd 65 Connection refused/;
s/\d+ 321 Connection timed out/dd 321 Connection timed out/;
# ======== Other error numbers ========
s/errno=\d+/errno=dd/g;
# ======== System Error Messages ======
# depending on the underlaying file system the error message seems to differ
s/(?: is not a regular file)|(?: has too many links \(\d+\))/ not a regular file or too many links/;
# ======== Output from ls ========
# Different operating systems use different spacing on long output
#s/ +/ /g if /^[-rwd]{10} /;
# (Bug 1226) SUSv3 allows a trailing printable char for modified access method control.
# Handle only the Gnu and MacOS space, dot, plus and at-sign. A full [[:graph:]]
# unfortunately matches a non-ls linefull of dashes.
# Allow the case where we've already picked out the file protection bits.
if (s/^([-d](?:[-r][-w][-SsTtx]){3})[.+@]?( +|$)/$1$2/) {
s/ +/ /g;
}
# ======== Message sizes =========
# Message sizes vary, owing to different logins and host names that get
# automatically inserted. I can't think of any way of even approximately
# comparing these.
s/([\s,])S=\d+\b/$1S=sss/;
s/:S\d+\b/:Ssss/;
s/^(\s*\d+m\s+)\d+(\s+[a-z0-9-]{16} <)/$1sss$2/i if $is_stdout;
s/\sSIZE=\d+\b/ SIZE=ssss/;
s/\ssize=\d+\b/ size=sss/ if $is_stderr;
s/old size = \d+\b/old size = sssss/;
s/message size = \d+\b/message size = sss/;
s/this message = \d+\b/this message = sss/;
s/Size of headers = \d+/Size of headers = sss/;
s/sum=(?!0)\d+/sum=dddd/;
s/(?<=sum=dddd )count=\d+\b/count=dd/;
s/(?<=sum=0 )count=\d+\b/count=dd/;
s/,S is \d+\b/,S is ddddd/;
s/\+0100,\d+;/+0100,ddd;/;
s/\(\d+ bytes written\)/(ddd bytes written)/;
s/added '\d+ 1'/added 'ddd 1'/;
s/Received\s+\d+/Received nnn/;
s/Delivered\s+\d+/Delivered nnn/;
# ======== Values in spool space failure message ========
s/space=\d+ inodes=[+-]?\d+/space=xxxxx inodes=xxxxx/;
# ======== Filter sizes ========
# The sizes of filter files may vary because of the substitution of local
# filenames, logins, etc.
s/^\d+(?= bytes read from )/ssss/;
# ======== OpenSSL error messages ========
# Different releases of the OpenSSL libraries seem to give different error
# numbers, or handle specific bad conditions in different ways, leading to
# different wording in the error messages, so we cannot compare them.
s/(TLS error on connection (?:from .* )?\(SSL_\w+\): error:)(.*)/$1 <<detail omitted>>/;
# ======== Maildir things ========
# timestamp output in maildir processing
s/(timestamp=|\(timestamp_only\): )\d+/$1ddddddd/g;
# maildir delivery files appearing in log lines (in cases of error)
s/writing to(?: file)? tmp\/\d+\.[^.]+\.(\S+)/writing to tmp\/MAILDIR.$1/;
s/renamed tmp\/\d+\.[^.]+\.(\S+) as new\/\d+\.[^.]+\.(\S+)/renamed tmp\/MAILDIR.$1 as new\/MAILDIR.$1/;
# Maildir file names in general
s/\b\d+\.H\d+P\d+\b/dddddddddd.HddddddPddddd/;
# Maildirsize data
while (/^\d+S,\d+C\s*$/)
{
print MUNGED;
while (<IN>)
{
last if !/^\d+ \d+\s*$/;
print MUNGED "ddd d\n";
}
last if !defined $_;
}
last if !defined $_;
# ======== Output from the "fd" program about open descriptors ========
# The statuses seem to be different on different operating systems, but
# at least we'll still be checking the number of open fd's.
s/max fd = \d+/max fd = dddd/;
s/status=0 RDONLY/STATUS/g;
s/status=1 WRONLY/STATUS/g;
s/status=2 RDWR/STATUS/g;
# ======== Contents of spool files ========
# A couple of tests dump the contents of the -H file. The length fields
# will be wrong because of different user names, etc.
s/^\d\d\d(?=[PFS*])/ddd/;
# ========= Exim lookups ==================
# Lookups have a char which depends on the number of lookup types compiled in,
# in stderr output. Replace with a "0". Recognising this while avoiding
# other output is fragile; perhaps the debug output should be revised instead.
s%(?<!sqlite)(?<!lsearch\*@)(?<!lsearch\*)(?<!lsearch)[0-?]TESTSUITE/aux-fixed/%0TESTSUITE/aux-fixed/%g;
# ==========================================================
# MIME boundaries in RFC3461 DSN messages
s/\d{8,10}-eximdsn-\d+/NNNNNNNNNN-eximdsn-MMMMMMMMMM/;
# ==========================================================
# Some munging is specific to the specific file types
# ======== stdout ========
if ($is_stdout)
{
# Skip translate_ip_address and use_classresources in -bP output because
# they aren't always there.
next if /translate_ip_address =/;
next if /use_classresources/;
# In certain filter tests, remove initial filter lines because they just
# clog up by repetition.
if ($rmfiltertest)
{
next if /^(Sender\staken\sfrom|
Return-path\scopied\sfrom|
Sender\s+=|
Recipient\s+=)/x;
if (/^Testing \S+ filter/)
{
$_ = <IN>; # remove blank line
next;
}
}
# openssl version variances
next if /^SSL info: unknown state/;
next if /^SSL info: SSLv2\/v3 write client hello A/;
next if /^SSL info: SSLv3 read server key exchange A/;
}
# ======== stderr ========
elsif ($is_stderr)
{
# The very first line of debugging output will vary
s/^Exim version .*/Exim version x.yz ..../;
# Debugging lines for Exim terminations
s/(?<=^>>>>>>>>>>>>>>>> Exim pid=)\d+(?= terminating)/pppp/;
# IP address lookups use gethostbyname() when IPv6 is not supported,
# and gethostbyname2() or getipnodebyname() when it is.
s/\b(gethostbyname2?|\bgetipnodebyname)(\(af=inet\))?/get[host|ipnode]byname[2]/;
# drop gnutls version strings
next if /GnuTLS compile-time version: \d+[\.\d]+$/;
next if /GnuTLS runtime version: \d+[\.\d]+$/;
# drop openssl version strings
next if /OpenSSL compile-time version: OpenSSL \d+[\.\da-z]+/;
next if /OpenSSL runtime version: OpenSSL \d+[\.\da-z]+/;
# drop lookups
next if /^Lookups \(built-in\):/;
next if /^Loading lookup modules from/;
next if /^Loaded \d+ lookup modules/;
next if /^Total \d+ lookups/;
# drop compiler information
next if /^Compiler:/;
# and the ugly bit
# different libraries will have different numbers (possibly 0) of follow-up
# lines, indenting with more data
if (/^Library version:/) {
while (1) {
$_ = <IN>;
next if /^\s/;
goto RESET_AFTER_EXTRA_LINE_READ;
}
}
# drop other build-time controls emitted for debugging
next if /^WHITELIST_D_MACROS:/;
next if /^TRUSTED_CONFIG_LIST:/;
# As of Exim 4.74, we log when a setgid fails; because we invoke Exim
# with -be, privileges will have been dropped, so this will always
# be the case
next if /^changing group to \d+ failed: (Operation not permitted|Not owner)/;
# We might not keep this check; rather than change all the tests, just
# ignore it as long as it succeeds; then we only need to change the
# TLS tests where tls_require_ciphers has been set.
if (m{^changed uid/gid: calling tls_validate_require_cipher}) {
my $discard = <IN>;
next;
}
next if /^tls_validate_require_cipher child \d+ ended: status=0x0/;
# We invoke Exim with -D, so we hit this new messag as of Exim 4.73:
next if /^macros_trusted overridden to true by whitelisting/;
# We have to omit the localhost ::1 address so that all is well in
# the IPv4-only case.
print MUNGED "MUNGED: ::1 will be omitted in what follows\n"
if (/looked up these IP addresses/);
next if /name=localhost address=::1/;
# drop pdkim debugging header
next if /^PDKIM <<<<<<<<<<<<<<<<<<<<<<<<<<<<<+$/;
# Various other IPv6 lines must be omitted too
next if /using host_fake_gethostbyname for \S+ \(IPv6\)/;
next if /get\[host\|ipnode\]byname\[2\]\(af=inet6\)/;
next if /DNS lookup of \S+ \(AAAA\) using fakens/;
next if / in dns_ipv4_lookup?/;
if (/DNS lookup of \S+ \(AAAA\) gave NO_DATA/)
{
$_= <IN>; # Gets "returning DNS_NODATA"
next;
}
# Skip tls_advertise_hosts and hosts_require_tls checks when the options
# are unset, because tls ain't always there.
next if /in\s(?:tls_advertise_hosts\?|hosts_require_tls\?)
\sno\s\(option\sunset\)/x;
# Skip auxiliary group lists because they will vary.
next if /auxiliary group list:/;
# Skip "extracted from gecos field" because the gecos field varies
next if /extracted from gecos field/;
# Skip "waiting for data on socket" and "read response data: size=" lines
# because some systems pack more stuff into packets than others.
next if /waiting for data on socket/;
next if /read response data: size=/;
# If Exim is compiled with readline support but it can't find the library
# to load, there will be an extra debug line. Omit it.
next if /failed to load readline:/;
# Some DBM libraries seem to make DBM files on opening with O_RDWR without
# O_CREAT; other's don't. In the latter case there is some debugging output
# which is not present in the former. Skip the relevant lines (there are
# two of them).
if (/TESTSUITE\/spool\/db\/\S+ appears not to exist: trying to create/)
{
$_ = <IN>;
next;
}
# Some tests turn on +expand debugging to check on expansions.
# Unfortunately, the Received: expansion varies, depending on whether TLS
# is compiled or not. So we must remove the relevant debugging if it is.
if (/^condition: def:tls_cipher/)
{
while (<IN>) { last if /^condition: def:sender_address/; }
}
elsif (/^expanding: Received: /)
{
while (<IN>) { last if !/^\s/; }
}