diff --git a/src/client/src/TSDBJNIConnector.c b/src/client/src/TSDBJNIConnector.c index 9530bc26b4c8e5f33aa8c576dc1ffef1c9f85697..1a4ad8f050057be6e5b6d26a61720a615b84d1c7 100644 --- a/src/client/src/TSDBJNIConnector.c +++ b/src/client/src/TSDBJNIConnector.c @@ -227,12 +227,12 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn } if (user == NULL) { - jniTrace("jobj:%p, user is null, use tsDefaultUser", jobj); - user = tsDefaultUser; + jniTrace("jobj:%p, user is null, use default user %s", jobj, TSDB_DEFAULT_USER); + user = TSDB_DEFAULT_USER; } if (pass == NULL) { - jniTrace("jobj:%p, pass is null, use tsDefaultPass", jobj); - pass = tsDefaultPass; + jniTrace("jobj:%p, pass is null, use default password", jobj); + pass = TSDB_DEFAULT_PASS; } /* @@ -252,8 +252,8 @@ JNIEXPORT jlong JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_connectImp(JNIEn if (host != NULL) (*env)->ReleaseStringUTFChars(env, jhost, host); if (dbname != NULL) (*env)->ReleaseStringUTFChars(env, jdbName, dbname); - if (user != NULL && user != tsDefaultUser) (*env)->ReleaseStringUTFChars(env, juser, user); - if (pass != NULL && pass != tsDefaultPass) (*env)->ReleaseStringUTFChars(env, jpass, pass); + if (user != NULL && user != (const char *)TSDB_DEFAULT_USER) (*env)->ReleaseStringUTFChars(env, juser, user); + if (pass != NULL && pass != (const char *)TSDB_DEFAULT_PASS) (*env)->ReleaseStringUTFChars(env, jpass, pass); return ret; } diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index eaceea468b4d2d5020e11e19b1d7e8b67cbf915c..980635588ee537702287073bcf8c8e361f5e221b 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -92,10 +92,6 @@ extern int32_t tsNumOfMnodes; extern int32_t tsMaxShellConns; extern int32_t tsMaxTables; -extern char tsDefaultDB[]; -extern char tsDefaultUser[]; -extern char tsDefaultPass[]; - extern char tsMqttBrokerAddress[]; extern char tsMqttBrokerClientId[]; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index e80597ca954652abd450f20738be0ecca849a04a..2ed6ef3ab7a77ea3f6bc6def2d8456828c6ef1c5 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -109,10 +109,6 @@ int32_t tsReplications = TSDB_DEFAULT_REPLICA_NUM; int16_t tsAffectedRowsMod = 0; int32_t tsNumOfMnodes = 3; int32_t tsMaxShellConns = 5000; - -char tsDefaultDB[TSDB_DB_NAME_LEN] = {0}; -char tsDefaultUser[64] = "root"; -char tsDefaultPass[64] = "taosdata"; int32_t tsMaxConnections = 5000; int32_t tsBalanceInterval = 300; // seconds @@ -713,37 +709,6 @@ static void doInitGlobalConfig() { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - // login configs - cfg.option = "defaultDB"; - cfg.ptr = tsDefaultDB; - cfg.valType = TAOS_CFG_VTYPE_STRING; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; - cfg.minValue = 0; - cfg.maxValue = 0; - cfg.ptrLength = TSDB_DB_NAME_LEN - 1; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - - cfg.option = "defaultUser"; - cfg.ptr = tsDefaultUser; - cfg.valType = TAOS_CFG_VTYPE_STRING; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT; - cfg.minValue = 0; - cfg.maxValue = 0; - cfg.ptrLength = TSDB_USER_LEN - 1; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - - cfg.option = "defaultPass"; - cfg.ptr = tsDefaultPass; - cfg.valType = TAOS_CFG_VTYPE_STRING; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_CLIENT | TSDB_CFG_CTYPE_B_NOT_PRINT; - cfg.minValue = 0; - cfg.maxValue = 0; - cfg.ptrLength = TSDB_PASSWORD_LEN - 1; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - cfg.option = "mqttBrokerAddress"; cfg.ptr = tsMqttBrokerAddress; cfg.valType = TAOS_CFG_VTYPE_STRING; diff --git a/src/cq/test/cqtest.c b/src/cq/test/cqtest.c index 1416a591bec5e4ec61e7a4581db955e91feec2e8..d06f14d53fcc6e434401636ee91f6c9bd5a44e5e 100644 --- a/src/cq/test/cqtest.c +++ b/src/cq/test/cqtest.c @@ -48,8 +48,8 @@ int main(int argc, char *argv[]) { taosInitLog("cq.log", 100000, 10); SCqCfg cqCfg; - strcpy(cqCfg.user, "root"); - strcpy(cqCfg.pass, "taosdata"); + strcpy(cqCfg.user, TSDB_DEFAULT_USER); + strcpy(cqCfg.pass, TSDB_DEFAULT_PASS); cqCfg.vgId = 2; cqCfg.cqWrite = writeToQueue; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index 6de7f672913f7adb94ac2fc853b2596480e2a4cb..d8e21c159b08130dc8a4d3e35c0a438a72997391 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -83,6 +83,9 @@ extern const int32_t TYPE_BYTES[11]; #define TSDB_DATA_NULL_STR "NULL" #define TSDB_DATA_NULL_STR_L "null" +#define TSDB_DEFAULT_USER "root" +#define TSDB_DEFAULT_PASS "taosdata" + #define TSDB_TRUE 1 #define TSDB_FALSE 0 #define TSDB_OK 0 diff --git a/src/kit/shell/src/shellEngine.c b/src/kit/shell/src/shellEngine.c index 7705db4b27e252a01933950fd309bd7ca179a008..f2ba5201ba0c3b4d454dc9de047ccd0ceb4a6884 100644 --- a/src/kit/shell/src/shellEngine.c +++ b/src/kit/shell/src/shellEngine.c @@ -56,11 +56,11 @@ TAOS *shellInit(SShellArguments *args) { if (args->is_use_passwd) { if (args->password == NULL) args->password = getpass("Enter password: "); } else { - args->password = tsDefaultPass; + args->password = TSDB_DEFAULT_PASS; } if (args->user == NULL) { - args->user = tsDefaultUser; + args->user = TSDB_DEFAULT_USER; } taos_init(); diff --git a/src/kit/taosdemo/taosdemo.c b/src/kit/taosdemo/taosdemo.c index ab5781e74fc49da5c70d73ec5bc57f9808f4fb27..4a455271fff51e1bd9438ce01d044eee3760f6c2 100644 --- a/src/kit/taosdemo/taosdemo.c +++ b/src/kit/taosdemo/taosdemo.c @@ -306,7 +306,7 @@ double getCurrentTime(); void callBack(void *param, TAOS_RES *res, int code); int main(int argc, char *argv[]) { - SDemoArguments arguments = {NULL, // host + SDemoArguments arguments = { NULL, // host 0, // port "root", // user "taosdata", // password diff --git a/src/kit/taosdump/taosdump.c b/src/kit/taosdump/taosdump.c index ee792c51166b090dd8ea104120ae5fd105791948..0b881864f2253de5caeebbe501c9be440d5b262d 100644 --- a/src/kit/taosdump/taosdump.c +++ b/src/kit/taosdump/taosdump.c @@ -34,6 +34,8 @@ #include "taosdef.h" #include "tutil.h" +#include "tglobal.h" + #define COMMAND_SIZE 65536 #define DEFAULT_DUMP_FILE "taosdump.sql" @@ -324,7 +326,7 @@ void taosFreeDbInfos(); int main(int argc, char *argv[]) { SDumpArguments arguments = { // connection option - NULL, "root", "taosdata", 0, + NULL, TSDB_DEFAULT_USER, TSDB_DEFAULT_PASS, 0, // output file DEFAULT_DUMP_FILE, DEFAULT_DUMP_FILE, NULL, // dump unit option @@ -502,7 +504,7 @@ int taosDumpOut(SDumpArguments *arguments) { } strncpy(dbInfos[count]->name, (char *)row[TSDB_SHOW_DB_NAME_INDEX], fields[TSDB_SHOW_DB_NAME_INDEX].bytes); - if (strcmp(arguments->user, "root") == 0) { + if (strcmp(arguments->user, TSDB_DEFAULT_USER) == 0) { dbInfos[count]->replica = (int)(*((int16_t *)row[TSDB_SHOW_DB_REPLICA_INDEX])); dbInfos[count]->days = (int)(*((int16_t *)row[TSDB_SHOW_DB_DAYS_INDEX])); dbInfos[count]->keep = *((int *)row[TSDB_SHOW_DB_KEEP_INDEX]); diff --git a/src/mnode/src/mnodeAcct.c b/src/mnode/src/mnodeAcct.c index 3fcb3849aafa8221cd7c4450fd851e5dce2672f4..ad52a4c3acc2d89463d14df00d120711a767ffc2 100644 --- a/src/mnode/src/mnodeAcct.c +++ b/src/mnode/src/mnodeAcct.c @@ -25,6 +25,8 @@ #include "mnodeSdb.h" #include "mnodeUser.h" +#include "tglobal.h" + void * tsAcctSdb = NULL; static int32_t tsAcctUpdateSize; static int32_t mnodeCreateRootAcct(); @@ -174,8 +176,8 @@ static int32_t mnodeCreateRootAcct() { SAcctObj *pAcct = malloc(sizeof(SAcctObj)); memset(pAcct, 0, sizeof(SAcctObj)); - strcpy(pAcct->user, "root"); - taosEncryptPass((uint8_t*)"taosdata", strlen("taosdata"), pAcct->pass); + strcpy(pAcct->user, TSDB_DEFAULT_USER); + taosEncryptPass((uint8_t *)TSDB_DEFAULT_PASS, strlen(TSDB_DEFAULT_PASS), pAcct->pass); pAcct->cfg = (SAcctCfg){ .maxUsers = 10, .maxDbs = 64, @@ -207,4 +209,4 @@ int32_t acctInit() { return TSDB_CODE_SUCCESS; } void acctCleanUp() {} int32_t acctCheck(void *pAcct, EAcctGrantType type) { return TSDB_CODE_SUCCESS; } -#endif \ No newline at end of file +#endif diff --git a/src/mnode/src/mnodeDb.c b/src/mnode/src/mnodeDb.c index 081fe289542e42dbc8817b7fa0ad340eb34f9953..9709d7786aaa3f6e0f563bd85ed453679ce0c4f6 100644 --- a/src/mnode/src/mnodeDb.c +++ b/src/mnode/src/mnodeDb.c @@ -478,7 +478,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn cols++; #ifndef __CLOUD_VERSION__ - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { #endif pShow->bytes[cols] = 4; pSchema[cols].type = TSDB_DATA_TYPE_INT; @@ -490,7 +490,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn #endif #ifndef __CLOUD_VERSION__ - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { #endif pShow->bytes[cols] = 2; pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; @@ -514,7 +514,7 @@ static int32_t mnodeGetDbMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn cols++; #ifndef __CLOUD_VERSION__ - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { #endif pShow->bytes[cols] = 4; pSchema[cols].type = TSDB_DATA_TYPE_INT; @@ -628,7 +628,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void cols++; #ifndef __CLOUD_VERSION__ - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { #endif pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int32_t *)pWrite = pDb->numOfVgroups; @@ -638,7 +638,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void #endif #ifndef __CLOUD_VERSION__ - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { #endif pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int16_t *)pWrite = pDb->cfg.replications; @@ -659,7 +659,7 @@ static int32_t mnodeRetrieveDbs(SShowObj *pShow, char *data, int32_t rows, void cols++; #ifndef __CLOUD_VERSION__ - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { #endif pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int32_t *)pWrite = pDb->cfg.maxTables; // table num can be created should minus 1 diff --git a/src/mnode/src/mnodeDnode.c b/src/mnode/src/mnodeDnode.c index bd95b0cc515ca48d41330cbcaa77264132d43c52..e3ea08aeceb34a20cdd1e3df9122d9dc7f4f918f 100644 --- a/src/mnode/src/mnodeDnode.c +++ b/src/mnode/src/mnodeDnode.c @@ -254,7 +254,7 @@ static int32_t mnodeProcessCfgDnodeMsg(SMnodeMsg *pMsg) { // TODO temporary disabled for compiling: strcpy(pCmCfgDnode->ep, pCmCfgDnode->ep); } - if (strcmp(pMsg->pUser->user, "root") != 0) { + if (strcmp(pMsg->pUser->user, TSDB_DEFAULT_USER) != 0) { return TSDB_CODE_MND_NO_RIGHTS; } @@ -480,7 +480,7 @@ static int32_t mnodeDropDnodeByEp(char *ep, SMnodeMsg *pMsg) { static int32_t mnodeProcessCreateDnodeMsg(SMnodeMsg *pMsg) { SCMCreateDnodeMsg *pCreate = pMsg->rpcMsg.pCont; - if (strcmp(pMsg->pUser->user, "root") != 0) { + if (strcmp(pMsg->pUser->user, TSDB_DEFAULT_USER) != 0) { return TSDB_CODE_MND_NO_RIGHTS; } else { return mnodeCreateDnode(pCreate->ep, pMsg); @@ -490,7 +490,7 @@ static int32_t mnodeProcessCreateDnodeMsg(SMnodeMsg *pMsg) { static int32_t mnodeProcessDropDnodeMsg(SMnodeMsg *pMsg) { SCMDropDnodeMsg *pDrop = pMsg->rpcMsg.pCont; - if (strcmp(pMsg->pUser->user, "root") != 0) { + if (strcmp(pMsg->pUser->user, TSDB_DEFAULT_USER) != 0) { return TSDB_CODE_MND_NO_RIGHTS; } else { return mnodeDropDnodeByEp(pDrop->ep, pMsg); @@ -501,7 +501,7 @@ static int32_t mnodeGetDnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC SUserObj *pUser = mnodeGetUserFromConn(pConn); if (pUser == NULL) return 0; - if (strcmp(pUser->pAcct->user, "root") != 0) { + if (strcmp(pUser->pAcct->user, TSDB_DEFAULT_USER) != 0) { mnodeDecUserRef(pUser); return TSDB_CODE_MND_NO_RIGHTS; } @@ -630,7 +630,7 @@ static int32_t mnodeGetModuleMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p SUserObj *pUser = mnodeGetUserFromConn(pConn); if (pUser == NULL) return 0; - if (strcmp(pUser->user, "root") != 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) { mnodeDecUserRef(pUser); return TSDB_CODE_MND_NO_RIGHTS; } @@ -740,7 +740,7 @@ static int32_t mnodeGetConfigMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *p SUserObj *pUser = mnodeGetUserFromConn(pConn); if (pUser == NULL) return 0; - if (strcmp(pUser->user, "root") != 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) { mnodeDecUserRef(pUser); return TSDB_CODE_MND_NO_RIGHTS; } @@ -827,7 +827,7 @@ static int32_t mnodeGetVnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC SUserObj *pUser = mnodeGetUserFromConn(pConn); if (pUser == NULL) return 0; - if (strcmp(pUser->user, "root") != 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) { mnodeDecUserRef(pUser); return TSDB_CODE_MND_NO_RIGHTS; } diff --git a/src/mnode/src/mnodeMnode.c b/src/mnode/src/mnodeMnode.c index 41bd6974dbe9eb422b3b72ec650bf06b995276df..219fb0b0a3b1e33292a55fc866e0982078e18469 100644 --- a/src/mnode/src/mnodeMnode.c +++ b/src/mnode/src/mnodeMnode.c @@ -31,6 +31,8 @@ #include "mnodeShow.h" #include "mnodeUser.h" +#include "tglobal.h" + static void * tsMnodeSdb = NULL; static int32_t tsMnodeUpdateSize = 0; static SRpcIpSet tsMnodeIpSetForShell; @@ -333,7 +335,7 @@ static int32_t mnodeGetMnodeMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pC SUserObj *pUser = mnodeGetUserFromConn(pConn); if (pUser == NULL) return 0; - if (strcmp(pUser->pAcct->user, "root") != 0) { + if (strcmp(pUser->pAcct->user, TSDB_DEFAULT_USER) != 0) { mnodeDecUserRef(pUser); return TSDB_CODE_MND_NO_RIGHTS; } diff --git a/src/mnode/src/mnodeProfile.c b/src/mnode/src/mnodeProfile.c index d035f19b6ff6d0168471fb57da5ab0b560835cc9..2a895c9496f1c5243770099285eea1fce27b1ed2 100644 --- a/src/mnode/src/mnodeProfile.c +++ b/src/mnode/src/mnodeProfile.c @@ -169,7 +169,7 @@ static void *mnodeGetNextConn(SHashMutableIterator *pIter, SConnObj **pConn) { static int32_t mnodeGetConnsMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) { SUserObj *pUser = mnodeGetUserFromConn(pConn); if (pUser == NULL) return 0; - if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_MND_NO_RIGHTS; + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) return TSDB_CODE_MND_NO_RIGHTS; int32_t cols = 0; SSchema *pSchema = pMeta->schema; @@ -294,7 +294,7 @@ int32_t mnodeSaveQueryStreamList(SConnObj *pConn, SCMHeartBeatMsg *pHBMsg) { static int32_t mnodeGetQueryMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) { SUserObj *pUser = mnodeGetUserFromConn(pConn); if (pUser == NULL) return 0; - if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_MND_NO_RIGHTS; + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) return TSDB_CODE_MND_NO_RIGHTS; int32_t cols = 0; SSchema *pSchema = pMeta->schema; @@ -403,7 +403,7 @@ static int32_t mnodeRetrieveQueries(SShowObj *pShow, char *data, int32_t rows, v static int32_t mnodeGetStreamMeta(STableMetaMsg *pMeta, SShowObj *pShow, void *pConn) { SUserObj *pUser = mnodeGetUserFromConn(pConn); if (pUser == NULL) return 0; - if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_MND_NO_RIGHTS; + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) return TSDB_CODE_MND_NO_RIGHTS; int32_t cols = 0; SSchema *pSchema = pMeta->schema; @@ -531,7 +531,7 @@ static int32_t mnodeRetrieveStreams(SShowObj *pShow, char *data, int32_t rows, v static int32_t mnodeProcessKillQueryMsg(SMnodeMsg *pMsg) { SUserObj *pUser = pMsg->pUser; - if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_MND_NO_RIGHTS; + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) return TSDB_CODE_MND_NO_RIGHTS; SCMKillQueryMsg *pKill = pMsg->rpcMsg.pCont; mPrint("kill query msg is received, queryId:%s", pKill->queryId); @@ -561,7 +561,7 @@ static int32_t mnodeProcessKillQueryMsg(SMnodeMsg *pMsg) { static int32_t mnodeProcessKillStreamMsg(SMnodeMsg *pMsg) { SUserObj *pUser = pMsg->pUser; - if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_MND_NO_RIGHTS; + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) return TSDB_CODE_MND_NO_RIGHTS; SCMKillQueryMsg *pKill = pMsg->rpcMsg.pCont; mPrint("kill stream msg is received, streamId:%s", pKill->queryId); @@ -591,7 +591,7 @@ static int32_t mnodeProcessKillStreamMsg(SMnodeMsg *pMsg) { static int32_t mnodeProcessKillConnectionMsg(SMnodeMsg *pMsg) { SUserObj *pUser = pMsg->pUser; - if (strcmp(pUser->user, "root") != 0) return TSDB_CODE_MND_NO_RIGHTS; + if (strcmp(pUser->user, TSDB_DEFAULT_USER) != 0) return TSDB_CODE_MND_NO_RIGHTS; SCMKillConnMsg *pKill = pMsg->rpcMsg.pCont; SConnObj * pConn = taosCacheAcquireByName(tsMnodeConnCache, pKill->queryId); diff --git a/src/mnode/src/mnodeUser.c b/src/mnode/src/mnodeUser.c index 07de4cf6411e2f459ee17103a81fb9c72842bbef..b559116e585001e70e3081a9d669f81ae34962ea 100644 --- a/src/mnode/src/mnodeUser.c +++ b/src/mnode/src/mnodeUser.c @@ -105,10 +105,10 @@ static int32_t mnodeUserActionRestored() { int32_t numOfRows = sdbGetNumOfRows(tsUserSdb); if (numOfRows <= 0 && dnodeIsFirstDeploy()) { mPrint("dnode first deploy, create root user"); - SAcctObj *pAcct = mnodeGetAcct("root"); - mnodeCreateUser(pAcct, "root", "taosdata", NULL); + SAcctObj *pAcct = mnodeGetAcct(TSDB_DEFAULT_USER); + mnodeCreateUser(pAcct, TSDB_DEFAULT_USER, TSDB_DEFAULT_PASS, NULL); mnodeCreateUser(pAcct, "monitor", tsInternalPass, NULL); - mnodeCreateUser(pAcct, "_root", tsInternalPass, NULL); + mnodeCreateUser(pAcct, "_"TSDB_DEFAULT_USER, tsInternalPass, NULL); mnodeDecAcctRef(pAcct); } @@ -222,7 +222,7 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass, void *pMsg) { pUser->createdTime = taosGetTimestampMs(); pUser->superAuth = 0; pUser->writeAuth = 1; - if (strcmp(pUser->user, "root") == 0 || strcmp(pUser->user, pUser->acct) == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0 || strcmp(pUser->user, pUser->acct) == 0) { pUser->superAuth = 1; } @@ -404,12 +404,12 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg) { if ((pAlter->flag & TSDB_ALTER_USER_PASSWD) != 0) { bool hasRight = false; - if (strcmp(pOperUser->user, "root") == 0) { + if (strcmp(pOperUser->user, TSDB_DEFAULT_USER) == 0) { hasRight = true; } else if (strcmp(pUser->user, pOperUser->user) == 0) { hasRight = true; } else if (pOperUser->superAuth) { - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { hasRight = false; } else if (strcmp(pOperUser->acct, pUser->acct) != 0) { hasRight = false; @@ -429,16 +429,16 @@ static int32_t mnodeProcessAlterUserMsg(SMnodeMsg *pMsg) { } else if ((pAlter->flag & TSDB_ALTER_USER_PRIVILEGES) != 0) { bool hasRight = false; - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { hasRight = false; } else if (strcmp(pUser->user, pUser->acct) == 0) { hasRight = false; - } else if (strcmp(pOperUser->user, "root") == 0) { + } else if (strcmp(pOperUser->user, TSDB_DEFAULT_USER) == 0) { hasRight = true; } else if (strcmp(pUser->user, pOperUser->user) == 0) { hasRight = false; } else if (pOperUser->superAuth) { - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { hasRight = false; } else if (strcmp(pOperUser->acct, pUser->acct) != 0) { hasRight = false; @@ -492,9 +492,9 @@ static int32_t mnodeProcessDropUserMsg(SMnodeMsg *pMsg) { } bool hasRight = false; - if (strcmp(pUser->user, "root") == 0) { + if (strcmp(pUser->user, TSDB_DEFAULT_USER) == 0) { hasRight = false; - } else if (strcmp(pOperUser->user, "root") == 0) { + } else if (strcmp(pOperUser->user, TSDB_DEFAULT_USER) == 0) { hasRight = true; } else if (strcmp(pUser->user, pOperUser->user) == 0) { hasRight = false; diff --git a/src/plugins/monitor/src/monitorMain.c b/src/plugins/monitor/src/monitorMain.c index feb03df35d716ad045c694764b4c3ab960a1eabb..4ea27f4839cad1608df01eeca0874ce5f35b1d69 100644 --- a/src/plugins/monitor/src/monitorMain.c +++ b/src/plugins/monitor/src/monitorMain.c @@ -177,8 +177,8 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) { ") tags (acctId binary(%d))", tsMonitorDbName, TSDB_USER_LEN); } else if (cmd == MONITOR_CMD_CREATE_TB_ACCT_ROOT) { - snprintf(sql, SQL_LENGTH, "create table if not exists %s.acct_%s using %s.acct tags('%s')", tsMonitorDbName, "root", - tsMonitorDbName, "root"); + snprintf(sql, SQL_LENGTH, "create table if not exists %s.acct_%s using %s.acct tags('%s')", tsMonitorDbName, TSDB_DEFAULT_USER, + tsMonitorDbName, TSDB_DEFAULT_USER); } else if (cmd == MONITOR_CMD_CREATE_TB_SLOWQUERY) { snprintf(sql, SQL_LENGTH, "create table if not exists %s.slowquery(ts timestamp, username " diff --git a/tests/test/c/importOneRow.c b/tests/test/c/importOneRow.c index 0690d8983786341c09d43ad1d69cf527e758203f..858926106c14afa6fb35bb66d44075c04add89f0 100644 --- a/tests/test/c/importOneRow.c +++ b/tests/test/c/importOneRow.c @@ -109,7 +109,7 @@ void* taos_execute(void *param) { taosGetFqdnPortFromEp(tsFirst, fqdn, &port); - void *taos = taos_connect(fqdn, tsDefaultUser, tsDefaultPass, NULL, port); + void *taos = taos_connect(fqdn, "root", "taosdata", NULL, port); if (taos == NULL) taos_error(taos); char sql[1024] = {0}; diff --git a/tests/test/c/importPerTable.c b/tests/test/c/importPerTable.c index 407a818fa5234e2f64c11ffcd4a5b4b75c574558..b4e8b6870342845ddcc75c2703fbe54119c423f8 100644 --- a/tests/test/c/importPerTable.c +++ b/tests/test/c/importPerTable.c @@ -73,7 +73,7 @@ void createDbAndTable() { taosGetFqdnPortFromEp(tsFirst, fqdn, &port); - con = taos_connect(fqdn, tsDefaultUser, tsDefaultPass, NULL, port); + con = taos_connect(fqdn, "root", "taosdata", NULL, port); if (con == NULL) { pError("failed to connect to DB, reason:%s", taos_errstr(con)); exit(1); @@ -200,7 +200,7 @@ void *syncTest(void *param) { taosGetFqdnPortFromEp(tsFirst, fqdn, &port); - con = taos_connect(fqdn, tsDefaultUser, tsDefaultPass, NULL, port); + con = taos_connect(fqdn, "root", "taosdata", NULL, port); if (con == NULL) { pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con)); exit(1); diff --git a/tests/test/c/insertPerRow.c b/tests/test/c/insertPerRow.c index 7a97b21e0a7fb6077cd09ac6dab98115f0e1e476..9b71ce50dd60fa8dddb7579d9f8a052b812d7b13 100644 --- a/tests/test/c/insertPerRow.c +++ b/tests/test/c/insertPerRow.c @@ -71,7 +71,7 @@ void createDbAndTable() { char fqdn[TSDB_FQDN_LEN]; uint16_t port; taosGetFqdnPortFromEp(tsFirst, fqdn, &port); - con = taos_connect(fqdn, tsDefaultUser, tsDefaultPass, NULL, port); + con = taos_connect(fqdn, "root", "taosdata", NULL, port); if (con == NULL) { pError("failed to connect to DB, reason:%s", taos_errstr(con)); exit(1); @@ -184,7 +184,7 @@ void *syncTest(void *param) { uint16_t port; taosGetFqdnPortFromEp(tsFirst, fqdn, &port); - con = taos_connect(fqdn, tsDefaultUser, tsDefaultPass, NULL, port); + con = taos_connect(fqdn, "root", "taosdata", NULL, port); if (con == NULL) { pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con)); exit(1); diff --git a/tests/test/c/insertPerTable.c b/tests/test/c/insertPerTable.c index 00e12566867dc2745df629c7db9b3ecb707275d3..a5e2c4b966b99734c9137a11c8e410ad76d27ce4 100644 --- a/tests/test/c/insertPerTable.c +++ b/tests/test/c/insertPerTable.c @@ -74,7 +74,7 @@ void createDbAndTable() { taosGetFqdnPortFromEp(tsFirst, fqdn, &port); - con = taos_connect(fqdn, tsDefaultUser, tsDefaultPass, NULL, port); + con = taos_connect(fqdn, "root", "taosdata", NULL, port); if (con == NULL) { pError("failed to connect to DB, reason:%s", taos_errstr(con)); exit(1); @@ -222,7 +222,7 @@ void *syncTest(void *param) { taosGetFqdnPortFromEp(tsFirst, fqdn, &port); - con = taos_connect(fqdn, tsDefaultUser, tsDefaultPass, NULL, port); + con = taos_connect(fqdn, "root", "taosdata", NULL, port); if (con == NULL) { pError("index:%d, failed to connect to DB, reason:%s", pInfo->threadIndex, taos_errstr(con)); exit(1); diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index f13e861907a8b4701b3556960b0797469f9d4bcc..aba9714f0acb38916be25640009aba54af9881c9 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -612,7 +612,7 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) { } bool simCreateTaosdConnect(SScript *script, char *rest) { - char *user = tsDefaultUser; + char *user = TSDB_DEFAULT_USER; char *token; int tokenLen; rest = paGetToken(rest, &token, &tokenLen); @@ -622,9 +622,9 @@ bool simCreateTaosdConnect(SScript *script, char *rest) { } if (simAsyncQuery) { - return simCreateRestFulConnect(script, user, tsDefaultPass); + return simCreateRestFulConnect(script, user, TSDB_DEFAULT_PASS); } else { - return simCreateNativeConnect(script, user, tsDefaultPass); + return simCreateNativeConnect(script, user, TSDB_DEFAULT_PASS); } }