From 1f187290089991b306083d9418a6cacb6a400f6b Mon Sep 17 00:00:00 2001 From: "Heiko Schlittermann (HS12-RIPE)" Date: Wed, 2 Nov 2016 22:28:18 +0100 Subject: [PATCH] Testsuite: find a group name if 'mail' is not available. If the group 'mail' does not exist (as on some *BSD systems), test 0001 fails. We now use a randomly choosen group, if necessary. The group name isn't used for anything else than testing the config file parser. --- test/confs/0001 | 14 +++++++------- test/lib/Exim/Runtest.pm | 28 ++++++++++++++++++++++++++++ test/runtest | 10 ++++++++++ 3 files changed, 45 insertions(+), 7 deletions(-) create mode 100644 test/lib/Exim/Runtest.pm diff --git a/test/confs/0001 b/test/confs/0001 index 8d55b2989..1eb0e884c 100644 --- a/test/confs/0001 +++ b/test/confs/0001 @@ -198,7 +198,7 @@ no_syslog_timestamp system_filter = /home/exim/test/filter system_filter_directory_transport = system_filter_file_transport = -system_filter_group = mail +system_filter_group = MAILGROUP system_filter_pipe_transport = system_filter_reply_transport = system_filter_user = 99 @@ -236,7 +236,7 @@ manualroute: no_fail_verify_recipient no_fail_verify_sender fallback_hosts = localhost - group = mail + group = MAILGROUP headers_add = headers_remove = host_find_failed = freeze @@ -370,7 +370,7 @@ forward: forbid_filter_run no_forbid_include no_forbid_pipe - group = mail + group = MAILGROUP headers_add = headers_remove = hide_child_in_errmsg @@ -386,7 +386,7 @@ forward: more no_one_time owners = root - owngroups = mail + owngroups = MAILGROUP pipe_transport = dummy no_qualify_preserve_domain redirect_router = aliasfile2 @@ -420,7 +420,7 @@ localuser: no_fail_verify_recipient no_fail_verify_sender fallback_hosts = - group = mail + group = MAILGROUP headers_add = X-added: by localuser headers_remove = no_initgroups @@ -460,7 +460,7 @@ smartuser: file_transport = dummy forbid_file forbid_pipe - group = mail + group = MAILGROUP headers_add = headers_remove = hide_child_in_errmsg @@ -519,7 +519,7 @@ appendfile: file = /home/$local_part/inbox file_format = "From : appendfile" no_file_must_exist - group = mail + group = MAILGROUP headers_add = X-original-domain: $original_domain\nX-original-localp: $original_local_part headers_remove = headers_rewrite = a@b c@d diff --git a/test/lib/Exim/Runtest.pm b/test/lib/Exim/Runtest.pm new file mode 100644 index 000000000..2ac9a61ee --- /dev/null +++ b/test/lib/Exim/Runtest.pm @@ -0,0 +1,28 @@ +package Exim::Runtest; +use strict; +use warnings; +use Carp; + +use List::Util qw'shuffle'; + + +# find a group name, preferrable 'mail', but +# use some other random name if 'mail' isn't a valid group +# name +sub mailgroup { + my $group = shift; + + croak "Need a group *name*, not a numeric group id." + if $group =~ /^\d+$/; + + return $group if getgrnam $group; + + my @groups; + setgrent or die "setgrent: $!\n"; + push @groups, $_ while defined($_ = getgrent); + endgrent; + return (shuffle @groups)[0]; +}; + + +1; diff --git a/test/runtest b/test/runtest index e8fbe4844..78cd051d3 100755 --- a/test/runtest +++ b/test/runtest @@ -26,6 +26,11 @@ use Socket; use Time::Local; use Cwd; use File::Basename; +use FindBin qw'$Bin'; + +use lib "$Bin/lib"; +use Exim::Runtest; + use if $ENV{DEBUG} && $ENV{DEBUG} =~ /\bruntest\b/ => ('Smart::Comments' => '####'); @@ -88,6 +93,10 @@ $parm_port_d3 = 1227; # Additional for daemon $parm_port_d4 = 1228; # Additional for daemon my $dynamic_socket; # allocated later for PORT_DYNAMIC +# Find a suiteable group name for test (currently only 0001 +# uses a group name. A numeric group id would do +my $parm_mailgroup = Exim::Runtest::mailgroup('mail'); + # Manually set locale $ENV{LC_ALL} = 'C'; @@ -149,6 +158,7 @@ s?\bTESTNUM\b?$_[0]?g; s?(\b|_)V4NET([\._])?$1$parm_ipv4_test_net$2?g; s?\bV6NET:?$parm_ipv6_test_net:?g; s?\bPORT_DYNAMIC\b?$dynamic_socket->sockport()?eg; +s?\bMAILGROUP\b?$parm_mailgroup?g; } -- 2.30.2