1
0
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:
David Steele
2019-05-22 11:24:18 -04:00
parent 3da60f4b5e
commit ff9c1bed5d
2 changed files with 12 additions and 4 deletions
+8 -3
View File
@@ -89,8 +89,7 @@ infoHash(const Ini *ini)
String *key = strLstGet(keyList, keyIdx); String *key = strLstGet(keyList, keyIdx);
// Skip the backrest checksum in the file // Skip the backrest checksum in the file
if ((strEq(section, INFO_SECTION_BACKREST_STR) && !strEq(key, INFO_KEY_CHECKSUM_STR)) || if (!strEq(section, INFO_SECTION_BACKREST_STR) || !strEq(key, INFO_KEY_CHECKSUM_STR))
!strEq(section, INFO_SECTION_BACKREST_STR))
{ {
ioFilterProcessIn(hash, BUFSTRDEF("\"")); ioFilterProcessIn(hash, BUFSTRDEF("\""));
ioFilterProcessIn(hash, BUFSTR(key)); ioFilterProcessIn(hash, BUFSTR(key));
@@ -325,9 +324,15 @@ infoSave(
MEM_CONTEXT_TEMP_BEGIN() 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_VERSION_STR, jsonFromStr(STRDEF(PROJECT_VERSION)));
iniSet(ini, INFO_SECTION_BACKREST_STR, INFO_KEY_FORMAT_STR, jsonFromUInt(REPOSITORY_FORMAT)); 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))); iniSet(ini, INFO_SECTION_BACKREST_STR, INFO_KEY_CHECKSUM_STR, jsonFromStr(infoHash(ini)));
// Save info file // Save info file
+4 -1
View File
@@ -264,10 +264,13 @@ testRun(void)
// ------------------------------------------------------------------------------------------------------------------------- // -------------------------------------------------------------------------------------------------------------------------
ini = iniNew(); ini = iniNew();
iniSet(ini, strNew("section1"), strNew("key1"), strNew("value4")); 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; ini = NULL;
TEST_RESULT_VOID(infoNewLoad(storageTest, fileName, cipherTypeAes256Cbc, cipherPass, &ini), " reload info"); 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("section1"), strNew("key1"))), "value4", " check ini");
TEST_RESULT_STR(strPtr(iniGet(ini, strNew("cipher"), strNew("cipher-pass"))), "\"/badpass\"", " check cipher-pass");
} }
} }