提交 89143de5 编写于 作者: C Cary Xu

grant check time

上级 26934679
...@@ -429,10 +429,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg * ...@@ -429,10 +429,8 @@ static int32_t mnodeCreateDb(SAcctObj *pAcct, SCreateDbMsg *pCreate, SMnodeMsg *
} }
} }
#ifdef GRANT_CHECK_WRITE
code = grantCheck(TSDB_GRANT_DB); code = grantCheck(TSDB_GRANT_DB);
if (code != 0) return code; if (code != 0) return code;
#endif
pDb = calloc(1, sizeof(SDbObj)); pDb = calloc(1, sizeof(SDbObj));
tstrncpy(pDb->name, pCreate->db, sizeof(pDb->name)); tstrncpy(pDb->name, pCreate->db, sizeof(pDb->name));
......
...@@ -663,12 +663,10 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) { ...@@ -663,12 +663,10 @@ static int32_t mnodeProcessDnodeStatusMsg(SMnodeMsg *pMsg) {
} }
static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) { static int32_t mnodeCreateDnode(char *ep, SMnodeMsg *pMsg) {
#ifndef GRANT_CHECK_WRITE
int32_t grantCode = grantCheck(TSDB_GRANT_DNODE); int32_t grantCode = grantCheck(TSDB_GRANT_DNODE);
if (grantCode != TSDB_CODE_SUCCESS) { if (grantCode != TSDB_CODE_SUCCESS) {
return grantCode; return grantCode;
} }
#endif
char dnodeEp[TSDB_EP_LEN] = {0}; char dnodeEp[TSDB_EP_LEN] = {0};
tstrncpy(dnodeEp, ep, TSDB_EP_LEN); tstrncpy(dnodeEp, ep, TSDB_EP_LEN);
strtrim(dnodeEp); strtrim(dnodeEp);
......
...@@ -205,12 +205,10 @@ int32_t mnodeCreateFunc(SAcctObj *pAcct, char *name, int32_t codeLen, char *code ...@@ -205,12 +205,10 @@ int32_t mnodeCreateFunc(SAcctObj *pAcct, char *name, int32_t codeLen, char *code
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
return code; return code;
} }
#ifdef GRANT_CHECK_WRITE
code = grantCheck(TSDB_GRANT_USER); code = grantCheck(TSDB_GRANT_USER);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
return code; return code;
} }
#endif
if (name[0] == 0) { if (name[0] == 0) {
return TSDB_CODE_MND_INVALID_FUNC_NAME; return TSDB_CODE_MND_INVALID_FUNC_NAME;
} }
......
...@@ -2216,20 +2216,18 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) { ...@@ -2216,20 +2216,18 @@ static int32_t mnodeProcessCreateChildTableMsg(SMnodeMsg *pMsg) {
//SCMCreateTableMsg* p1 = pMsg->rpcMsg.pCont; // there are several tables here. //SCMCreateTableMsg* p1 = pMsg->rpcMsg.pCont; // there are several tables here.
SCreateTableMsg* pCreate = (SCreateTableMsg*)((char *)pMsg->rpcMsg.pCont + sizeof(SCMCreateTableMsg)); SCreateTableMsg* pCreate = (SCreateTableMsg*)((char *)pMsg->rpcMsg.pCont + sizeof(SCMCreateTableMsg));
#ifdef GRANT_CHECK_WRITE
int32_t code = grantCheck(TSDB_GRANT_TIMESERIES); int32_t code = grantCheck(TSDB_GRANT_TIMESERIES);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
mError("msg:%p, app:%p table:%s, failed to create, grant timeseries failed", pMsg, pMsg->rpcMsg.ahandle, mError("msg:%p, app:%p table:%s, failed to create, grant timeseries failed", pMsg, pMsg->rpcMsg.ahandle,
pCreate->tableName); pCreate->tableName);
return code; return code;
} }
#endif
if (pMsg->retry == 0) { if (pMsg->retry == 0) {
if (pMsg->pTable == NULL) { if (pMsg->pTable == NULL) {
SVgObj *pVgroup = NULL; SVgObj *pVgroup = NULL;
int32_t tid = 0; int32_t tid = 0;
int32_t code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &tid); code = mnodeGetAvailableVgroup(pMsg, &pVgroup, &tid);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
mDebug("msg:%p, app:%p table:%s, failed to get available vgroup, reason:%s", pMsg, pMsg->rpcMsg.ahandle, mDebug("msg:%p, app:%p table:%s, failed to get available vgroup, reason:%s", pMsg, pMsg->rpcMsg.ahandle,
pCreate->tableName, tstrerror(code)); pCreate->tableName, tstrerror(code));
......
...@@ -250,12 +250,10 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) { ...@@ -250,12 +250,10 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) {
return TSDB_CODE_MND_USER_ALREADY_EXIST; return TSDB_CODE_MND_USER_ALREADY_EXIST;
} }
#ifdef GRANT_CHECK_WRITE
code = grantCheck(TSDB_GRANT_USER); code = grantCheck(TSDB_GRANT_USER);
if (code != TSDB_CODE_SUCCESS) { if (code != TSDB_CODE_SUCCESS) {
return code; return code;
} }
#endif
pUser = calloc(1, sizeof(SUserObj)); pUser = calloc(1, sizeof(SUserObj));
tstrncpy(pUser->user, name, TSDB_USER_LEN); tstrncpy(pUser->user, name, TSDB_USER_LEN);
......
...@@ -56,6 +56,11 @@ int32_t vnodeProcessRead(void *vparam, SVReadMsg *pRead) { ...@@ -56,6 +56,11 @@ int32_t vnodeProcessRead(void *vparam, SVReadMsg *pRead) {
} }
static int32_t vnodeCheckRead(SVnodeObj *pVnode) { static int32_t vnodeCheckRead(SVnodeObj *pVnode) {
if (grantCheck(TSDB_GRANT_TIME) != TSDB_CODE_SUCCESS) {
vDebug("vgId:%d, grant expired, refCount:%d pVnode:%p", pVnode->vgId, pVnode->refCount, pVnode);
return TSDB_CODE_GRANT_EXPIRED;
}
if (!vnodeInReadyStatus(pVnode)) { if (!vnodeInReadyStatus(pVnode)) {
vDebug("vgId:%d, vnode status is %s, refCount:%d pVnode:%p", pVnode->vgId, vnodeStatus[pVnode->status], vDebug("vgId:%d, vnode status is %s, refCount:%d pVnode:%p", pVnode->vgId, vnodeStatus[pVnode->status],
pVnode->refCount, pVnode); pVnode->refCount, pVnode);
...@@ -228,16 +233,6 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) { ...@@ -228,16 +233,6 @@ static int32_t vnodeProcessQueryMsg(SVnodeObj *pVnode, SVReadMsg *pRead) {
vError("error rpc msg in query, %s", tstrerror(pRead->code)); vError("error rpc msg in query, %s", tstrerror(pRead->code));
} }
if (grantCheck(TSDB_GRANT_TIME) != TSDB_CODE_SUCCESS) {
SQueryTableRsp *pRsp = (SQueryTableRsp *)rpcMallocCont(sizeof(SQueryTableRsp));
pRsp->code = TSDB_CODE_GRANT_EXPIRED;
pRsp->qId = 0;
pRet->len = sizeof(SQueryTableRsp);
pRet->rsp = pRsp;
return pRsp->code;
}
int32_t code = TSDB_CODE_SUCCESS; int32_t code = TSDB_CODE_SUCCESS;
void ** handle = NULL; void ** handle = NULL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册