From 24d7dc58254548e5c030a5885be73a76e30122c5 Mon Sep 17 00:00:00 2001 From: Tao Liu Date: Mon, 1 Jun 2020 06:00:03 +0000 Subject: [PATCH] [TD-424] modify the tscGetmetadata --- src/client/inc/tsclient.h | 1 + src/client/src/tscServer.c | 10 ++++++++++ src/inc/taosmsg.h | 1 + src/system/detail/src/mgmtShell.c | 2 ++ 4 files changed, 14 insertions(+) diff --git a/src/client/inc/tsclient.h b/src/client/inc/tsclient.h index f931bd4729..5520c471ee 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 ea42f32cf6..046f9f5adb 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 48ee48eae3..964718c51c 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 c8a2ef7db0..3eb929407a 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; } -- GitLab