mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 23:11:15 +02:00
Deal with paths containing \ and spaces in basebackup_to_shell tests
As $gzip is embedded in postgresql.conf \ needs to be escaped, otherwise guc.c
will take it as a string escape. Similarly, if "$gzip" contains spaces, the
prior incantation will fail. Both of these are common on windows.
Reviewed-by: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Discussion: https://postgr.es/m/ce1b6eb3-5736-6f38-9775-b7020128b8d8@enterprisedb.com
Backpatch: 15-, where the test was added in 027fa0fd72
This commit is contained in:
parent
9a01ea73da
commit
1ab0719836
@ -16,6 +16,9 @@ if (!defined $gzip || $gzip eq '')
|
|||||||
plan skip_all => 'gzip not available';
|
plan skip_all => 'gzip not available';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# to ensure path can be embedded in postgresql.conf
|
||||||
|
$gzip =~ s{\\}{/}g if ($PostgreSQL::Test::Utils::windows_os);
|
||||||
|
|
||||||
my $node = PostgreSQL::Test::Cluster->new('primary');
|
my $node = PostgreSQL::Test::Cluster->new('primary');
|
||||||
|
|
||||||
# Make sure pg_hba.conf is set up to allow connections from backupuser.
|
# Make sure pg_hba.conf is set up to allow connections from backupuser.
|
||||||
@ -53,8 +56,8 @@ $escaped_backup_path =~ s{\\}{\\\\}g
|
|||||||
if ($PostgreSQL::Test::Utils::windows_os);
|
if ($PostgreSQL::Test::Utils::windows_os);
|
||||||
my $shell_command =
|
my $shell_command =
|
||||||
$PostgreSQL::Test::Utils::windows_os
|
$PostgreSQL::Test::Utils::windows_os
|
||||||
? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
|
? qq{"$gzip" --fast > "$escaped_backup_path\\\\%f.gz"}
|
||||||
: qq{$gzip --fast > "$escaped_backup_path/%f.gz"};
|
: qq{"$gzip" --fast > "$escaped_backup_path/%f.gz"};
|
||||||
$node->append_conf('postgresql.conf',
|
$node->append_conf('postgresql.conf',
|
||||||
"basebackup_to_shell.command='$shell_command'");
|
"basebackup_to_shell.command='$shell_command'");
|
||||||
$node->reload();
|
$node->reload();
|
||||||
@ -74,8 +77,8 @@ $node->command_fails_like(
|
|||||||
# Reconfigure to restrict access and require a detail.
|
# Reconfigure to restrict access and require a detail.
|
||||||
$shell_command =
|
$shell_command =
|
||||||
$PostgreSQL::Test::Utils::windows_os
|
$PostgreSQL::Test::Utils::windows_os
|
||||||
? qq{$gzip --fast > "$escaped_backup_path\\\\%d.%f.gz"}
|
? qq{"$gzip" --fast > "$escaped_backup_path\\\\%d.%f.gz"}
|
||||||
: qq{$gzip --fast > "$escaped_backup_path/%d.%f.gz"};
|
: qq{"$gzip" --fast > "$escaped_backup_path/%d.%f.gz"};
|
||||||
$node->append_conf('postgresql.conf',
|
$node->append_conf('postgresql.conf',
|
||||||
"basebackup_to_shell.command='$shell_command'");
|
"basebackup_to_shell.command='$shell_command'");
|
||||||
$node->append_conf('postgresql.conf',
|
$node->append_conf('postgresql.conf',
|
||||||
|
Loading…
Reference in New Issue
Block a user