diff --git a/source/dnode/mgmt/exe/dmMain.c b/source/dnode/mgmt/exe/dmMain.c index f8ca992b22..69ff35ef7c 100644 --- a/source/dnode/mgmt/exe/dmMain.c +++ b/source/dnode/mgmt/exe/dmMain.c @@ -367,6 +367,10 @@ int mainWindows(int argc, char **argv) { } 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); taosCloseLog(); taosCleanupArgs(); diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index 518735e01f..858cf23309 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -148,7 +148,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); } #else - pCfg->tsdbCfg.cryptAlgorithm = 0; + pCfg->tsdbCfg.encryptAlgorithm = 0; #endif pCfg->walCfg.vgId = pCreate->vgId; @@ -164,7 +164,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); } #else - pCfg->walCfg.cryptAlgorithm = 0; + pCfg->walCfg.encryptAlgorithm = 0; #endif #if defined(TD_ENTERPRISE) @@ -173,7 +173,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) { strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); } #else - pCfg->tdbEncryptKey = 0; + pCfg->tdbEncryptAlgorithm = 0; #endif pCfg->sttTrigger = pCreate->sstTrigger; diff --git a/source/dnode/vnode/src/vnd/vnodeCfg.c b/source/dnode/vnode/src/vnd/vnodeCfg.c index f4e0713ebf..a0da430c6a 100644 --- a/source/dnode/vnode/src/vnd/vnodeCfg.c +++ b/source/dnode/vnode/src/vnd/vnodeCfg.c @@ -246,15 +246,15 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { tjsonGetNumberValue(pJson, "tsdb.encryptAlgorithm", pCfg->tsdbCfg.encryptAlgorithm, code); if (code < 0) return -1; #if defined(TD_ENTERPRISE) - // if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){ - // if(tsEncryptKey[0] == 0){ - // terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; - // return -1; - // } - // else{ - // strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); - // } - // } + if(pCfg->tsdbCfg.encryptAlgorithm == DND_CA_SM4){ + if(tsEncryptKey[0] == 0){ + terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; + return -1; + } + else{ + strncpy(pCfg->tsdbCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); + } + } #endif tjsonGetNumberValue(pJson, "wal.vgId", pCfg->walCfg.vgId, code); if (code < 0) return -1; @@ -273,28 +273,28 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) { tjsonGetNumberValue(pJson, "wal.encryptAlgorithm", pCfg->walCfg.encryptAlgorithm, code); if (code < 0) return -1; #if defined(TD_ENTERPRISE) - // if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){ - // if(tsEncryptKey[0] == 0){ - // terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; - // return -1; - // } - // else{ - // strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); - // } - // } + if(pCfg->walCfg.encryptAlgorithm == DND_CA_SM4){ + if(tsEncryptKey[0] == 0){ + terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; + return -1; + } + else{ + strncpy(pCfg->walCfg.encryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); + } + } #endif tjsonGetNumberValue(pJson, "tdbEncryptAlgorithm", pCfg->tdbEncryptAlgorithm, code); if (code < 0) return -1; #if defined(TD_ENTERPRISE) - // if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){ - // if(tsEncryptKey[0] == 0){ - // terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; - // return -1; - // } - // else{ - // strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); - // } - // } + if(pCfg->tdbEncryptAlgorithm == DND_CA_SM4){ + if(tsEncryptKey[0] == 0){ + terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY; + return -1; + } + else{ + strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN); + } + } #endif tjsonGetNumberValue(pJson, "sstTrigger", pCfg->sttTrigger, code); if (code < 0) pCfg->sttTrigger = TSDB_DEFAULT_SST_TRIGGER;