@@ -19,13 +19,29 @@ package ServerSetup;
19
19
use strict;
20
20
use warnings;
21
21
use TestLib;
22
+ use File::Basename;
23
+ use File::Copy;
22
24
use Test::More;
23
25
24
26
use Exporter ' import' ;
25
27
our @EXPORT = qw(
26
28
configure_test_server_for_ssl switch_server_cert
27
29
) ;
28
30
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
+
29
45
sub configure_test_server_for_ssl
30
46
{
31
47
my $tempdir = $_ [0];
@@ -48,13 +64,12 @@ sub configure_test_server_for_ssl
48
64
49
65
close CONF;
50
66
51
-
52
67
# 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" ) ;
55
70
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" ) ;
58
73
59
74
# Only accept SSL connections from localhost. Our tests don't depend on this
60
75
# but seems best to keep it as narrow as possible for security reasons.
0 commit comments