You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-05-22 10:15:16 +02:00
Save cipher-pass key/value missed in f492f057.
This value is required when encryption is enabled. In passing simplify the expression used to skip the checksum when calculating the checksum.
This commit is contained in:
+8
-3
@@ -89,8 +89,7 @@ infoHash(const Ini *ini)
|
||||
String *key = strLstGet(keyList, keyIdx);
|
||||
|
||||
// Skip the backrest checksum in the file
|
||||
if ((strEq(section, INFO_SECTION_BACKREST_STR) && !strEq(key, INFO_KEY_CHECKSUM_STR)) ||
|
||||
!strEq(section, INFO_SECTION_BACKREST_STR))
|
||||
if (!strEq(section, INFO_SECTION_BACKREST_STR) || !strEq(key, INFO_KEY_CHECKSUM_STR))
|
||||
{
|
||||
ioFilterProcessIn(hash, BUFSTRDEF("\""));
|
||||
ioFilterProcessIn(hash, BUFSTR(key));
|
||||
@@ -325,9 +324,15 @@ infoSave(
|
||||
|
||||
MEM_CONTEXT_TEMP_BEGIN()
|
||||
{
|
||||
// Add common info values
|
||||
// Add version and format
|
||||
iniSet(ini, INFO_SECTION_BACKREST_STR, INFO_KEY_VERSION_STR, jsonFromStr(STRDEF(PROJECT_VERSION)));
|
||||
iniSet(ini, INFO_SECTION_BACKREST_STR, INFO_KEY_FORMAT_STR, jsonFromUInt(REPOSITORY_FORMAT));
|
||||
|
||||
// Add cipher passphrase if defined
|
||||
if (this->cipherPass != NULL)
|
||||
iniSet(ini, INFO_SECTION_CIPHER_STR, INFO_KEY_CIPHER_PASS_STR, jsonFromStr(this->cipherPass));
|
||||
|
||||
// Add checksum (this must be set after all other values or it will not be valid)
|
||||
iniSet(ini, INFO_SECTION_BACKREST_STR, INFO_KEY_CHECKSUM_STR, jsonFromStr(infoHash(ini)));
|
||||
|
||||
// Save info file
|
||||
|
||||
@@ -264,10 +264,13 @@ testRun(void)
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
ini = iniNew();
|
||||
iniSet(ini, strNew("section1"), strNew("key1"), strNew("value4"));
|
||||
TEST_RESULT_VOID(infoSave(infoNew(), ini, storageTest, fileName, cipherTypeAes256Cbc, cipherPass), "save encrypted info");
|
||||
Info *info = infoNew();
|
||||
info->cipherPass = strNew("/badpass");
|
||||
TEST_RESULT_VOID(infoSave(info, ini, storageTest, fileName, cipherTypeAes256Cbc, cipherPass), "save encrypted info");
|
||||
|
||||
ini = NULL;
|
||||
TEST_RESULT_VOID(infoNewLoad(storageTest, fileName, cipherTypeAes256Cbc, cipherPass, &ini), " reload info");
|
||||
TEST_RESULT_STR(strPtr(iniGet(ini, strNew("section1"), strNew("key1"))), "value4", " check ini");
|
||||
TEST_RESULT_STR(strPtr(iniGet(ini, strNew("cipher"), strNew("cipher-pass"))), "\"/badpass\"", " check cipher-pass");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user