diff options
author | Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> | 2016-11-02 22:28:18 +0100 |
---|---|---|
committer | Heiko Schlittermann (HS12-RIPE) <hs@schlittermann.de> | 2016-11-02 22:30:32 +0100 |
commit | 1f187290089991b306083d9418a6cacb6a400f6b (patch) | |
tree | 6160ab2d1c096aa0a94e4d15a8119f8ed3f14ac8 /test/lib | |
parent | 0b9ead6dd2746efbdc7525ba32816b85e9534263 (diff) |
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.
Diffstat (limited to 'test/lib')
-rw-r--r-- | test/lib/Exim/Runtest.pm | 28 |
1 files changed, 28 insertions, 0 deletions
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; |