fix: grant check for create table
This commit is contained in:
parent
30f2d0c419
commit
381d378b58
|
@ -21,6 +21,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "os.h"
|
#include "os.h"
|
||||||
|
#include "taoserror.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
TSDB_GRANT_ALL,
|
TSDB_GRANT_ALL,
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
|
||||||
|
*
|
||||||
|
* This program is free software: you can use, redistribute, and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License, version 3
|
||||||
|
* or later ("AGPL"), as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define _DEFAULT_SOURCE
|
||||||
|
#include "tgrant.h"
|
||||||
|
|
||||||
|
#ifndef _GRANT
|
||||||
|
|
||||||
|
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
||||||
|
|
||||||
|
#endif
|
|
@ -190,6 +190,10 @@ static int32_t mndCreateFunc(SMnode *pMnode, SRpcMsg *pReq, SCreateFuncReq *pCre
|
||||||
int32_t code = -1;
|
int32_t code = -1;
|
||||||
STrans *pTrans = NULL;
|
STrans *pTrans = NULL;
|
||||||
|
|
||||||
|
if ((terrno = grantCheck(TSDB_GRANT_USER)) < 0) {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
SFuncObj func = {0};
|
SFuncObj func = {0};
|
||||||
memcpy(func.name, pCreate->name, TSDB_FUNC_NAME_LEN);
|
memcpy(func.name, pCreate->name, TSDB_FUNC_NAME_LEN);
|
||||||
func.createdTime = taosGetTimestampMs();
|
func.createdTime = taosGetTimestampMs();
|
||||||
|
|
|
@ -128,7 +128,6 @@ int32_t mndInitGrant(SMnode *pMnode) {
|
||||||
|
|
||||||
void mndCleanupGrant() {}
|
void mndCleanupGrant() {}
|
||||||
void grantParseParameter() { mError("can't parsed parameter k"); }
|
void grantParseParameter() { mError("can't parsed parameter k"); }
|
||||||
int32_t grantCheck(EGrantType grant) { return TSDB_CODE_SUCCESS; }
|
|
||||||
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
void grantReset(SMnode *pMnode, EGrantType grant, uint64_t value) {}
|
||||||
void grantAdd(EGrantType grant, uint64_t value) {}
|
void grantAdd(EGrantType grant, uint64_t value) {}
|
||||||
void grantRestore(EGrantType grant, uint64_t value) {}
|
void grantRestore(EGrantType grant, uint64_t value) {}
|
||||||
|
|
|
@ -477,6 +477,11 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t version, void *pR
|
||||||
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
for (int32_t iReq = 0; iReq < req.nReqs; iReq++) {
|
||||||
pCreateReq = req.pReqs + iReq;
|
pCreateReq = req.pReqs + iReq;
|
||||||
|
|
||||||
|
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
|
||||||
|
rcode = -1;
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
// validate hash
|
// validate hash
|
||||||
sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name);
|
sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name);
|
||||||
if (vnodeValidateTableHash(pVnode, tbName) < 0) {
|
if (vnodeValidateTableHash(pVnode, tbName) < 0) {
|
||||||
|
@ -821,6 +826,13 @@ static int32_t vnodeProcessSubmitReq(SVnode *pVnode, int64_t version, void *pReq
|
||||||
goto _exit;
|
goto _exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((terrno = grantCheck(TSDB_GRANT_TIMESERIES)) < 0) {
|
||||||
|
pRsp->code = terrno;
|
||||||
|
tDecoderClear(&decoder);
|
||||||
|
taosArrayDestroy(createTbReq.ctb.tagName);
|
||||||
|
goto _exit;
|
||||||
|
}
|
||||||
|
|
||||||
if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) {
|
if (metaCreateTable(pVnode->pMeta, version, &createTbReq) < 0) {
|
||||||
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
if (terrno != TSDB_CODE_TDB_TABLE_ALREADY_EXIST) {
|
||||||
submitBlkRsp.code = terrno;
|
submitBlkRsp.code = terrno;
|
||||||
|
|
Loading…
Reference in New Issue