@@ -19,13 +19,29 @@ package ServerSetup;
1919use strict;
2020use warnings;
2121use TestLib;
22+ use File::Basename;
23+ use File::Copy;
2224use Test::More;
2325
2426use Exporter ' import' ;
2527our @EXPORT = qw(
2628 configure_test_server_for_ssl switch_server_cert
2729) ;
2830
31+ # Copy a set of files, taking into account wildcards
32+ sub copy_files
33+ {
34+ my $orig = shift ;
35+ my $dest = shift ;
36+
37+ my @orig_files = glob $orig ;
38+ foreach my $orig_file (@orig_files )
39+ {
40+ my $base_file = basename($orig_file );
41+ copy($orig_file , " $dest /$base_file " ) or die " Could not copy $orig_file to $dest " ;
42+ }
43+ }
44+
2945sub configure_test_server_for_ssl
3046{
3147 my $tempdir = $_ [0];
@@ -48,13 +64,12 @@ sub configure_test_server_for_ssl
4864
4965 close CONF;
5066
51-
5267 # Copy all server certificates and keys, and client root cert, to the data dir
53- system_or_bail " cp ssl/server-*.crt ' $tempdir ' /pgdata" ;
54- system_or_bail " cp ssl/server-*.key ' $tempdir ' /pgdata" ;
68+ copy_files( " ssl/server-*.crt" , " $tempdir /pgdata" ) ;
69+ copy_files( " ssl/server-*.key" , " $tempdir /pgdata" ) ;
5570 system_or_bail " chmod 0600 '$tempdir '/pgdata/server-*.key" ;
56- system_or_bail " cp ssl/root+client_ca.crt ' $tempdir ' /pgdata" ;
57- system_or_bail " cp ssl/root+client.crl ' $tempdir ' /pgdata" ;
71+ copy_files( " ssl/root+client_ca.crt" , " $tempdir /pgdata" ) ;
72+ copy_files( " ssl/root+client.crl" , " $tempdir /pgdata" ) ;
5873
5974 # Only accept SSL connections from localhost. Our tests don't depend on this
6075 # but seems best to keep it as narrow as possible for security reasons.
0 commit comments