diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index f931bd472992a22ed7de6e99c1545495a821c620..5520c471ee02071bc9cca7158ad7b51cfc06b20b 100644 --- a/src/client/inc/tsclient.h +++ b/src/client/inc/tsclient.h @@ -307,6 +307,7 @@ typedef struct _tsc_obj { char sversion[TSDB_VERSION_LEN]; char writeAuth : 1; char superAuth : 1; + char auditAuth : 1; struct _sql_obj *pSql; struct _sql_obj *pHb; struct _sql_obj *sqlList; diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index ea42f32cf65c53ccecf748459b3ea0aa8f776bdf..046f9f5adbc9fa7089da08c8c50a17d968f3ca39 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -3353,6 +3353,7 @@ int tscProcessConnectRsp(SSqlObj *pSql) { strcpy(pObj->sversion, pConnect->version); pObj->writeAuth = pConnect->writeAuth; pObj->superAuth = pConnect->superAuth; + pObj->auditAuth = pConnect->auditAuth; taosTmrReset(tscProcessActivityTimer, tsShellActivityTimer * 500, pObj, tscTmr, &pObj->pTimer); return 0; @@ -3576,6 +3577,15 @@ static int32_t doGetMeterMetaFromServer(SSqlObj *pSql, SMeterMetaInfo *pMeterMet int tscGetMeterMeta(SSqlObj *pSql, SMeterMetaInfo *pMeterMetaInfo) { assert(strlen(pMeterMetaInfo->name) != 0); + char db[TSDB_DB_NAME_LEN + 1] = {0}; + extractDBName(pMeterMetaInfo->name, db); + if(strncasecmp(db,"audit",5) == 0 && pSql->pTscObj->auditAuth == 0 && strncasecmp(pSql->pTscObj->user,"monitor",7) != 0) { + return TSDB_CODE_NOT_AUDIT_USER; + } + if(strncasecmp(db,"audit",5) != 0 && pSql->pTscObj->auditAuth != 0 && pSql->pTscObj->writeAuth == 0 ){ + return TSDB_CODE_NO_RIGHTS; + } + // If this SMeterMetaInfo owns a metermeta, release it first if (pMeterMetaInfo->pMeterMeta != NULL) { taosRemoveDataFromCache(tscCacheHandle, (void **)&(pMeterMetaInfo->pMeterMeta), false); diff --git a/src/inc/taosmsg.h b/src/inc/taosmsg.h index 48ee48eae345a7a576b7aaa6eef1b2438a9ed39d..964718c51c58f0e52d8148502661023599c8ac14 100644 --- a/src/inc/taosmsg.h +++ b/src/inc/taosmsg.h @@ -391,6 +391,7 @@ typedef struct { char version[TSDB_VERSION_LEN]; char writeAuth; char superAuth; + char auditAuth; } SConnectRsp; typedef struct { diff --git a/src/system/detail/src/mgmtShell.c b/src/system/detail/src/mgmtShell.c index c8a2ef7db0ef2101947a791fa5376f39623dab79..3eb929407af82f8f2e57a2e7d74a4835fc0da321 100644 --- a/src/system/detail/src/mgmtShell.c +++ b/src/system/detail/src/mgmtShell.c @@ -1416,6 +1416,7 @@ _rsp: strcpy(pConnectRsp->version, version); pConnectRsp->writeAuth = pConn->writeAuth; pConnectRsp->superAuth = pConn->superAuth; + pConnectRsp->auditAuth = pConn->auditAuth; pMsg += sizeof(SConnectRsp); int size; @@ -1441,6 +1442,7 @@ _rsp: } else { pConnectRsp->writeAuth = 0; pConnectRsp->superAuth = 0; + pConnectRsp->auditAuth = 0; pConn->pAcct = NULL; pConn->pUser = NULL; }