Skip to content

Commit

Permalink
fix: table level privilege
Browse files Browse the repository at this point in the history
  • Loading branch information
xiao-yu-wang committed Apr 7, 2023
1 parent 0f2c753 commit d1decca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
6 changes: 4 additions & 2 deletions source/common/src/tmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
8 changes: 5 additions & 3 deletions source/libs/catalog/src/ctgUtil.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit d1decca

Please sign in to comment.