pgbackrest.git / summary / log / commit / refs
commit 7d4bbf290cf33de06fca9854f21ec9690cfd51bb
Author: David Steele <david@pgmasters.net>
Date: Wed Jan 16 20:16:50 2019 +0000
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.
src/command/info/info.c | 11 ++++++++++-
test/src/module/command/infoTest.c | 9 ++++++---
2 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/command/info/info.c b/src/command/info/info.c
index 51536a319..dcf462083 100644
--- a/src/command/info/info.c
+++ b/src/command/info/info.c
@@ -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);
diff --git a/test/src/module/command/infoTest.c b/test/src/module/command/infoTest.c
index 49b6831bf..0fe176301 100644
--- a/test/src/module/command/infoTest.c
+++ b/test/src/module/command/infoTest.c
@@ -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",
[parent: e68d1e730423]