1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Fix difference in cipher type reporting missed in 8304d452.

The C code can't get the cipher type from the storage object because the C storage object does not have encryption baked in like the Perl code does.

Instead, check backup.info to see if encryption is enabled.  This will need to rethought if another cipher type is added but for now it works fine.
This commit is contained in:
David Steele
2019-01-16 22:16:50 +02:00
parent e68d1e7304
commit 7d4bbf290c
2 changed files with 16 additions and 4 deletions

View File

@ -14,6 +14,7 @@ Info Command
#include "common/memContext.h"
#include "common/type/json.h"
#include "config/config.h"
#include "crypto/crypto.h"
#include "info/info.h"
#include "info/infoArchive.h"
#include "info/infoBackup.h"
@ -51,6 +52,7 @@ STRING_STATIC(KEY_START_STR, "start");
STRING_STATIC(KEY_STOP_STR, "stop");
STRING_STATIC(STANZA_KEY_BACKUP_STR, "backup");
STRING_STATIC(STANZA_KEY_CIPHER_STR, "cipher");
STRING_STATIC(STANZA_VALUE_CIPHER_NONE_STR, "none");
STRING_STATIC(STANZA_KEY_NAME_STR, "name");
STRING_STATIC(STANZA_KEY_STATUS_STR, "status");
STRING_STATIC(STANZA_KEY_DB_STR, "db");
@ -330,11 +332,18 @@ stanzaInfoList(const String *stanza, StringList *stanzaList)
// Set the stanza name and cipher
kvPut(varKv(stanzaInfo), varNewStr(STANZA_KEY_NAME_STR), varNewStr(stanzaListName));
kvPut(varKv(stanzaInfo), varNewStr(STANZA_KEY_CIPHER_STR), varNewStr(cfgOptionStr(cfgOptRepoCipherType)));
kvPut(varKv(stanzaInfo), varNewStr(STANZA_KEY_CIPHER_STR), varNewStr(STANZA_VALUE_CIPHER_NONE_STR));
// If the backup.info file exists, get the database history information (newest to oldest) and corresponding archive
if (info != NULL)
{
// Determine if encryption is enabled by checking for a cipher passphrase. This is not ideal since it does not tell us
// what type of encryption is in use, but to figure that out we need a way to query the (possibly) remote repo to find
// out. No such mechanism exists so this will have to do for now. Probably the easiest thing to do is store the
// cipher type in the info file.
if (infoPgCipherPass(infoBackupPg(info)) != NULL)
kvPut(varKv(stanzaInfo), varNewStr(STANZA_KEY_CIPHER_STR), varNewStr(CIPHER_TYPE_AES_256_CBC_STR));
for (unsigned int pgIdx = infoPgDataTotal(infoBackupPg(info)) - 1; (int)pgIdx >= 0; pgIdx--)
{
InfoPgData pgData = infoPgData(infoBackupPg(info), pgIdx);

View File

@ -72,10 +72,13 @@ testRun(void)
String *content = strNew
(
"[backrest]\n"
"backrest-checksum=\"51774ffab293c5cfb07511d7d2e101e92416f4ed\"\n"
"backrest-checksum=\"80798255547bafa3eee805ab0fccaa1da03cab0e\"\n"
"backrest-format=5\n"
"backrest-version=\"2.04\"\n"
"\n"
"[cipher]\n"
"cipher-pass=12345\n"
"\n"
"[db]\n"
"db-catalog-version=201409291\n"
"db-control-version=942\n"
@ -145,7 +148,7 @@ testRun(void)
" }\n"
" ],\n"
" \"backup\" : [],\n"
" \"cipher\" : \"none\",\n"
" \"cipher\" : \"aes-256-cbc\",\n"
" \"db\" : [\n"
" {\n"
" \"id\" : 1,\n"
@ -170,7 +173,7 @@ testRun(void)
TEST_RESULT_STR(strPtr(infoRender()),
"stanza: stanza1\n"
" status: error (no valid backups)\n"
" cipher: none\n"
" cipher: aes-256-cbc\n"
"\n"
" db (current)\n"
" wal archive min/max (9.4-3): none present\n",