7 use List::Util qw'shuffle';
10 # find a group name, preferrable 'mail', but
11 # use some other random name if 'mail' isn't a valid group
16 croak "Need a group *name*, not a numeric group id."
19 return $group if getgrnam $group;
22 setgrent or die "setgrent: $!\n";
23 push @groups, $_ while defined($_ = getgrent);
25 return (shuffle @groups)[0];
30 for (my $port = 1024; $port < 65000; $port++) {
31 $socket = IO::Socket::INET->new(
32 LocalHost => '127.0.0.1',
38 croak 'Can not allocate a free port.';