From d1decca07ee57709bdd4d4be2d07e376ace580cc Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Fri, 7 Apr 2023 18:22:07 +0800 Subject: [PATCH] fix: table level privilege --- source/common/src/tmsg.c | 6 ++++-- source/libs/catalog/src/ctgUtil.c | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 30bf900803..7d517e3e1e 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1524,6 +1524,8 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs pRsp->createdDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); pRsp->readDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); pRsp->writeDbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pRsp->readTbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); + pRsp->writeTbs = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); if (pRsp->readDbs == NULL || pRsp->writeDbs == NULL) { return -1; } @@ -1579,7 +1581,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs char *value = taosMemoryCalloc(valuelen + 1, sizeof(char)); if (tDecodeCStrTo(pDecoder, value) < 0) return -1; - taosHashPut(pRsp->readTbs, key, keyLen, value, valuelen); + taosHashPut(pRsp->readTbs, key, strlen(key), value, valuelen); taosMemoryFree(key); taosMemoryFree(value); @@ -1597,7 +1599,7 @@ int32_t tDeserializeSGetUserAuthRspImpl(SDecoder *pDecoder, SGetUserAuthRsp *pRs char *value = taosMemoryCalloc(valuelen + 1, sizeof(char)); if (tDecodeCStrTo(pDecoder, value) < 0) return -1; - taosHashPut(pRsp->writeTbs, key, keyLen, value, valuelen); + taosHashPut(pRsp->writeTbs, key, strlen(key), value, valuelen); taosMemoryFree(key); taosMemoryFree(value); diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index 501ad63dce..4fd5f126f3 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -1337,11 +1337,13 @@ int32_t ctgChkSetTbAuthRes(SCatalog *pCtg, SCtgAuthReq *req, SCtgAuthRsp* res) { STableMeta *pMeta = NULL; SGetUserAuthRsp *pInfo = &req->authInfo; SHashObj *pTbs = (AUTH_TYPE_READ == req->singleType) ? pInfo->readTbs : pInfo->writeTbs; - - char *pCond = taosHashGet(pTbs, req->pRawReq->tbName.tname, strlen(req->pRawReq->tbName.tname)); + + char tbFullName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(&req->pRawReq->tbName, tbFullName); + char *pCond = taosHashGet(pTbs, tbFullName, strlen(tbFullName)); if (pCond) { if (strlen(pCond) > 1) { - CTG_RET(nodesStringToNode(pCond, &res->pRawRes->pCond)); + CTG_ERR_RET(nodesStringToNode(pCond, &res->pRawRes->pCond)); } res->pRawRes->pass = true;