From 98287342a2847933b3de415b7b2058e0d5b5c564 Mon Sep 17 00:00:00 2001 From: Andrew Pogrebnoy Date: Tue, 3 Sep 2024 14:45:46 +0300 Subject: [PATCH] Add Xlog init macros for frontend --- src/catalog/tde_global_space.c | 3 ++- src/include/access/pg_tde_tdemap.h | 1 - src/include/access/pg_tde_xlog_encrypt_fe.h | 29 +++++++++++++++++++++ src/include/catalog/tde_global_space.h | 1 + src/include/pg_tde_fe.h | 3 ++- 5 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 src/include/access/pg_tde_xlog_encrypt_fe.h diff --git a/src/catalog/tde_global_space.c b/src/catalog/tde_global_space.c index c56f123f..56a600ae 100644 --- a/src/catalog/tde_global_space.c +++ b/src/catalog/tde_global_space.c @@ -63,9 +63,10 @@ TDEInitGlobalKeys(const char *dir) #endif /* !FRONTEND */ { RelKeyData *ikey; - + if (dir != NULL) pg_tde_set_globalspace_dir(dir); + ikey = pg_tde_get_key_from_file(&GLOBAL_SPACE_RLOCATOR(XLOG_TDE_OID)); /* diff --git a/src/include/access/pg_tde_tdemap.h b/src/include/access/pg_tde_tdemap.h index 0a6b632d..5260e9bd 100644 --- a/src/include/access/pg_tde_tdemap.h +++ b/src/include/access/pg_tde_tdemap.h @@ -12,7 +12,6 @@ #include "access/xlog_internal.h" #include "catalog/pg_tablespace_d.h" #include "catalog/tde_principal_key.h" -#include "storage/fd.h" #include "storage/relfilelocator.h" typedef struct InternalKey diff --git a/src/include/access/pg_tde_xlog_encrypt_fe.h b/src/include/access/pg_tde_xlog_encrypt_fe.h new file mode 100644 index 00000000..bc4c6718 --- /dev/null +++ b/src/include/access/pg_tde_xlog_encrypt_fe.h @@ -0,0 +1,29 @@ +/*------------------------------------------------------------------------- + * + * pg_tde_xlog_encrypt_fe.h + * Frontened definitions for encrypted XLog storage manager + * + *------------------------------------------------------------------------- + */ + +#ifndef PG_TDE_XLOGENCRYPT_FE_H +#define PG_TDE_XLOGENCRYPT_FE_H + +#ifdef PERCONA_FORK +#include "access/pg_tde_xlog_encrypt.h" +#include "catalog/tde_global_space.h" +#include "encryption/enc_aes.h" +#include "keyring/keyring_file.h" +#include "keyring/keyring_vault.h" + +/* Frontend has to call it needs to read an encrypted XLog */ +#define TDE_XLOG_INIT(kring_dir) \ + AesInit(); \ + InstallFileKeyring(); \ + InstallVaultV2Keyring(); \ + TDEInitGlobalKeys(kring_dir); \ + TDEXLogSmgrInit() + +#endif /* PERCONA_FORK */ + +#endif /* PG_TDE_XLOGENCRYPT_FE_H */ \ No newline at end of file diff --git a/src/include/catalog/tde_global_space.h b/src/include/catalog/tde_global_space.h index 669f3aa2..42aaa0de 100644 --- a/src/include/catalog/tde_global_space.h +++ b/src/include/catalog/tde_global_space.h @@ -21,6 +21,7 @@ * We take Oids of the sql operators, so there is no overlap with the "real" * catalog objects possible. */ +#define GLOBAL_DATA_TDE_OID InvalidOid #define XLOG_TDE_OID 608 #define GLOBAL_DATA_TDE_OID InvalidOid diff --git a/src/include/pg_tde_fe.h b/src/include/pg_tde_fe.h index 029c434f..44f5c6a6 100644 --- a/src/include/pg_tde_fe.h +++ b/src/include/pg_tde_fe.h @@ -21,8 +21,9 @@ #pragma GCC diagnostic ignored "-Wunused-value" #pragma GCC diagnostic ignored "-Wunused-variable" #pragma GCC diagnostic ignored "-Wextra" + /* - * Errors handeling + * Errors handling * ---------------------------------------- */