diff --git a/include/common/tmsg.h b/include/common/tmsg.h index d96e7bad8cc3f9b96bfff26e437bac0593893a52..74d86f64b245ce31fe99900a8367c061a9ba76e8 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -769,6 +769,8 @@ typedef struct { char* pAst2; int64_t deleteMark1; int64_t deleteMark2; + int32_t sqlLen; + char* sql; } SMCreateStbReq; int32_t tSerializeSMCreateStbReq(void* buf, int32_t bufLen, SMCreateStbReq* pReq); @@ -789,6 +791,8 @@ typedef struct { int8_t source; // 1-taosX or 0-taosClient int8_t reserved[6]; tb_uid_t suid; + int32_t sqlLen; + char* sql; } SMDropStbReq; int32_t tSerializeSMDropStbReq(void* buf, int32_t bufLen, SMDropStbReq* pReq); @@ -802,6 +806,8 @@ typedef struct { int32_t ttl; int32_t commentLen; char* comment; + int32_t sqlLen; + char* sql; } SMAlterStbReq; int32_t tSerializeSMAlterStbReq(void* buf, int32_t bufLen, SMAlterStbReq* pReq); @@ -871,6 +877,8 @@ int32_t tDeserializeSCreateAcctReq(void* buf, int32_t bufLen, SCreateAcctReq* pR typedef struct { char user[TSDB_USER_LEN]; + int32_t sqlLen; + char *sql; } SDropUserReq, SDropAcctReq; int32_t tSerializeSDropUserReq(void* buf, int32_t bufLen, SDropUserReq* pReq); @@ -883,6 +891,8 @@ typedef struct { int8_t enable; char user[TSDB_USER_LEN]; char pass[TSDB_USET_PASSWORD_LEN]; + int32_t sqlLen; + char* sql; } SCreateUserReq; int32_t tSerializeSCreateUserReq(void* buf, int32_t bufLen, SCreateUserReq* pReq); @@ -899,6 +909,8 @@ typedef struct { char tabName[TSDB_TABLE_NAME_LEN]; char* tagCond; int32_t tagCondLen; + int32_t sqlLen; + char* sql; } SAlterUserReq; int32_t tSerializeSAlterUserReq(void* buf, int32_t bufLen, SAlterUserReq* pReq); @@ -1061,6 +1073,8 @@ typedef struct { int16_t hashPrefix; int16_t hashSuffix; int32_t tsdbPageSize; + int32_t sqlLen; + char* sql; } SCreateDbReq; int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq); @@ -1086,6 +1100,8 @@ typedef struct { int32_t minRows; int32_t walRetentionPeriod; int32_t walRetentionSize; + int32_t sqlLen; + char* sql; } SAlterDbReq; int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq); @@ -1094,6 +1110,8 @@ int32_t tDeserializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq); typedef struct { char db[TSDB_DB_FNAME_LEN]; int8_t ignoreNotExists; + int32_t sqlLen; + char* sql; } SDropDbReq; int32_t tSerializeSDropDbReq(void* buf, int32_t bufLen, SDropDbReq* pReq); @@ -1850,6 +1868,8 @@ void tFreeSExplainRsp(SExplainRsp* pRsp); typedef struct { char fqdn[TSDB_FQDN_LEN]; // end point, hostname:port int32_t port; + int32_t sqlLen; + char* sql; } SCreateDnodeReq; int32_t tSerializeSCreateDnodeReq(void* buf, int32_t bufLen, SCreateDnodeReq* pReq); @@ -1861,6 +1881,8 @@ typedef struct { int32_t port; int8_t force; int8_t unsafe; + int32_t sqlLen; + char* sql; } SDropDnodeReq; int32_t tSerializeSDropDnodeReq(void* buf, int32_t bufLen, SDropDnodeReq* pReq); @@ -1885,6 +1907,8 @@ typedef struct { int32_t dnodeId; char config[TSDB_DNODE_CONFIG_LEN]; char value[TSDB_DNODE_VALUE_LEN]; + int32_t sqlLen; + char* sql; } SMCfgDnodeReq; int32_t tSerializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq); @@ -1900,6 +1924,8 @@ int32_t tDeserializeSDCfgDnodeReq(void* buf, int32_t bufLen, SDCfgDnodeReq* pReq typedef struct { int32_t dnodeId; + int32_t sqlLen; + char *sql; } SMCreateMnodeReq, SMDropMnodeReq, SDDropMnodeReq, SMCreateQnodeReq, SMDropQnodeReq, SDCreateQnodeReq, SDDropQnodeReq, SMCreateSnodeReq, SMDropSnodeReq, SDCreateSnodeReq, SDDropSnodeReq; @@ -2208,6 +2234,7 @@ typedef struct { int64_t deleteMark; int8_t igUpdate; int64_t lastTs; + int32_t sqlLen; } SCMCreateStreamReq; typedef struct { @@ -2244,6 +2271,7 @@ typedef struct { char subDbName[TSDB_DB_FNAME_LEN]; char* ast; char subStbName[TSDB_TABLE_FNAME_LEN]; + int32_t sqlLen; } SCMCreateTopicReq; int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq); @@ -2428,6 +2456,8 @@ typedef struct { typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; int8_t igNotExists; + int32_t sqlLen; + char* sql; } SMDropTopicReq; int32_t tSerializeSMDropTopicReq(void* buf, int32_t bufLen, SMDropTopicReq* pReq); @@ -3006,6 +3036,8 @@ typedef struct { typedef struct { char name[TSDB_STREAM_FNAME_LEN]; int8_t igNotExists; + int32_t sqlLen; + char* sql; } SMDropStreamReq; typedef struct { diff --git a/include/libs/audit/audit.h b/include/libs/audit/audit.h index 7785a0912d95bdf52a3bde3af45002dace6cb51b..ca676c191022b5e3bdb2b8c926f32b4c2c4ae0ac 100644 --- a/include/libs/audit/audit.h +++ b/include/libs/audit/audit.h @@ -31,13 +31,12 @@ extern "C" { typedef struct { const char *server; uint16_t port; - int32_t maxLogs; bool comp; } SAuditCfg; int32_t auditInit(const SAuditCfg *pCfg); void auditSend(SJson *pJson); -void auditRecord(SRpcMsg *pReq, char *oper, char *db, char *stable, char *detail); +void auditRecord(SRpcMsg *pReq, char *oper, char *db, char *stable, int32_t detailLen, char *detail); #ifdef __cplusplus } diff --git a/source/dnode/mgmt/node_mgmt/src/dmEnv.c b/source/dnode/mgmt/node_mgmt/src/dmEnv.c index bbf42210865bd9980a8984cb7d54cd177ca8b8dc..320c9db37d75bb63225b3ca90ff6e268b4d561d3 100644 --- a/source/dnode/mgmt/node_mgmt/src/dmEnv.c +++ b/source/dnode/mgmt/node_mgmt/src/dmEnv.c @@ -37,8 +37,9 @@ #define DM_INIT_AUDIT() \ do { \ - auditCfg.port = tsAuditPort; \ - auditCfg.server = tsAuditFqdn; \ + auditCfg.port = tsMonitorPort; \ + auditCfg.server = tsMonitorFqdn; \ + auditCfg.comp = tsMonitorComp; \ if (auditInit(&auditCfg) != 0) { \ return -1; \ } \ diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index e160f388595fb017683a41dab88d92452036d2b1..a6eb27aee5cd9a0af26352f35740c1ce74f31136 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -736,13 +736,7 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) { code = mndCreateDb(pMnode, pReq, &createReq, pUser); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - sprintf(detail, "dbname:%s, buffer:%d, cacheLast:%d, cacheLastSize:%d, compression:%d, " - "daysPerFile:%d, daysToKeep0:%d, daysToKeep1:%d, daysToKeep2:%d", - createReq.db, createReq.buffer, createReq.cacheLast, createReq.cacheLastSize, createReq.compression, - createReq.daysPerFile, createReq.daysToKeep0, createReq.daysToKeep1, createReq.daysToKeep2); - - auditRecord(pReq, "createDB", createReq.db, "", detail); + auditRecord(pReq, "createDB", createReq.db, "", createReq.sqlLen, createReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -986,13 +980,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) { if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; } - char detail[1000] = {0}; - sprintf(detail, "dbname:%s, buffer:%d, cacheLast:%d, cacheLastSize:%d, " - "daysPerFile:%d, daysToKeep0:%d, daysToKeep1:%d, daysToKeep2:%d", - alterReq.db, alterReq.buffer, alterReq.cacheLast, alterReq.cacheLastSize, - alterReq.daysPerFile, alterReq.daysToKeep0, alterReq.daysToKeep1, alterReq.daysToKeep2); - - auditRecord(pReq, "alterDB", alterReq.db, "", detail); + auditRecord(pReq, "alterDB", alterReq.db, "", alterReq.sqlLen, alterReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -1283,10 +1271,7 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) { code = TSDB_CODE_ACTION_IN_PROGRESS; } - char detail[1000] = {0}; - sprintf(detail, "dbname:%s, ignoreNotExists:%d", dropReq.db, dropReq.ignoreNotExists); - - auditRecord(pReq, "dropDB", dropReq.db, "", detail); + auditRecord(pReq, "dropDB", dropReq.db, "", dropReq.sqlLen, dropReq.sql); _OVER: if (code != TSDB_CODE_SUCCESS && code != TSDB_CODE_ACTION_IN_PROGRESS) { diff --git a/source/dnode/mnode/impl/src/mndDnode.c b/source/dnode/mnode/impl/src/mndDnode.c index e1264c820c76f89935539f9266ce716e7df02d4d..2ae99638afdbf887f384c21251cb9ff5c943db08 100644 --- a/source/dnode/mnode/impl/src/mndDnode.c +++ b/source/dnode/mnode/impl/src/mndDnode.c @@ -913,7 +913,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) { sprintf(detail, "%s:%d", createReq.fqdn, createReq.port); - auditRecord(pReq, "createDnode", detail, "", ""); + auditRecord(pReq, "createDnode", detail, "", createReq.sqlLen, createReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -1062,18 +1062,13 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) { code = mndDropDnode(pMnode, pReq, pDnode, pMObj, pQObj, pSObj, numOfVnodes, force, dropReq.unsafe); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - char obj1[150] = {0}; sprintf(obj1, "%s:%d", dropReq.fqdn, dropReq.port); char obj2[10] = {0}; sprintf(obj2, "%d", dropReq.dnodeId); - sprintf(detail, "dnodeId:%d, force:%d, unsafe:%d", - dropReq.dnodeId, dropReq.force, dropReq.unsafe); - - auditRecord(pReq, "dropDnode", obj1, obj2, detail); + auditRecord(pReq, "dropDnode", obj1, obj2, dropReq.sqlLen, dropReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -1208,6 +1203,11 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) { } } + char detail[50] = {0}; + sprintf(detail, "%d", cfgReq.dnodeId); + + auditRecord(pReq, "alterDnode", detail, "", cfgReq.sqlLen, cfgReq.sql); + int32_t code = -1; SSdb *pSdb = pMnode->pSdb; void *pIter = NULL; diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index 930ec0bc94975380ab71642dc8d68de235cd1134..739c7a2912489cab8f78379576c0cd2e1a303a01 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -660,7 +660,7 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) { sprintf(detail, "dnodeId:%d", createReq.dnodeId); - auditRecord(pReq, "createMnode", obj, detail, ""); + auditRecord(pReq, "createMnode", obj, detail, createReq.sqlLen, createReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -798,14 +798,10 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) { code = mndDropMnode(pMnode, pReq, pObj); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - char obj[20] = {0}; sprintf(obj, "%d", dropReq.dnodeId); - sprintf(detail, "dnodeId:%d", dropReq.dnodeId); - - auditRecord(pReq, "dropMnode", obj, detail, ""); + auditRecord(pReq, "dropMnode", obj, "", dropReq.sqlLen, dropReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index 17a0e39d3f60cd85adefdedd6a1fc85bc1c65a49..8f2f1ee7fae2288f0cd44030952d858ef2cb1bed 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -317,7 +317,7 @@ _CONNECT: sprintf(detail, "user:%s, from:%s, connType%d", connReq.user, obj, connReq.connType); - auditRecord(pReq, "login", connReq.app, obj, detail); + auditRecord(pReq, "login", connReq.app, obj, strlen(detail), detail); _OVER: diff --git a/source/dnode/mnode/impl/src/mndQnode.c b/source/dnode/mnode/impl/src/mndQnode.c index 5ec81440bbb0fa90c0e858b1b2381e0fcd6b4487..fee8f595e2069a78fcc470d072b9caa8abe1491e 100644 --- a/source/dnode/mnode/impl/src/mndQnode.c +++ b/source/dnode/mnode/impl/src/mndQnode.c @@ -20,6 +20,7 @@ #include "mndShow.h" #include "mndTrans.h" #include "mndUser.h" +#include "audit.h" #define QNODE_VER_NUMBER 1 #define QNODE_RESERVE_SIZE 64 @@ -306,6 +307,10 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) { code = mndCreateQnode(pMnode, pReq, pDnode, &createReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; + char obj[33] = {0}; + sprintf(obj, "%d", createReq.dnodeId); + + auditRecord(pReq, "createQnode", obj, "", createReq.sqlLen, createReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { mError("qnode:%d, failed to create since %s", createReq.dnodeId, terrstr()); @@ -415,6 +420,11 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) { code = mndDropQnode(pMnode, pReq, pObj); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; + char obj[33] = {0}; + sprintf(obj, "%d", dropReq.dnodeId); + + auditRecord(pReq, "createQnode", obj, "", dropReq.sqlLen, dropReq.sql); + _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { mError("qnode:%d, failed to drop since %s", dropReq.dnodeId, terrstr()); diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 3589b4525a4f20d604fa18a564bf4c372b7713c3..8cd4ef86e184eb9d89ab751c64333522248da9c1 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1134,11 +1134,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) { } if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - sprintf(detail, "dbname:%s, stable:%s, igExists:%d, ttl:%d", - pDb->name, createReq.name, createReq.igExists, createReq.ttl); - - auditRecord(pReq, "createStb", pDb->name, createReq.name, detail); + auditRecord(pReq, "createStb", pDb->name, createReq.name, createReq.sqlLen, createReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -2208,11 +2204,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) { code = mndAlterStb(pMnode, pReq, &alterReq, pDb, pStb); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - sprintf(detail, "dbname:%s, stable:%s, alterType:%d, ttl:%d", - pDb->name, alterReq.name, alterReq.alterType, alterReq.ttl); - - auditRecord(pReq, "alterStb", pDb->name, alterReq.name, detail); + auditRecord(pReq, "alterStb", pDb->name, alterReq.name, alterReq.sqlLen, alterReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -2474,11 +2466,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) { code = mndDropStb(pMnode, pReq, pDb, pStb); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - sprintf(detail, "dbname:%s, stable:%s, igNotExists:%d", - pDb->name, dropReq.name, dropReq.igNotExists); - - auditRecord(pReq, "dropStb", pDb->name, dropReq.name, detail); + auditRecord(pReq, "dropStb", pDb->name, dropReq.name, dropReq.sqlLen, dropReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 347722284e2f0b24aad1dca89ac16c2f8d675a2a..df2af2262577e8bbabe1d159ce1fc5f380ef9c63 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -829,11 +829,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) { code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - sprintf(detail, "name:%s, igExists:%d", - createStreamReq.name, createStreamReq.igExists); - - auditRecord(pReq, "createStream", createStreamReq.name, "", detail); + auditRecord(pReq, "createStream", createStreamReq.name, "", createStreamReq.sqlLen, createStreamReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -1080,11 +1076,7 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { return -1; } - char detail[1000] = {0}; - sprintf(detail, "name:%s, igNotExists:%d", - dropReq.name, dropReq.igNotExists); - - auditRecord(pReq, "dropStream", dropReq.name, "", detail); + auditRecord(pReq, "dropStream", dropReq.name, "", dropReq.sqlLen, dropReq.sql); sdbRelease(pMnode->pSdb, pStream); mndTransDrop(pTrans); diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 25f7a7d9ada0865645749b1e783e68ff8a48ce65..1e1cf21b1f1b4eaea4efa0fa1aca0d88c7ee34da 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -622,11 +622,8 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) { code = TSDB_CODE_ACTION_IN_PROGRESS; } - char detail[1000] = {0}; - sprintf(detail, "subDbName:%s, subStbName:%s", - createTopicReq.subDbName, createTopicReq.subStbName); - - auditRecord(pReq, "crateTopic", createTopicReq.name, createTopicReq.subDbName, detail); + auditRecord(pReq, "crateTopic", createTopicReq.name, createTopicReq.subDbName, + createTopicReq.sqlLen, createTopicReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -819,11 +816,7 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) { return -1; } - char detail[1000] = {0}; - sprintf(detail, "name:%s, igNotExists:%d", - dropReq.name, dropReq.igNotExists); - - auditRecord(pReq, "dropTopic", dropReq.name, "", detail); + auditRecord(pReq, "dropTopic", dropReq.name, "", dropReq.sqlLen, dropReq.sql); return TSDB_CODE_ACTION_IN_PROGRESS; } diff --git a/source/dnode/mnode/impl/src/mndUser.c b/source/dnode/mnode/impl/src/mndUser.c index 735e4866e234aab5fe650cf854ab061f227088de..a46f664c855729877c48115d02e6f0615139fb2e 100644 --- a/source/dnode/mnode/impl/src/mndUser.c +++ b/source/dnode/mnode/impl/src/mndUser.c @@ -656,11 +656,7 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) { code = mndCreateUser(pMnode, pOperUser->acct, &createReq, pReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - sprintf(detail, "user:%s, createType:%d", - createReq.user, createReq.createType); - - auditRecord(pReq, "createUser", createReq.user, "", detail); + auditRecord(pReq, "createUser", createReq.user, "", createReq.sqlLen, createReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -977,11 +973,26 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) { code = mndAlterUser(pMnode, pUser, &newUser, pReq); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - char detail[1000] = {0}; - sprintf(detail, "user:%s, objname:%s, alterType:%d", - alterReq.user, alterReq.objname, alterReq.alterType); - - auditRecord(pReq, "alterUser", alterReq.user, alterReq.objname, detail); + if(alterReq.alterType == TSDB_ALTER_USER_PASSWD){ + auditRecord(pReq, "changePassword", alterReq.user, alterReq.objname, 0, ""); + } + else if(alterReq.alterType == TSDB_ALTER_USER_SUPERUSER || + alterReq.alterType == TSDB_ALTER_USER_ENABLE || + alterReq.alterType == TSDB_ALTER_USER_SYSINFO){ + auditRecord(pReq, "alterUser", alterReq.user, alterReq.objname, alterReq.sqlLen, alterReq.sql); + } + else if(alterReq.alterType == TSDB_ALTER_USER_ADD_READ_DB|| + alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_DB|| + alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_DB|| + alterReq.alterType == TSDB_ALTER_USER_ADD_SUBSCRIBE_TOPIC|| + alterReq.alterType == TSDB_ALTER_USER_ADD_READ_TABLE|| + alterReq.alterType == TSDB_ALTER_USER_ADD_WRITE_TABLE|| + alterReq.alterType == TSDB_ALTER_USER_ADD_ALL_TABLE){ + auditRecord(pReq, "GrantPrivileges", alterReq.user, alterReq.objname, alterReq.sqlLen, alterReq.sql); + } + else{ + auditRecord(pReq, "RevokePrivileges", alterReq.user, alterReq.objname, alterReq.sqlLen, alterReq.sql); + } _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { @@ -1052,7 +1063,7 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) { code = mndDropUser(pMnode, pReq, pUser); if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; - auditRecord(pReq, "dropUser", dropReq.user, "", ""); + auditRecord(pReq, "dropUser", dropReq.user, "", dropReq.sqlLen, dropReq.sql); _OVER: if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index bdc104b4fdf5e0d7332bf1863ecc8f14ae31034a..9e69281f1a02c9c86b538eddc1a074e75e4fed23 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -860,7 +860,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq, taosArrayPush(rsp.pArray, &cRsp); - auditRecord(pReq, "createTable", pVnode->config.dbname, pCreateReq->name, "detail"); + auditRecord(pReq, "createTable", pVnode->config.dbname, pCreateReq->name, pCreateReq->sqlLen, pCreateReq->sql); } vDebug("vgId:%d, add %d new created tables into query table list", TD_VID(pVnode), (int32_t)taosArrayGetSize(tbUids));