pg.ddx.io pgbackrest/pgbackrest GitHub issues and pull requests
help / color / mirror / Atom feedFrom: pgstef (@pgstef) <noreply+pgstef@github.com>
To: pgbackrest/pgbackrest <noreply+pgbackrest-pgbackrest@github.com>
Subject: Re: [pgbackrest/pgbackrest] PR #2917 (approved): Add an info helper to load, cache, and save info files.
Date: Fri, 13 Nov 2026 11:07:43 +0000
Message-ID: <gh-pgbackrest-pgbackrest-2917-r5889891448@github.com> (raw)
In-Reply-To: <gh-pgbackrest-pgbackrest-2917@github.com>
References: <gh-pgbackrest-pgbackrest-2917@github.com>
> Fixed in [9c999ee](https://github.com/pgbackrest/pgbackrest/commit/9c999eee26aa6a41ffece0044102be21f66ccba7).
Thanks, the PR looks good to me now!
One small nitpick: I don't think the initialization-order fix in the save helpers has a dedicated regression test yet. Would it be worth adding one along the lines of the diff below?
```c
inline patch 1: test/define.yaml, test/src/module/info/helperTest.c (+89/-1 lines) download inline-1.patch
diff --git a/test/define.yaml b/test/define.yaml
index f8d45cb80..379462586 100644
--- a/test/define.yaml
+++ b/test/define.yaml
@@ -726,7 +726,7 @@ unit:
# --------------------------------------------------------------------------------------------------------------------------------
- name: info/helper
- total: 1
+ total: 2
harness:
name: infoHelper
shim:
diff --git a/test/src/module/info/helperTest.c b/test/src/module/info/helperTest.c
index ad2bd7d06..0b7aa08b5 100644
--- a/test/src/module/info/helperTest.c
+++ b/test/src/module/info/helperTest.c
@@ -1,13 +1,24 @@
/***********************************************************************************************************************************
Test Info Helper
***********************************************************************************************************************************/
+#include "common/crypto/cipherBlock.h"
+#include "common/crypto/hash.h"
#include "common/format/format.h"
+#include "common/io/filter/sink.h"
+#include "common/io/filter/size.h"
+#include "config/protocol.h"
+#include "info/helper.intern.h"
+#include "protocol/helper.h"
+#include "storage/remote/protocol.h"
#include "storage/helper.h"
+#include "storage/posix/storage.h"
#include "harness/config.h"
#include "harness/info.h"
#include "harness/infoHelper.h"
#include "harness/postgres.h"
+#include "harness/protocol.h"
+#include "harness/storage.h"
/***********************************************************************************************************************************
Test Run
@@ -163,5 +174,82 @@ testRun(void)
TEST_RESULT_STR_Z(infoArchiveId(infoArchiveRepoIdx(1)), "14-1", "archive info loaded from file");
}
+ // *****************************************************************************************************************************
+ if (testBegin("infoArchiveRepoIdxSave() as first repo access encrypts with cipher configured only on the repo host"))
+ {
+ const Storage *const storageTest = storagePosixNewP(TEST_PATH_STR, .write = true);
+
+ static const ProtocolServerHandler testRemoteHandlerList[] =
+ {
+ PROTOCOL_SERVER_HANDLER_OPTION_LIST
+ PROTOCOL_SERVER_HANDLER_STORAGE_REMOTE_LIST
+ };
+
+ hrnProtocolRemoteShimInstall(LSTDEF(testRemoteHandlerList));
+
+ static const StorageRemoteFilterHandler storageRemoteFilterHandlerList[] =
+ {
+ {.type = CIPHER_BLOCK_FILTER_TYPE, .handlerParam = cipherBlockNewPack},
+ {.type = CRYPTO_HASH_FILTER_TYPE, .handlerParam = cryptoHashNewPack},
+ {.type = SINK_FILTER_TYPE, .handlerNoParam = ioSinkNew},
+ {.type = SIZE_FILTER_TYPE, .handlerNoParam = ioSizeNew},
+ };
+
+ storageRemoteFilterHandlerSet(LSTDEF(storageRemoteFilterHandlerList));
+
+ hrnInfoHelperStatementClearSet(false);
+
+ HRN_STORAGE_PUT_Z(
+ storageTest, "repo-host.conf", "[global]\nrepo1-cipher-type=aes-256-cbc\nrepo1-cipher-pass=remotepass\n");
+
+ StringList *argList = strLstNew();
+ hrnCfgArgRawZ(argList, cfgOptStanza, "db");
+ hrnCfgArgRawZ(argList, cfgOptProtocolTimeout, "20");
+ hrnCfgArgKeyRawZ(argList, cfgOptPgPath, 1, TEST_PATH "/pg");
+ hrnCfgArgKeyRawZ(argList, cfgOptRepoHost, 1, "localhost");
+ hrnCfgArgKeyRawZ(argList, cfgOptRepoHostUser, 1, TEST_USER);
+ hrnCfgArgKeyRawZ(argList, cfgOptRepoHostConfig, 1, TEST_PATH "/repo-host.conf");
+ hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 1, TEST_PATH "/repo-enc");
+ HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
+
+ TEST_RESULT_UINT(cfgOptionIdxStrId(cfgOptRepoCipherType, 0), cipherTypeNone, "cipher type not configured locally");
+
+ TEST_RESULT_VOID(
+ infoArchiveRepoIdxSet(0, infoArchiveNew(PG_VERSION_14, 6569239123849665679, REPOSITORY_FORMAT_5, cipherSpecMapNew())),
+ "cache archive info");
+ TEST_RESULT_VOID(infoArchiveRepoIdxSave(0), "save archive info as the first repo access");
+
+ TEST_RESULT_UINT(cfgOptionIdxStrId(cfgOptRepoCipherType, 0), cipherTypeAes256Cbc, "cipher type pulled from repo host");
+ TEST_RESULT_UINT(
+ cipherSpecType(cfgCipherSpecMainIdx(0)), cipherTypeAes256Cbc, "cipher spec resolved after remote set cipher options");
+
+ const String *const content = strNewBuf(
+ storageGetP(storageNewReadP(storageTest, STRDEF("repo-enc/archive/db/archive.info"))));
+
+ TEST_RESULT_BOOL(strBeginsWithZ(content, "[backrest]"), false, "archive.info written encrypted");
+
+ // -------------------------------------------------------------------------------------------------------------------------
+ TEST_TITLE("control: storage obtained first gives an encrypted archive.info");
+
+ protocolFree();
+ HRN_STORAGE_PATH_REMOVE(storageTest, "repo-enc", .recurse = true);
+ HRN_CFG_LOAD(cfgCmdStanzaCreate, argList);
+
+ TEST_RESULT_VOID(storageRepoIdxWrite(0), "get repo storage first");
+ TEST_RESULT_VOID(
+ infoArchiveRepoIdxSet(0, infoArchiveNew(PG_VERSION_14, 6569239123849665679, REPOSITORY_FORMAT_5, cipherSpecMapNew())),
+ "cache archive info");
+ TEST_RESULT_VOID(infoArchiveRepoIdxSave(0), "save archive info");
+ TEST_RESULT_UINT(cipherSpecType(cfgCipherSpecMainIdx(0)), cipherTypeAes256Cbc, "main cipher spec is aes");
+
+ TEST_RESULT_BOOL(
+ strBeginsWithZ(
+ strNewBuf(storageGetP(storageNewReadP(storageTest, STRDEF("repo-enc/archive/db/archive.info")))), "[backrest]"),
+ false, "archive.info encrypted");
+
+ protocolFree();
+ hrnProtocolRemoteShimUninstall();
+ }
+
FUNCTION_HARNESS_RETURN_VOID();
}
```
view thread (13+ messages) latest in thread
Message-ID: <gh-pgbackrest-pgbackrest-2917-r5889891448@github.com>
Permalink: ../gh-pgbackrest-pgbackrest-2917-r5889891448@github.com/
· ·
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox