You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-09-16 09:06:18 +02:00
Fix missing missing URI encoding in S3 driver.
File names with uncommon characters (e.g. @) caused authentication failures due to S3 encoding them correctly while the S3 driver did not. Reported by Dan Farrell.
This commit is contained in:
@@ -15,6 +15,14 @@
|
||||
<release date="XXXX-XX-XX" version="2.06dev" title="UNDER DEVELOPMENT">
|
||||
<release-core-list>
|
||||
<release-bug-list>
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="dan.farrell"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Fix missing missing URI encoding in S3 driver.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<p>Fix incorrectly reported error return in <id>info</id> logging. A return code of 1 from the <cmd>archive-get</cmd> was being logged as an error message at <id>info</id> level but otherwise worked correctly.</p>
|
||||
</release-item>
|
||||
@@ -5293,6 +5301,11 @@
|
||||
<contributor-id type="github">cmwshang</contributor-id>
|
||||
</contributor>
|
||||
|
||||
<contributor id="dan.farrell">
|
||||
<contributor-name-display>Dan Farrell</contributor-name-display>
|
||||
<contributor-id type="github">farrellit</contributor-id>
|
||||
</contributor>
|
||||
|
||||
<contributor id="david.youatt">
|
||||
<contributor-name-display>David Youatt</contributor-name-display>
|
||||
<contributor-id type="github">youattd</contributor-id>
|
||||
|
@@ -128,7 +128,7 @@ sub new
|
||||
my $strQuery = httpQuery($hQuery);
|
||||
|
||||
# Construct the request headers
|
||||
$self->{strRequestHeader} = "${strVerb} ${strUri}?${strQuery} HTTP/1.1" . "\r\n";
|
||||
$self->{strRequestHeader} = "${strVerb} " . httpUriEncode($strUri, true) . "?${strQuery} HTTP/1.1" . "\r\n";
|
||||
|
||||
foreach my $strHeader (sort(keys(%{$hRequestHeader})))
|
||||
{
|
||||
|
@@ -68,6 +68,7 @@ push @EXPORT, qw(httpQuery);
|
||||
sub httpUriEncode
|
||||
{
|
||||
my $strString = shift;
|
||||
my $bPath = shift;
|
||||
|
||||
# Only encode if source string is defined
|
||||
my $strEncodedString;
|
||||
@@ -81,7 +82,7 @@ sub httpUriEncode
|
||||
|
||||
# These characters are reproduced verbatim
|
||||
if (($cChar ge 'A' && $cChar le 'Z') || ($cChar ge 'a' && $cChar le 'z') || ($cChar ge '0' && $cChar le '9') ||
|
||||
$cChar eq '_' || $cChar eq '-' || $cChar eq '~' || $cChar eq '.')
|
||||
$cChar eq '_' || $cChar eq '-' || $cChar eq '~' || $cChar eq '.' || ($bPath && $cChar eq '/'))
|
||||
{
|
||||
$strEncodedString .= $cChar;
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ use Exporter qw(import);
|
||||
our @EXPORT = qw();
|
||||
use POSIX qw(strftime);
|
||||
|
||||
use pgBackRest::Common::Http::Common;
|
||||
use pgBackRest::Common::Log;
|
||||
use pgBackRest::LibC qw(:crypto);
|
||||
|
||||
@@ -257,7 +258,8 @@ sub s3AuthorizationHeader
|
||||
}
|
||||
|
||||
# Create authorization string
|
||||
my ($strCanonicalRequest, $strSignedHeaders) = s3CanonicalRequest($strVerb, $strUri, $strQuery, $hHeader, $strPayloadHash);
|
||||
my ($strCanonicalRequest, $strSignedHeaders) = s3CanonicalRequest(
|
||||
$strVerb, httpUriEncode($strUri, true), $strQuery, $hHeader, $strPayloadHash);
|
||||
my $strStringToSign = s3StringToSign($strDateTime, $strRegion, cryptoHashOne('sha256', $strCanonicalRequest));
|
||||
|
||||
$hHeader->{&S3_HEADER_AUTHORIZATION} =
|
||||
|
@@ -5184,7 +5184,7 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"\n\n"
|
||||
"my $strQuery = httpQuery($hQuery);\n"
|
||||
"\n\n"
|
||||
"$self->{strRequestHeader} = \"${strVerb} ${strUri}?${strQuery} HTTP/1.1\" . \"\\r\\n\";\n"
|
||||
"$self->{strRequestHeader} = \"${strVerb} \" . httpUriEncode($strUri, true) . \"?${strQuery} HTTP/1.1\" . \"\\r\\n\";\n"
|
||||
"\n"
|
||||
"foreach my $strHeader (sort(keys(%{$hRequestHeader})))\n"
|
||||
"{\n"
|
||||
@@ -5437,6 +5437,7 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"sub httpUriEncode\n"
|
||||
"{\n"
|
||||
"my $strString = shift;\n"
|
||||
"my $bPath = shift;\n"
|
||||
"\n\n"
|
||||
"my $strEncodedString;\n"
|
||||
"\n"
|
||||
@@ -5448,7 +5449,7 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"my $cChar = substr($strString, $iIndex, 1);\n"
|
||||
"\n\n"
|
||||
"if (($cChar ge 'A' && $cChar le 'Z') || ($cChar ge 'a' && $cChar le 'z') || ($cChar ge '0' && $cChar le '9') ||\n"
|
||||
"$cChar eq '_' || $cChar eq '-' || $cChar eq '~' || $cChar eq '.')\n"
|
||||
"$cChar eq '_' || $cChar eq '-' || $cChar eq '~' || $cChar eq '.' || ($bPath && $cChar eq '/'))\n"
|
||||
"{\n"
|
||||
"$strEncodedString .= $cChar;\n"
|
||||
"}\n"
|
||||
@@ -20132,6 +20133,7 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"our @EXPORT = qw();\n"
|
||||
"use POSIX qw(strftime);\n"
|
||||
"\n"
|
||||
"use pgBackRest::Common::Http::Common;\n"
|
||||
"use pgBackRest::Common::Log;\n"
|
||||
"use pgBackRest::LibC qw(:crypto);\n"
|
||||
"\n\n\n\n"
|
||||
@@ -20343,7 +20345,8 @@ static const EmbeddedModule embeddedModule[] =
|
||||
"$hHeader->{&S3_HEADER_TOKEN} = $strSecurityToken;\n"
|
||||
"}\n"
|
||||
"\n\n"
|
||||
"my ($strCanonicalRequest, $strSignedHeaders) = s3CanonicalRequest($strVerb, $strUri, $strQuery, $hHeader, $strPayloadHash);\n"
|
||||
"my ($strCanonicalRequest, $strSignedHeaders) = s3CanonicalRequest(\n"
|
||||
"$strVerb, httpUriEncode($strUri, true), $strQuery, $hHeader, $strPayloadHash);\n"
|
||||
"my $strStringToSign = s3StringToSign($strDateTime, $strRegion, cryptoHashOne('sha256', $strCanonicalRequest));\n"
|
||||
"\n"
|
||||
"$hHeader->{&S3_HEADER_AUTHORIZATION} =\n"
|
||||
|
Reference in New Issue
Block a user