From cfd3e5149c3b92e48a38ddfe27debe625d52bab6 Mon Sep 17 00:00:00 2001 From: slguan Date: Tue, 3 Mar 2020 18:27:18 +0800 Subject: [PATCH] compile for mgmt grant --- src/dnode/inc/dnodeSystem.h | 1 - src/dnode/src/dnodeService.c | 6 +++++- src/dnode/src/dnodeSystem.c | 4 ---- src/inc/dnode.h | 1 - src/mnode/inc/mgmtGrant.h | 4 +++- src/mnode/src/mgmtChildTable.c | 2 +- src/mnode/src/mgmtDnodeInt.c | 13 +++++++++++-- src/mnode/src/mgmtGrant.c | 8 ++++++-- 8 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/dnode/inc/dnodeSystem.h b/src/dnode/inc/dnodeSystem.h index d2c2984599..7aeb26b54f 100644 --- a/src/dnode/inc/dnodeSystem.h +++ b/src/dnode/inc/dnodeSystem.h @@ -33,7 +33,6 @@ extern int32_t (*dnodeInitPeers)(int32_t numOfThreads); extern int32_t (*dnodeCheckSystem)(); extern int32_t (*dnodeInitStorage)(); extern void (*dnodeCleanupStorage)(); -extern void (*dnodeParseParameterK)(); extern int32_t tsMaxQueues; extern void ** tsRpcQhandle; extern void *tsQueryQhandle; diff --git a/src/dnode/src/dnodeService.c b/src/dnode/src/dnodeService.c index d7f9721fda..a8a110ab4c 100644 --- a/src/dnode/src/dnodeService.c +++ b/src/dnode/src/dnodeService.c @@ -19,6 +19,8 @@ #include "tglobalcfg.h" #include "dnodeSystem.h" +void (*dnodeParseParameterKFp)() = NULL; + /* * Termination handler */ @@ -63,7 +65,9 @@ int main(int argc, char *argv[]) { printf("buildinfo: %s\n", buildinfo); return 0; } else if (strcmp(argv[i], "-k") == 0) { - dnodeParseParameterK(); + if (dnodeParseParameterKFp) { + dnodeParseParameterKFp(); + } #ifdef TAOS_MEM_CHECK } else if (strcmp(argv[i], "--alloc-random-fail") == 0) { if ((i < argc - 1) && (argv[i+1][0] != '-')) { diff --git a/src/dnode/src/dnodeSystem.c b/src/dnode/src/dnodeSystem.c index 23962ec075..67a1d42565 100644 --- a/src/dnode/src/dnodeSystem.c +++ b/src/dnode/src/dnodeSystem.c @@ -294,10 +294,6 @@ int32_t dnodeCheckSystemImp() { int32_t (*dnodeCheckSystem)() = dnodeCheckSystemImp; -void dnodeParseParameterKImp() {} - -void (*dnodeParseParameterK)() = dnodeParseParameterKImp; - int32_t dnodeInitPeersImp(int32_t numOfThreads) { return 0; } diff --git a/src/inc/dnode.h b/src/inc/dnode.h index c69e1d2b26..15a6096826 100644 --- a/src/inc/dnode.h +++ b/src/inc/dnode.h @@ -42,7 +42,6 @@ extern uint32_t tsRebootTime; // dnodeCluster extern void (*dnodeStartModules)(); -extern void (*dnodeParseParameterK)(); extern int32_t (*dnodeCheckSystem)(); diff --git a/src/mnode/inc/mgmtGrant.h b/src/mnode/inc/mgmtGrant.h index 2e7122f619..1cfc88f94a 100644 --- a/src/mnode/inc/mgmtGrant.h +++ b/src/mnode/inc/mgmtGrant.h @@ -31,7 +31,9 @@ int32_t mgmtCheckTimeSeries(uint32_t timeseries); int32_t mgmtCheckUserGrant(); int32_t mgmtCheckDbGrant(); int32_t mgmtGetGrantsMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn); -int32_t mgmtRetrieveGrants(SShowObj *pShow, char *data, int rows, void *pConn); +int32_t mgmtRetrieveGrants(SShowObj *pShow, char *data, int32_t rows, void *pConn); + +extern void (*mgmtUpdateGrantInfoFp)(void *pCont); #ifdef __cplusplus } diff --git a/src/mnode/src/mgmtChildTable.c b/src/mnode/src/mgmtChildTable.c index e2b141fb64..02771b19c9 100644 --- a/src/mnode/src/mgmtChildTable.c +++ b/src/mnode/src/mgmtChildTable.c @@ -442,7 +442,7 @@ int32_t mgmtModifyChildTableTagValueByName(SChildTableObj *pTable, char *tagName // // mgmtMeterActionEncode(pTable, msg, size, &rowSize); // -// int32_t ret = sdbUpdateRow(meterSdb, msg, rowSize, 1); // Need callback function +// int32_t ret = sdbUpdateRow(tsChildTableSdb, msg, rowSize, 1); // Need callback function // tfree(msg); // // if (pTable->isDirty) pTable->isDirty = 0; diff --git a/src/mnode/src/mgmtDnodeInt.c b/src/mnode/src/mgmtDnodeInt.c index fb3110d93d..5a365f220a 100644 --- a/src/mnode/src/mgmtDnodeInt.c +++ b/src/mnode/src/mgmtDnodeInt.c @@ -26,6 +26,7 @@ #include "mgmtDb.h" #include "mgmtDnode.h" #include "mgmtDnodeInt.h" +#include "mgmtGrant.h" #include "mgmtProfile.h" #include "mgmtShell.h" #include "mgmtTable.h" @@ -230,6 +231,14 @@ void mgmtSendCreateVnodeMsg(SVgObj *pVgroup, int32_t vnode, SRpcIpSet *ipSet, vo } } +static void mgmtProcessDnodeGrantMsg(void *pCont, void *thandle) { + if (mgmtUpdateGrantInfoFp) { + mgmtUpdateGrantInfoFp(pCont); + mTrace("grant info is updated"); + } + rpcSendResponse(thandle, TSDB_CODE_SUCCESS, NULL, 0); +} + void mgmtProcessMsgFromDnode(char msgType, void *pCont, int32_t contLen, void *pConn, int32_t code) { if (msgType < 0 || msgType >= TSDB_MSG_TYPE_MAX) { mError("invalid msg type:%d", msgType); @@ -255,9 +264,9 @@ void mgmtProcessMsgFromDnode(char msgType, void *pCont, int32_t contLen, void *p } else if (msgType == TSDB_MSG_TYPE_DNODE_CFG_RSP) { } else if (msgType == TSDB_MSG_TYPE_ALTER_STREAM_RSP) { } else if (msgType == TSDB_MSG_TYPE_STATUS) { - mgmtProcessDnodeStatus(msgType, pConn, contLen, pConn, code); + mgmtProcessDnodeStatus(msgType, pCont, contLen, pConn, code); } else if (msgType == TSDB_MSG_TYPE_GRANT) { - mgmtProcessDropStableRsp(msgType, pCont, contLen, pConn, code); + mgmtProcessDnodeGrantMsg(pCont, pConn); } else { mError("%s from dnode is not processed", taosMsg[(int8_t)msgType]); } diff --git a/src/mnode/src/mgmtGrant.c b/src/mnode/src/mgmtGrant.c index df151ac500..c24fb82aa6 100644 --- a/src/mnode/src/mgmtGrant.c +++ b/src/mnode/src/mgmtGrant.c @@ -18,6 +18,7 @@ #include "mnode.h" #include "mgmtAcct.h" #include "mgmtGrant.h" +#include "mgmtUser.h" int32_t (*mgmtCheckUserGrantFp)() = NULL; int32_t (*mgmtCheckDbGrantFp)() = NULL; @@ -27,6 +28,7 @@ int32_t (*mgmtCheckTimeSeriesFp)(uint32_t timeseries) = NULL; bool (*mgmtCheckExpiredFp)() = NULL; int32_t (*mgmtGetGrantsMetaFp)(STableMeta *pMeta, SShowObj *pShow, void *pConn) = NULL; int32_t (*mgmtRetrieveGrantsFp)(SShowObj *pShow, char *data, int rows, void *pConn) = NULL; +void (*mgmtUpdateGrantInfoFp)(void *pCont) = NULL; int32_t mgmtCheckUserGrant() { if (mgmtCheckUserGrantFp) { @@ -76,17 +78,19 @@ bool mgmtCheckExpired() { int32_t mgmtGetGrantsMeta(STableMeta *pMeta, SShowObj *pShow, void *pConn) { if (mgmtGetGrantsMetaFp) { + SUserObj *pUser = mgmtGetUserFromConn(pConn); + if (pUser == NULL) return 0; + if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_NO_RIGHTS; return mgmtGetGrantsMetaFp(pMeta, pShow, pConn); } else { return TSDB_CODE_OPS_NOT_SUPPORT; } } -int32_t mgmtRetrieveGrants(SShowObj *pShow, char *data, int rows, void *pConn) { +int32_t mgmtRetrieveGrants(SShowObj *pShow, char *data, int32_t rows, void *pConn) { if (mgmtRetrieveGrantsFp) { return mgmtRetrieveGrantsFp(pShow, data, rows, pConn); } else { return 0; } } - -- GitLab