Skip to content
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
7862707
fix(rbac): rollup database privilege
kailixu Apr 22, 2026
91b110c
fix(rbac): show create database privilege
kailixu Apr 22, 2026
7a3cf72
test(rbac): update show grants test case
kailixu Apr 22, 2026
ec66bb4
fix(rbac): show connections privilege
kailixu Apr 23, 2026
6a96166
Merge branch 'main' into fix/TD-6837020675-main
kailixu Apr 23, 2026
85d41d3
chore(rbac): privilege check optimization
kailixu Apr 24, 2026
17cbc31
chore: refactor sysscanoperator from 3.0
kailixu Apr 24, 2026
bed17a6
Merge branch 'main' into fix/TD-6837020675-main
kailixu Apr 25, 2026
30fe44f
enh(rbac): read system table privileges
kailixu Apr 25, 2026
073bc72
enh(rbac): read system table privileges
kailixu Apr 25, 2026
0fca3e0
enh(rbac): privilege check for show local/cluster variables
kailixu Apr 25, 2026
33349e9
enh(rbac): privilege of show stmt
kailixu Apr 25, 2026
a4c7511
fix(rbac): alter pass/alter self pass privilege
kailixu Apr 26, 2026
d6c8766
fix(rbac): privilege for show tsmas
kailixu Apr 26, 2026
a50cd47
fix(rbac): privilege of show subscriptions
kailixu Apr 26, 2026
c1adda9
enh(test): makefile for specific c file
kailixu Apr 26, 2026
332d850
enh(test): makefile for specific c file
kailixu Apr 26, 2026
86a015c
fix(rbac): test case of priv_control
kailixu Apr 26, 2026
f2b5b8e
chore: fix ci problem
kailixu Apr 26, 2026
0e6ef8f
chore: fix ci problem
kailixu Apr 26, 2026
4484f52
chore: fix ci problem
kailixu Apr 26, 2026
ef51541
chore: fix ci problem
kailixu Apr 27, 2026
ef08c1f
chore: fix ci problem
kailixu Apr 27, 2026
bffc3ca
chore: update totp to totp_secret
kailixu Apr 27, 2026
c48181c
chore: add test case for totp_secret privilege
kailixu Apr 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/common/systable.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ void getPerfDbMeta(const SSysTableMeta** pPerfsTableMeta, size_t* size);
void getVisibleInfosTablesNum(bool sysInfo, size_t* size);
bool invisibleColumn(bool sysInfo, int8_t tableType, int8_t flags);

const SSysTableMeta* getSysTableMeta(const char* dbName, const char* tbName);

#ifdef __cplusplus
}
#endif
Expand Down
9 changes: 8 additions & 1 deletion include/common/tcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,14 @@ typedef struct STUidTagInfo {
#define NOTIFY_EVENT_STR_COLUMN_INDEX 0

int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t startTime);
int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol, char* likePattern);

#define SHOW_VAR_PRIV_SYSTEM 0x01
#define SHOW_VAR_PRIV_SECURITY 0x02
#define SHOW_VAR_PRIV_AUDIT 0x04
#define SHOW_VAR_PRIV_DEBUG 0x08
#define SHOW_VAR_PRIV_ALL (SHOW_VAR_PRIV_SYSTEM | SHOW_VAR_PRIV_SECURITY | SHOW_VAR_PRIV_AUDIT | SHOW_VAR_PRIV_DEBUG)

int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol, char* likePattern, uint8_t showPrivMask);

#define TSMA_RES_STB_POSTFIX "_tsma_res_stb_"
#define MD5_OUTPUT_LEN 32
Expand Down
3 changes: 2 additions & 1 deletion include/libs/command/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
typedef struct SExplainCtx SExplainCtx;
typedef struct SExplainPlanCtx SExplainPlanCtx;

int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode *pStmt, SRetrieveTableRsp **pRsp, int8_t biMode, void* charsetCxt);
int32_t qExecCommand(int64_t *pConnId, bool sysInfoUser, uint8_t showVarPrivMask, SNode *pStmt,
SRetrieveTableRsp **pRsp, int8_t biMode, void *charsetCxt);

int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp);
int32_t qExecExplainBegin(SQueryPlan *pDag, SExplainCtx **pCtx, int64_t startTs);
Expand Down
3 changes: 2 additions & 1 deletion include/libs/parser/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ typedef struct SParseContext {
union {
uint16_t privInfo;
struct {
// N.B. keep the order of the bit definition unchanged
uint16_t minSecLevel : 3; // user min security level
uint16_t privInfoBasic : 1;
uint16_t privInfoPrivileged : 1;
Expand All @@ -148,7 +149,7 @@ typedef struct SParseContext {
uint16_t privPerfBasic : 1;
uint16_t privPerfPrivileged : 1;
uint16_t maxSecLevel : 3; // user max security level
uint16_t macMode : 1; // 1 = MAC mandatory (mirrors macActive, propagates to executor)
uint16_t macMode : 1; // 1 = MAC mandatory (mirrors macActive, propagates to executor)
uint16_t reserved1 : 3;
};
};
Expand Down
43 changes: 40 additions & 3 deletions source/client/src/clientImpl.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,12 +430,43 @@ int32_t parseSql(SRequestObj* pRequest, bool topicQuery, SQuery** pQuery, SStmtC

return code;
}
#ifdef TD_ENTERPRISE
static uint8_t getShowVarPrivMask(SRequestObj* pRequest) {
SCatalog* pCatalog = NULL;
SGetUserAuthRsp authRsp = {0};
STscObj* pTscObj = pRequest->pTscObj;
SRequestConnInfo conn = {.pTrans = pTscObj->pAppInfo->pTransporter,
.requestId = pRequest->requestId,
.requestObjRefId = pRequest->self,
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};

if (TSDB_CODE_SUCCESS != catalogGetHandle(pTscObj->pAppInfo->clusterId, &pCatalog)) {
return 0;
}
if (TSDB_CODE_SUCCESS != catalogGetUserAuth(pCatalog, &conn, pTscObj->user, &authRsp)) {
return 0;
}
Comment thread
kailixu marked this conversation as resolved.

uint8_t mask = 0;
if (PRIV_HAS(&authRsp.sysPrivs, PRIV_VAR_SYSTEM_SHOW)) mask |= SHOW_VAR_PRIV_SYSTEM;
if (PRIV_HAS(&authRsp.sysPrivs, PRIV_VAR_SECURITY_SHOW)) mask |= SHOW_VAR_PRIV_SECURITY;
if (PRIV_HAS(&authRsp.sysPrivs, PRIV_VAR_AUDIT_SHOW)) mask |= SHOW_VAR_PRIV_AUDIT;
if (PRIV_HAS(&authRsp.sysPrivs, PRIV_VAR_DEBUG_SHOW)) mask |= SHOW_VAR_PRIV_DEBUG;
return mask;
Comment thread
kailixu marked this conversation as resolved.
}
#endif

int32_t execLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
SRetrieveTableRsp* pRsp = NULL;
int8_t biMode = atomic_load_8(&pRequest->pTscObj->biMode);
int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp, biMode,
pRequest->pTscObj->optionInfo.charsetCxt);
uint8_t showVarPrivMask = SHOW_VAR_PRIV_ALL;
#ifdef TD_ENTERPRISE
if (pQuery->pRoot != NULL && nodeType(pQuery->pRoot) == QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT) {
showVarPrivMask = getShowVarPrivMask(pRequest);
}
#endif
int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, showVarPrivMask, pQuery->pRoot, &pRsp,
biMode, pRequest->pTscObj->optionInfo.charsetCxt);
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, pRequest->body.resInfo.convertUcs4,
pRequest->stmtBindVersion > 0);
Expand Down Expand Up @@ -473,7 +504,13 @@ void asyncExecLocalCmd(SRequestObj* pRequest, SQuery* pQuery) {
return;
}

int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, pQuery->pRoot, &pRsp,
uint8_t showVarPrivMask = SHOW_VAR_PRIV_ALL;
#ifdef TD_ENTERPRISE
if (pQuery->pRoot != NULL && nodeType(pQuery->pRoot) == QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT) {
showVarPrivMask = getShowVarPrivMask(pRequest);
}
#endif
int32_t code = qExecCommand(&pRequest->pTscObj->id, pRequest->pTscObj->sysInfo, showVarPrivMask, pQuery->pRoot, &pRsp,
atomic_load_8(&pRequest->pTscObj->biMode), pRequest->pTscObj->optionInfo.charsetCxt);
if (TSDB_CODE_SUCCESS == code && NULL != pRsp) {
code = setQueryResultFromRsp(&pRequest->body.resInfo, pRsp, pRequest->body.resInfo.convertUcs4,
Expand Down
22 changes: 22 additions & 0 deletions source/common/src/systable.c
Original file line number Diff line number Diff line change
Expand Up @@ -972,3 +972,25 @@ bool invisibleColumn(bool sysInfo, int8_t tableType, int8_t flags) {
}
return 0 != (flags & COL_IS_SYSINFO);
}

/**
* information_schema or performance_schema
*/
const SSysTableMeta* getSysTableMeta(const char* dbName, const char* tbName) {
const SSysTableMeta* pMeta = NULL;
size_t size = 0;
if (!dbName || !tbName) {
return NULL;
}
if (dbName[0] == 'i' || dbName[0] == 'I') {
getInfosDbMeta(&pMeta, &size);
} else {
getPerfDbMeta(&pMeta, &size);
}
Comment thread
kailixu marked this conversation as resolved.
for (size_t i = 0; i < size; ++i) {
if (strcasecmp(pMeta[i].name, tbName) == 0) {
return pMeta + i;
}
}
return NULL;
}
24 changes: 23 additions & 1 deletion source/common/src/tmisce.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,24 @@ int32_t taosGenCrashJsonMsg(int signum, char** pMsg, int64_t clusterId, int64_t
TAOS_RETURN(code);
}

int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol, char* likePattern) {
#ifdef TD_ENTERPRISE
static bool showVarPrivAllowed(uint8_t showPrivMask, int8_t cfgPrivType) {
switch (cfgPrivType) {
case CFG_PRIV_SYSTEM:
return (showPrivMask & SHOW_VAR_PRIV_SYSTEM) != 0;
case CFG_PRIV_SECURITY:
return (showPrivMask & SHOW_VAR_PRIV_SECURITY) != 0;
case CFG_PRIV_AUDIT:
return (showPrivMask & SHOW_VAR_PRIV_AUDIT) != 0;
case CFG_PRIV_DEBUG:
return (showPrivMask & SHOW_VAR_PRIV_DEBUG) != 0;
default:
return false;
}
}
#endif

int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol, char* likePattern, uint8_t showPrivMask) {
int32_t code = 0;
SConfig* pConf = taosGetCfg();
if (pConf == NULL) {
Expand Down Expand Up @@ -373,6 +390,11 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol, char* likePat
if (likePattern && rawStrPatternMatch(pItem->name, likePattern) != TSDB_PATTERN_MATCH) {
continue;
}
#ifdef TD_ENTERPRISE
if (!showVarPrivAllowed(showPrivMask, pItem->privType)) {
continue;
}
#endif
STR_WITH_MAXSIZE_TO_VARSTR(name, pItem->name, TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE);

SColumnInfoData* pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
Expand Down
2 changes: 1 addition & 1 deletion source/dnode/mgmt/mgmt_dnode/src/dmHandle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1683,7 +1683,7 @@ int32_t dmBuildVariablesBlock(SSDataBlock **ppBlock) {
}

int32_t dmAppendVariablesToBlock(SSDataBlock *pBlock, int32_t dnodeId) {
int32_t code = dumpConfToDataBlock(pBlock, 1, NULL);
int32_t code = dumpConfToDataBlock(pBlock, 1, NULL, SHOW_VAR_PRIV_ALL);
if (code != 0) {
return code;
}
Expand Down
2 changes: 2 additions & 0 deletions source/dnode/mnode/impl/inc/mndPrivilege.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ int32_t mndCheckTokenPrivilege(SMnode *pMnode, const char *opUser, const char *o

int32_t mndCheckSysObjPrivilege(SMnode *pMnode, SUserObj *pUser, const char *token, EPrivType privType,
EPrivObjType objType, int64_t ownerId, const char *objFName, const char *tbName);
uint64_t mndBuildSysPrivBatchMask(SMnode *pMnode, SUserObj *pUser, const char *token,
const EPrivType *privTypes, int32_t numPrivTypes);
int32_t mndCheckObjPrivilegeRec(SMnode *pMnode, SUserObj *pUser, EPrivType privType, EPrivObjType objType,
int64_t ownerId, int32_t acctId, const char *objName, const char *tbName);
int32_t mndCheckObjPrivilegeRecF(SMnode *pMnode, SUserObj *pUser, EPrivType privType, EPrivObjType objType,
Expand Down
58 changes: 54 additions & 4 deletions source/dnode/mnode/impl/src/mndConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,43 @@ static void cfgObjArrayCleanUp(SArray *array) {
taosArrayDestroy(array);
}

static SArray *initVariablesFromItems(SArray *pItems, const char* likePattern) {
#ifdef TD_ENTERPRISE
static bool mndShowVarPrivAllowed(uint8_t showPrivMask, int8_t cfgPrivType) {
switch (cfgPrivType) {
case CFG_PRIV_SYSTEM:
return (showPrivMask & SHOW_VAR_PRIV_SYSTEM) != 0;
case CFG_PRIV_SECURITY:
return (showPrivMask & SHOW_VAR_PRIV_SECURITY) != 0;
case CFG_PRIV_AUDIT:
return (showPrivMask & SHOW_VAR_PRIV_AUDIT) != 0;
case CFG_PRIV_DEBUG:
return (showPrivMask & SHOW_VAR_PRIV_DEBUG) != 0;
default:
return false;
}
}

static uint8_t mndBuildShowVarPrivMask(SMnode *pMnode, SUserObj *pUser, const char *token) {
static const EPrivType kShowVarPrivTypes[] = {
PRIV_VAR_SYSTEM_SHOW,
PRIV_VAR_SECURITY_SHOW,
PRIV_VAR_AUDIT_SHOW,
PRIV_VAR_DEBUG_SHOW,
};

uint64_t rawMask =
mndBuildSysPrivBatchMask(pMnode, pUser, token, kShowVarPrivTypes, (int32_t)ARRAY_SIZE(kShowVarPrivTypes));

uint8_t mask = 0;
if (rawMask & (1ULL << 0)) mask |= SHOW_VAR_PRIV_SYSTEM;
if (rawMask & (1ULL << 1)) mask |= SHOW_VAR_PRIV_SECURITY;
if (rawMask & (1ULL << 2)) mask |= SHOW_VAR_PRIV_AUDIT;
if (rawMask & (1ULL << 3)) mask |= SHOW_VAR_PRIV_DEBUG;
return mask;
}
#endif

static SArray *initVariablesFromItems(SArray *pItems, const char* likePattern, uint8_t showPrivMask) {
if (pItems == NULL) {
return NULL;
}
Expand All @@ -1251,6 +1287,11 @@ static SArray *initVariablesFromItems(SArray *pItems, const char* likePattern) {
if (likePattern != NULL && rawStrPatternMatch(pItem->name, likePattern) != TSDB_PATTERN_MATCH) {
continue;
}
#ifdef TD_ENTERPRISE
if (!mndShowVarPrivAllowed(showPrivMask, pItem->privType)) {
continue;
}
#endif

// init info value
switch (pItem->dtype) {
Expand Down Expand Up @@ -1319,21 +1360,29 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
SShowVariablesRsp rsp = {0};
int32_t code = TSDB_CODE_SUCCESS;
SShowVariablesReq req = {0};
SArray *array = NULL;
SUserObj *pUser = NULL;
uint8_t showPrivMask = 0;
SMnode *pMnode = pReq->info.node;

code = tDeserializeSShowVariablesReq(pReq->pCont, pReq->contLen, &req);
if (code != 0) {
mError("failed to deserialize config req, since %s", terrstr());
goto _OVER;
}

if ((code = mndCheckOperPrivilege(pReq->info.node, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_SHOW_VARIABLES)) != 0) {
if ((code = mndCheckOperPrivilege(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_SHOW_VARIABLES)) != 0) {
goto _OVER;
}

if ((code = mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pUser)) != 0) {
goto _OVER;
}
#ifdef TD_ENTERPRISE
showPrivMask = mndBuildShowVarPrivMask(pMnode, pUser, RPC_MSG_TOKEN(pReq));
#endif
SVariablesInfo info = {0};
char *likePattern = req.opType == OP_TYPE_LIKE ? req.val : NULL;
rsp.variables = initVariablesFromItems(taosGetGlobalCfg(tsCfg), likePattern);
rsp.variables = initVariablesFromItems(taosGetGlobalCfg(tsCfg), likePattern, showPrivMask);
if (rsp.variables == NULL) {
code = terrno;
goto _OVER;
Expand All @@ -1360,6 +1409,7 @@ static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
if (code != 0) {
mError("failed to get show variables info since %s", tstrerror(code));
}
mndReleaseUser(pMnode, pUser);
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mndReleaseUser(pMnode, pUser) is called unconditionally, but pUser can still be NULL on error paths before mndAcquireUser() succeeds. mndReleaseUser() does not handle NULL (it calls sdbRelease directly), so this can crash. Guard the release (e.g., if (pUser) ...) similarly to other mnode codepaths.

Suggested change
mndReleaseUser(pMnode, pUser);
if (pUser != NULL) {
mndReleaseUser(pMnode, pUser);
}

Copilot uses AI. Check for mistakes.
tFreeSShowVariablesReq(&req);
tFreeSShowVariablesRsp(&rsp);
TAOS_RETURN(code);
Expand Down
4 changes: 3 additions & 1 deletion source/dnode/mnode/impl/src/mndDb.c
Original file line number Diff line number Diff line change
Expand Up @@ -2857,7 +2857,9 @@ static int32_t mndProcessTrimDbReq(SRpcMsg *pReq) {
TAOS_CHECK_EXIT(code);
}

TAOS_CHECK_EXIT(mndCheckDbPrivilege(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_TRIM_DB, pDb));
TAOS_CHECK_EXIT(mndCheckDbPrivilege(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq),
trimReq.optrType == TSDB_OPTR_ROLLUP ? MND_OPER_ROLLUP_DB : MND_OPER_TRIM_DB,
pDb));
Comment thread
kailixu marked this conversation as resolved.

if (pDb->cfg.isMount) {
TAOS_CHECK_EXIT(TSDB_CODE_MND_MOUNT_OBJ_NOT_SUPPORT);
Expand Down
4 changes: 2 additions & 2 deletions source/dnode/mnode/impl/src/mndMount.c
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ static int32_t mndProcessCreateMountReq(SRpcMsg *pReq) {
}
}
// mount operation share the privileges of db
Comment thread
kailixu marked this conversation as resolved.
Outdated
TAOS_CHECK_EXIT(mndCheckDbPrivilege(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_CREATE_MOUNT, (SDbObj *)pObj));
TAOS_CHECK_EXIT(mndCheckOperPrivilege(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_CREATE_MOUNT));
TAOS_CHECK_EXIT(grantCheck(TSDB_GRANT_MOUNT));
TAOS_CHECK_EXIT(mndAcquireUser(pMnode, RPC_MSG_USER(pReq), &pUser));
char fullMountName[TSDB_MOUNT_NAME_LEN + 32] = {0};
Expand Down Expand Up @@ -690,7 +690,7 @@ static int32_t mndProcessDropMountReq(SRpcMsg *pReq) {
}

// mount operation share the privileges of db
Comment thread
kailixu marked this conversation as resolved.
Outdated
TAOS_CHECK_GOTO(mndCheckDbPrivilege(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_DROP_MOUNT, (SDbObj *)pObj), NULL, _exit);
TAOS_CHECK_GOTO(mndCheckOperPrivilege(pMnode, RPC_MSG_USER(pReq), RPC_MSG_TOKEN(pReq), MND_OPER_DROP_MOUNT), NULL, _exit);

code = mndDropMount(pMnode, pReq, pObj);
if (code == TSDB_CODE_SUCCESS) {
Expand Down
7 changes: 7 additions & 0 deletions source/dnode/mnode/impl/src/mndPrivilege.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ int32_t mndCheckSysObjPrivilege(SMnode *pMnode, SUserObj *pUser, const char *tok
EPrivObjType objType, int64_t ownerId, const char *objFName, const char *tbName) {
return 0;
}
uint64_t mndBuildSysPrivBatchMask(SMnode *pMnode, SUserObj *pUser, const char *token,
const EPrivType *privTypes, int32_t numPrivTypes) {
if (numPrivTypes <= 0) {
return 0;
}
return numPrivTypes >= 64 ? UINT64_MAX : ((1ULL << numPrivTypes) - 1);
}
Comment thread
kailixu marked this conversation as resolved.
int32_t mndCheckObjPrivilegeRec(SMnode *pMnode, SUserObj *pUser, EPrivType privType, EPrivObjType objType,
int64_t ownerId, int32_t acctId, const char *objName, const char *tbName) {
return 0;
Expand Down
2 changes: 1 addition & 1 deletion source/dnode/mnode/impl/src/mndSma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,7 +1461,7 @@ static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlo
showAll = (0 == mndCheckSysObjPrivilege(pMnode, pUser, RPC_MSG_TOKEN(pReq), PRIV_CM_SHOW, PRIV_OBJ_TSMA, 0, objFName,
objLevel == 0 ? NULL : "*"));
if (!showAll && pShow->db[0] != 0) {
showAll = (0 == mndCheckSysObjPrivilege(pMnode, pUser, RPC_MSG_TOKEN(pReq), PRIV_CM_SHOW, PRIV_OBJ_TSMA, pUser->uid,
showAll = (0 == mndCheckSysObjPrivilege(pMnode, pUser, RPC_MSG_TOKEN(pReq), PRIV_CM_SHOW, PRIV_OBJ_TSMA, pDb->ownerId,
pShow->db, objLevel == 0 ? NULL : "*"));
}

Expand Down
4 changes: 3 additions & 1 deletion source/dnode/mnode/impl/src/mndSubscribe.c
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,9 @@ static int32_t retrieveSub(SRpcMsg *pReq, SMqSubscribeObj *pSub, SUserObj *pOper
varDataSetLen(cgroup, strlen(varDataVal(cgroup)));

if (!showAll) {
(void)mndAcquireTopic(pMnode, topic, &pTopic);
char topicFName[TSDB_TOPIC_FNAME_LEN + 1] = {0};
(void)snprintf(topicFName, sizeof(topicFName), "%d.%s", pOperUser->acctId, varDataVal(topic));
(void)mndAcquireTopic(pMnode, topicFName, &pTopic);
if (pTopic) {
SName name = {0}; // 1.topic1
if (0 == tNameFromString(&name, pTopic->name, T_NAME_ACCT | T_NAME_DB)) {
Expand Down
10 changes: 5 additions & 5 deletions source/libs/command/src/command.c
Original file line number Diff line number Diff line change
Expand Up @@ -1254,7 +1254,7 @@ static int32_t buildLocalVariablesResultDataBlock(SSDataBlock** pOutput) {
return terrno;
}

static int32_t execShowLocalVariables(SShowStmt* pStmt, SRetrieveTableRsp** pRsp) {
static int32_t execShowLocalVariables(SShowStmt* pStmt, uint8_t showVarPrivMask, SRetrieveTableRsp** pRsp) {
SSDataBlock* pBlock = NULL;
char* likePattern = NULL;
int32_t code = buildLocalVariablesResultDataBlock(&pBlock);
Expand All @@ -1264,7 +1264,7 @@ static int32_t execShowLocalVariables(SShowStmt* pStmt, SRetrieveTableRsp** pRsp
}
}
if (TSDB_CODE_SUCCESS == code) {
code = dumpConfToDataBlock(pBlock, 0, likePattern);
code = dumpConfToDataBlock(pBlock, 0, likePattern, showVarPrivMask);
}
if (TSDB_CODE_SUCCESS == code) {
code = buildRetrieveTableRsp(pBlock, SHOW_LOCAL_VARIABLES_RESULT_COLS, pRsp);
Expand Down Expand Up @@ -1363,8 +1363,8 @@ static int32_t execShowCreateRsma(SShowCreateRsmaStmt* pStmt, SRetrieveTableRsp*
return code;
}

int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp, int8_t biMode,
void* charsetCxt) {
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, uint8_t showVarPrivMask, SNode* pStmt,
SRetrieveTableRsp** pRsp, int8_t biMode, void* charsetCxt) {
switch (nodeType(pStmt)) {
case QUERY_NODE_DESCRIBE_STMT:
return execDescribe(sysInfoUser, pStmt, pRsp, biMode);
Expand All @@ -1385,7 +1385,7 @@ int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieve
case QUERY_NODE_ALTER_LOCAL_STMT:
return execAlterLocal((SAlterLocalStmt*)pStmt);
case QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT:
return execShowLocalVariables((SShowStmt*)pStmt, pRsp);
return execShowLocalVariables((SShowStmt*)pStmt, showVarPrivMask, pRsp);
case QUERY_NODE_SELECT_STMT:
return execSelectWithoutFrom((SSelectStmt*)pStmt, pRsp);
default:
Expand Down
Loading
Loading