un-hard-coded-username/password
This commit is contained in:
parent
068cf10863
commit
e6df815118
|
@ -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, tsDefaultUser);
|
||||
strcpy(cqCfg.pass, tsDefaultPass);
|
||||
cqCfg.vgId = 2;
|
||||
cqCfg.cqWrite = writeToQueue;
|
||||
|
||||
|
|
|
@ -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, tsDefaultUser, tsDefaultPass, 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, tsDefaultUser) == 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]);
|
||||
|
|
|
@ -25,6 +25,8 @@
|
|||
#include "mnodeSdb.h"
|
||||
#include "mnodeUser.h"
|
||||
|
||||
#include "tglobal.h"
|
||||
|
||||
void * tsAcctSdb = NULL;
|
||||
static int32_t tsAcctUpdateSize;
|
||||
static int32_t mnodeCreateRootAcct();
|
||||
|
@ -171,8 +173,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, tsDefaultUser);
|
||||
taosEncryptPass((uint8_t*)tsDefaultPass, strlen(tsDefaultPass), pAcct->pass);
|
||||
pAcct->cfg = (SAcctCfg){
|
||||
.maxUsers = 10,
|
||||
.maxDbs = 64,
|
||||
|
@ -204,4 +206,4 @@ int32_t acctInit() { return TSDB_CODE_SUCCESS; }
|
|||
void acctCleanUp() {}
|
||||
int32_t acctCheck(void *pAcct, EAcctGrantType type) { return TSDB_CODE_SUCCESS; }
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -472,7 +472,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, tsDefaultUser) == 0) {
|
||||
#endif
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
|
@ -484,7 +484,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, tsDefaultUser) == 0) {
|
||||
#endif
|
||||
pShow->bytes[cols] = 2;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT;
|
||||
|
@ -508,7 +508,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, tsDefaultUser) == 0) {
|
||||
#endif
|
||||
pShow->bytes[cols] = 4;
|
||||
pSchema[cols].type = TSDB_DATA_TYPE_INT;
|
||||
|
@ -622,7 +622,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, tsDefaultUser) == 0) {
|
||||
#endif
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int32_t *)pWrite = pDb->numOfVgroups;
|
||||
|
@ -632,7 +632,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, tsDefaultUser) == 0) {
|
||||
#endif
|
||||
pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows;
|
||||
*(int16_t *)pWrite = pDb->cfg.replications;
|
||||
|
@ -653,7 +653,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, tsDefaultUser) == 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
|
||||
|
|
|
@ -250,7 +250,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, tsDefaultUser) != 0) {
|
||||
return TSDB_CODE_MND_NO_RIGHTS;
|
||||
}
|
||||
|
||||
|
@ -447,7 +447,7 @@ static int32_t mnodeDropDnodeByEp(char *ep) {
|
|||
static int32_t mnodeProcessCreateDnodeMsg(SMnodeMsg *pMsg) {
|
||||
SCMCreateDnodeMsg *pCreate = pMsg->rpcMsg.pCont;
|
||||
|
||||
if (strcmp(pMsg->pUser->user, "root") != 0) {
|
||||
if (strcmp(pMsg->pUser->user, tsDefaultUser) != 0) {
|
||||
return TSDB_CODE_MND_NO_RIGHTS;
|
||||
} else {
|
||||
int32_t code = mnodeCreateDnode(pCreate->ep);
|
||||
|
@ -467,7 +467,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, tsDefaultUser) != 0) {
|
||||
return TSDB_CODE_MND_NO_RIGHTS;
|
||||
} else {
|
||||
int32_t code = mnodeDropDnodeByEp(pDrop->ep);
|
||||
|
@ -486,7 +486,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, tsDefaultUser) != 0) {
|
||||
mnodeDecUserRef(pUser);
|
||||
return TSDB_CODE_MND_NO_RIGHTS;
|
||||
}
|
||||
|
@ -615,7 +615,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, tsDefaultUser) != 0) {
|
||||
mnodeDecUserRef(pUser);
|
||||
return TSDB_CODE_MND_NO_RIGHTS;
|
||||
}
|
||||
|
@ -725,7 +725,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, tsDefaultUser) != 0) {
|
||||
mnodeDecUserRef(pUser);
|
||||
return TSDB_CODE_MND_NO_RIGHTS;
|
||||
}
|
||||
|
@ -812,7 +812,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, tsDefaultUser) != 0) {
|
||||
mnodeDecUserRef(pUser);
|
||||
return TSDB_CODE_MND_NO_RIGHTS;
|
||||
}
|
||||
|
|
|
@ -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, tsDefaultUser) != 0) {
|
||||
mnodeDecUserRef(pUser);
|
||||
return TSDB_CODE_MND_NO_RIGHTS;
|
||||
}
|
||||
|
|
|
@ -168,7 +168,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, tsDefaultUser) != 0) return TSDB_CODE_MND_NO_RIGHTS;
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->schema;
|
||||
|
@ -282,7 +282,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, tsDefaultUser) != 0) return TSDB_CODE_MND_NO_RIGHTS;
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->schema;
|
||||
|
@ -391,7 +391,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, tsDefaultUser) != 0) return TSDB_CODE_MND_NO_RIGHTS;
|
||||
|
||||
int32_t cols = 0;
|
||||
SSchema *pSchema = pMeta->schema;
|
||||
|
@ -519,7 +519,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, tsDefaultUser) != 0) return TSDB_CODE_MND_NO_RIGHTS;
|
||||
|
||||
SCMKillQueryMsg *pKill = pMsg->rpcMsg.pCont;
|
||||
mPrint("kill query msg is received, queryId:%s", pKill->queryId);
|
||||
|
@ -549,7 +549,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, tsDefaultUser) != 0) return TSDB_CODE_MND_NO_RIGHTS;
|
||||
|
||||
SCMKillQueryMsg *pKill = pMsg->rpcMsg.pCont;
|
||||
mPrint("kill stream msg is received, streamId:%s", pKill->queryId);
|
||||
|
@ -579,7 +579,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, tsDefaultUser) != 0) return TSDB_CODE_MND_NO_RIGHTS;
|
||||
|
||||
SCMKillConnMsg *pKill = pMsg->rpcMsg.pCont;
|
||||
SConnObj * pConn = taosCacheAcquireByName(tsMnodeConnCache, pKill->queryId);
|
||||
|
|
|
@ -103,8 +103,8 @@ static int32_t mnodeUserActionDecode(SSdbOper *pOper) {
|
|||
|
||||
static int32_t mnodeUserActionRestored() {
|
||||
if (dnodeIsFirstDeploy()) {
|
||||
SAcctObj *pAcct = mnodeGetAcct("root");
|
||||
mnodeCreateUser(pAcct, "root", "taosdata");
|
||||
SAcctObj *pAcct = mnodeGetAcct(tsDefaultUser);
|
||||
mnodeCreateUser(pAcct, tsDefaultUser, tsDefaultPass);
|
||||
mnodeCreateUser(pAcct, "monitor", tsInternalPass);
|
||||
mnodeCreateUser(pAcct, "_root", tsInternalPass);
|
||||
mnodeDecAcctRef(pAcct);
|
||||
|
@ -218,7 +218,7 @@ int32_t mnodeCreateUser(SAcctObj *pAcct, char *name, char *pass) {
|
|||
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, tsDefaultUser) == 0 || strcmp(pUser->user, pUser->acct) == 0) {
|
||||
pUser->superAuth = 1;
|
||||
}
|
||||
|
||||
|
@ -392,12 +392,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, tsDefaultUser) == 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, tsDefaultUser) == 0) {
|
||||
hasRight = false;
|
||||
} else if (strcmp(pOperUser->acct, pUser->acct) != 0) {
|
||||
hasRight = false;
|
||||
|
@ -418,16 +418,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, tsDefaultUser) == 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, tsDefaultUser) == 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, tsDefaultUser) == 0) {
|
||||
hasRight = false;
|
||||
} else if (strcmp(pOperUser->acct, pUser->acct) != 0) {
|
||||
hasRight = false;
|
||||
|
@ -482,9 +482,9 @@ static int32_t mnodeProcessDropUserMsg(SMnodeMsg *pMsg) {
|
|||
}
|
||||
|
||||
bool hasRight = false;
|
||||
if (strcmp(pUser->user, "root") == 0) {
|
||||
if (strcmp(pUser->user, tsDefaultUser) == 0) {
|
||||
hasRight = false;
|
||||
} else if (strcmp(pOperUser->user, "root") == 0) {
|
||||
} else if (strcmp(pOperUser->user, tsDefaultUser) == 0) {
|
||||
hasRight = true;
|
||||
} else if (strcmp(pUser->user, pOperUser->user) == 0) {
|
||||
hasRight = false;
|
||||
|
|
|
@ -177,8 +177,8 @@ static void dnodeBuildMonitorSql(char *sql, int32_t cmd) {
|
|||
") tags (acctId binary(%d))",
|
||||
tsMonitorDbName, TSDB_USER_LEN + 1);
|
||||
} 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, tsDefaultUser,
|
||||
tsMonitorDbName, tsDefaultUser);
|
||||
} else if (cmd == MONITOR_CMD_CREATE_TB_SLOWQUERY) {
|
||||
snprintf(sql, SQL_LENGTH,
|
||||
"create table if not exists %s.slowquery(ts timestamp, username "
|
||||
|
|
Loading…
Reference in New Issue