1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-12 10:04:14 +02:00

Add error message when current user uid/gid does not map to a name.

This condition resulted in a nasty stack trace dump when the undefined value was used later on.

Reported by Camilo Aguilar.
This commit is contained in:
David Steele 2018-12-07 07:41:26 -05:00
parent ac84ffb901
commit e6abdfb5b8
3 changed files with 28 additions and 0 deletions

View File

@ -31,6 +31,14 @@
<p>Correct <br-option>archive-get-queue-max</br-option> to be <id>size</id> type.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-ideator id="camilo.aguilar"/>
</release-item-contributor-list>
<p>Add error message when current user <id>uid</id>/<id>gid</id> does not map to a name.</p>
</release-item>
<release-item>
<p>Error when <br-option>--target-action=shutdown</br-option> specified for <postgres/> &lt; 9.5.</p>
</release-item>

View File

@ -101,6 +101,11 @@ sub manifestOwnershipCheck
else
{
$oOwnerTypeHash{&MANIFEST_SUBKEY_USER} = getpwuid($<);
if (!defined($oOwnerTypeHash{&MANIFEST_SUBKEY_USER}))
{
confess &log(ERROR_USER_MISSING, 'current user uid does not map to a name');
}
}
if ($oManifest->test(MANIFEST_SECTION_TARGET_PATH, MANIFEST_TARGET_PGDATA, MANIFEST_SUBKEY_GROUP) &&
@ -112,6 +117,11 @@ sub manifestOwnershipCheck
else
{
$oOwnerTypeHash{&MANIFEST_SUBKEY_GROUP} = getgrgid($();
if (!defined($oOwnerTypeHash{&MANIFEST_SUBKEY_GROUP}))
{
confess &log(ERROR_GROUP_MISSING, 'current user gid does not map to a name');
}
}
# Loop through owner types (user, group)

View File

@ -15736,6 +15736,11 @@ static const EmbeddedModule embeddedModule[] =
"else\n"
"{\n"
"$oOwnerTypeHash{&MANIFEST_SUBKEY_USER} = getpwuid($<);\n"
"\n"
"if (!defined($oOwnerTypeHash{&MANIFEST_SUBKEY_USER}))\n"
"{\n"
"confess &log(ERROR_USER_MISSING, 'current user uid does not map to a name');\n"
"}\n"
"}\n"
"\n"
"if ($oManifest->test(MANIFEST_SECTION_TARGET_PATH, MANIFEST_TARGET_PGDATA, MANIFEST_SUBKEY_GROUP) &&\n"
@ -15747,6 +15752,11 @@ static const EmbeddedModule embeddedModule[] =
"else\n"
"{\n"
"$oOwnerTypeHash{&MANIFEST_SUBKEY_GROUP} = getgrgid($();\n"
"\n"
"if (!defined($oOwnerTypeHash{&MANIFEST_SUBKEY_GROUP}))\n"
"{\n"
"confess &log(ERROR_GROUP_MISSING, 'current user gid does not map to a name');\n"
"}\n"
"}\n"
"\n\n"
"foreach my $strOwnerType (sort (keys %oOwnerTypeHash))\n"