1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-03-03 14:52:21 +02:00

Pass cipher type directly to backupFileProtocol().

Cipher type was inferred from the presence of cipherSubPass rather than being passed explicitly in order to maintain compatibility with Perl backupFile().

Now that Perl is gone it makes sense to pass it explicitly, as we do elsewhere.
This commit is contained in:
David Steele 2021-03-12 15:19:32 -05:00
parent e07040c2e4
commit ec347847e5
3 changed files with 9 additions and 1 deletions

View File

@ -1436,6 +1436,7 @@ typedef struct BackupJobData
{
const String *const backupLabel; // Backup label (defines the backup path)
const bool backupStandby; // Backup from standby
const CipherType cipherType; // Cipher type
const String *const cipherSubPass; // Passphrase used to encrypt files in the backup
const CompressType compressType; // Backup compression type
const int compressLevel; // Compress level if backup is compressed
@ -1493,6 +1494,7 @@ static ProtocolParallelJob *backupJobCallback(void *data, unsigned int clientIdx
protocolCommandParamAdd(command, VARINT(jobData->compressLevel));
protocolCommandParamAdd(command, VARSTR(jobData->backupLabel));
protocolCommandParamAdd(command, VARBOOL(jobData->delta));
protocolCommandParamAdd(command, VARUINT(jobData->cipherType));
protocolCommandParamAdd(command, VARSTR(jobData->cipherSubPass));
// Remove job from the queue
@ -1583,6 +1585,7 @@ backupProcess(BackupData *backupData, Manifest *manifest, const String *lsnStart
.backupStandby = backupStandby,
.compressType = compressTypeEnum(cfgOptionStr(cfgOptCompressType)),
.compressLevel = cfgOptionInt(cfgOptCompressLevel),
.cipherType = cipherType(cfgOptionStr(cfgOptRepoCipherType)),
.cipherSubPass = manifestCipherSubPass(manifest),
.delta = cfgOptionBool(cfgOptDelta),
.lsnStart = cfgOptionBool(cfgOptOnline) ? pgLsnFromStr(lsnStart) : 0xFFFFFFFFFFFFFFFF,

View File

@ -43,7 +43,7 @@ backupProtocol(const String *command, const VariantList *paramList, ProtocolServ
varUInt64(varLstGet(paramList, 6)), varStr(varLstGet(paramList, 7)), varBool(varLstGet(paramList, 8)),
(CompressType)varUIntForce(varLstGet(paramList, 9)), varIntForce(varLstGet(paramList, 10)),
varStr(varLstGet(paramList, 11)), varBool(varLstGet(paramList, 12)),
varStr(varLstGet(paramList, 13)) == NULL ? cipherTypeNone : cipherTypeAes256Cbc, varStr(varLstGet(paramList, 13)));
(CipherType)varUIntForce(varLstGet(paramList, 13)), varStr(varLstGet(paramList, 14)));
// Return backup result
VariantList *resultList = varLstNew();

View File

@ -510,6 +510,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(0)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(false)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeNone)); // cipherType
varLstAdd(paramList, NULL); // cipherSubPass
TEST_RESULT_BOOL(
@ -602,6 +603,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(1)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(false)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeNone)); // cipherType
varLstAdd(paramList, NULL); // cipherSubPass
TEST_RESULT_BOOL(
@ -645,6 +647,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(1)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(true)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeNone)); // cipherType
varLstAdd(paramList, NULL); // cipherSubPass
TEST_RESULT_BOOL(
@ -787,6 +790,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(3)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(false)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeNone)); // cipherType
varLstAdd(paramList, NULL); // cipherSubPass
TEST_RESULT_BOOL(
@ -906,6 +910,7 @@ testRun(void)
varLstAdd(paramList, varNewInt(0)); // repoFileCompressLevel
varLstAdd(paramList, varNewStr(backupLabel)); // backupLabel
varLstAdd(paramList, varNewBool(false)); // delta
varLstAdd(paramList, varNewUInt(cipherTypeAes256Cbc)); // cipherType
varLstAdd(paramList, varNewStrZ("12345678")); // cipherPass
TEST_RESULT_BOOL(