You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-17 01:12:23 +02:00
Immediately error when a secure option (e.g. repo1-s3-key) is passed on the command line.
Since pgBackRest would not pass secure options on to sub-processes an obscure error was thrown. The new error is much clearer and provides hints about how to fix the problem. Update command documentation to omit secure options that cannot be specified on the command-line. Reported by Brad Nicholson.
This commit is contained in:
@ -700,6 +700,9 @@ sub helpCommandDocGet
|
||||
|
||||
foreach my $strOption (sort(keys(%{$$oCommandHash{&CONFIG_HELP_OPTION}})))
|
||||
{
|
||||
# Skip secure options that can't be defined on the command line
|
||||
next if ($rhConfigDefine->{$strOption}{&CFGDEF_SECURE});
|
||||
|
||||
my ($oOption, $strCategory) = helpCommandDocGetOptionFind($oConfigHash, $oOptionDefine, $strCommand, $strOption);
|
||||
|
||||
$$oCategory{$strCategory}{$strOption} = $oOption;
|
||||
|
@ -23,6 +23,14 @@
|
||||
<p>Fix <br-option>--target-action</br-option> and <br-option>--recovery-option</br-option> options being reported as invalid when restoring with <br-option>--type=immediate</br-option>.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="nicholson.brad"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Immediately error when a secure option (e.g. <br-option>repo1-s3-key</br-option>) is passed on the command line. Since <backrest/> would not pass secure options on to sub-processes an obscure error was thrown. The new error is much clearer and provides hints about how to fix the problem. Update command documentation to omit secure options that cannot be specified on the command-line.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="kokdemir.ibrahim.edib"/>
|
||||
|
@ -430,6 +430,17 @@ configParse(unsigned int argListSize, const char *argList[])
|
||||
cfgCommandName(cfgCommand()));
|
||||
}
|
||||
|
||||
// Error if this option is secure and cannot be passed on the command line
|
||||
if (parseOption->found && parseOption->source == cfgSourceParam && cfgDefOptionSecure(optionDefId))
|
||||
{
|
||||
THROW(
|
||||
OptionInvalidError,
|
||||
"option '%s' is not allowed on the command-line\n"
|
||||
"HINT: this option could expose secrets in the process list.\n"
|
||||
"HINT: specify the option in '%s' instead.",
|
||||
cfgOptionName(optionId), cfgDefOptionDefault(commandDefId, cfgDefOptConfig));
|
||||
}
|
||||
|
||||
// Error if this option does not allow multiple arguments
|
||||
if (parseOption->valueList != NULL && strLstSize(parseOption->valueList) > 1 &&
|
||||
!(cfgDefOptionType(cfgOptionDefIdFromId(optionId)) == cfgDefOptTypeHash ||
|
||||
|
@ -127,6 +127,20 @@ testRun()
|
||||
configParse(strLstSize(argList), strLstPtr(argList)), OptionRequiredError,
|
||||
"backup command requires option: stanza");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
strLstAdd(argList, strNew("--pg1-path=/path/to/db"));
|
||||
strLstAdd(argList, strNew("--stanza=db"));
|
||||
strLstAdd(argList, strNew("--repo1-type=s3"));
|
||||
strLstAdd(argList, strNew("--repo1-s3-key=xxx"));
|
||||
strLstAdd(argList, strNew(TEST_COMMAND_BACKUP));
|
||||
TEST_ERROR(
|
||||
configParse(strLstSize(argList), strLstPtr(argList)), OptionInvalidError,
|
||||
"option 'repo1-s3-key' is not allowed on the command-line\n"
|
||||
"HINT: this option could expose secrets in the process list.\n"
|
||||
"HINT: specify the option in '/etc/pgbackrest.conf' instead.");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAdd(argList, strNew(TEST_BACKREST_EXE));
|
||||
|
Reference in New Issue
Block a user