Skip to content

Commit a91242b

Browse files
committed
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 027fa0f
1 parent 0df4eb3 commit a91242b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

contrib/basebackup_to_shell/t/001_basic.pl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
plan skip_all => 'gzip not available';
1717
}
1818

19+
# to ensure path can be embedded in postgresql.conf
20+
$gzip =~ s{\\}{/}g if ($PostgreSQL::Test::Utils::windows_os);
21+
1922
my $node = PostgreSQL::Test::Cluster->new('primary');
2023

2124
# Make sure pg_hba.conf is set up to allow connections from backupuser.
@@ -53,8 +56,8 @@
5356
if ($PostgreSQL::Test::Utils::windows_os);
5457
my $shell_command =
5558
$PostgreSQL::Test::Utils::windows_os
56-
? qq{$gzip --fast > "$escaped_backup_path\\\\%f.gz"}
57-
: qq{$gzip --fast > "$escaped_backup_path/%f.gz"};
59+
? qq{"$gzip" --fast > "$escaped_backup_path\\\\%f.gz"}
60+
: qq{"$gzip" --fast > "$escaped_backup_path/%f.gz"};
5861
$node->append_conf('postgresql.conf',
5962
"basebackup_to_shell.command='$shell_command'");
6063
$node->reload();
@@ -74,8 +77,8 @@
7477
# Reconfigure to restrict access and require a detail.
7578
$shell_command =
7679
$PostgreSQL::Test::Utils::windows_os
77-
? qq{$gzip --fast > "$escaped_backup_path\\\\%d.%f.gz"}
78-
: qq{$gzip --fast > "$escaped_backup_path/%d.%f.gz"};
80+
? qq{"$gzip" --fast > "$escaped_backup_path\\\\%d.%f.gz"}
81+
: qq{"$gzip" --fast > "$escaped_backup_path/%d.%f.gz"};
7982
$node->append_conf('postgresql.conf',
8083
"basebackup_to_shell.command='$shell_command'");
8184
$node->append_conf('postgresql.conf',

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy