write config lock

This commit is contained in:
dmchen 2024-04-07 02:24:41 +00:00
parent d06bfd9cea
commit c43e937538
3 changed files with 34 additions and 30 deletions

View File

@ -367,6 +367,10 @@ int mainWindows(int argc, char **argv) {
} }
if(global.generateCode) { if(global.generateCode) {
if(dmCheckRunning(tsDataDir) == NULL) {
dError("failed to generate encrypt code since taosd is running, please stop it first");
return -1;
}
int ret = updateEncryptKey(global.encryptKey); int ret = updateEncryptKey(global.encryptKey);
taosCloseLog(); taosCloseLog();
taosCleanupArgs(); taosCleanupArgs();

View File

@ -148,7 +148,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
} }
#else #else
pCfg->tsdbCfg.cryptAlgorithm = 0; pCfg->tsdbCfg.encryptAlgorithm = 0;
#endif #endif
pCfg->walCfg.vgId = pCreate->vgId; pCfg->walCfg.vgId = pCreate->vgId;
@ -164,7 +164,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
} }
#else #else
pCfg->walCfg.cryptAlgorithm = 0; pCfg->walCfg.encryptAlgorithm = 0;
#endif #endif
#if defined(TD_ENTERPRISE) #if defined(TD_ENTERPRISE)
@ -173,7 +173,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
} }
#else #else
pCfg->tdbEncryptKey = 0; pCfg->tdbEncryptAlgorithm = 0;
#endif #endif
pCfg->sttTrigger = pCreate->sstTrigger; pCfg->sttTrigger = pCreate->sstTrigger;

View File

@ -246,15 +246,15 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
tjsonGetNumberValue(pJson, "tsdb.encryptAlgorithm", pCfg->tsdbCfg.encryptAlgorithm, code); tjsonGetNumberValue(pJson, "tsdb.encryptAlgorithm", pCfg->tsdbCfg.encryptAlgorithm, code);
if (code < 0) return -1; if (code < 0) return -1;
#if defined(TD_ENTERPRISE) #if defined(TD_ENTERPRISE)
// if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){ if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){
// if(tsEncryptKey[0] == 0){ if(tsEncryptKey[0] == 0){
// terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
// return -1; return -1;
// } }
// else{ else{
// strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
// } }
// } }
#endif #endif
tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId, code); tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId, code);
if (code < 0) return -1; if (code < 0) return -1;
@ -273,28 +273,28 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
tjsonGetNumberValue(pJson, "wal.encryptAlgorithm", pCfg->walCfg.encryptAlgorithm, code); tjsonGetNumberValue(pJson, "wal.encryptAlgorithm", pCfg->walCfg.encryptAlgorithm, code);
if (code < 0) return -1; if (code < 0) return -1;
#if defined(TD_ENTERPRISE) #if defined(TD_ENTERPRISE)
// if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){ if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){
// if(tsEncryptKey[0] == 0){ if(tsEncryptKey[0] == 0){
// terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
// return -1; return -1;
// } }
// else{ else{
// strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
// } }
// } }
#endif #endif
tjsonGetNumberValue(pJson, "tdbEncryptAlgorithm", pCfg->tdbEncryptAlgorithm, code); tjsonGetNumberValue(pJson, "tdbEncryptAlgorithm", pCfg->tdbEncryptAlgorithm, code);
if (code < 0) return -1; if (code < 0) return -1;
#if defined(TD_ENTERPRISE) #if defined(TD_ENTERPRISE)
// if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){ if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){
// if(tsEncryptKey[0] == 0){ if(tsEncryptKey[0] == 0){
// terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
// return -1; return -1;
// } }
// else{ else{
// strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
// } }
// } }
#endif #endif
tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sttTrigger, code); tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sttTrigger, code);
if (code < 0) pCfg->sttTrigger = TSDB_DEFAULT_SST_TRIGGER; if (code < 0) pCfg->sttTrigger = TSDB_DEFAULT_SST_TRIGGER;