feat/TS-5927-long-password-fix-case
This commit is contained in:
parent
70686226d8
commit
8f2370f3fa
|
@ -1706,15 +1706,10 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
|
|||
int32_t lino = 0;
|
||||
SUserObj userObj = {0};
|
||||
|
||||
if (pCreate->isImport != 1) {
|
||||
if (pCreate->passIsMd5 == 1) {
|
||||
memcpy(userObj.pass, pCreate->pass, TSDB_PASSWORD_LEN);
|
||||
} else {
|
||||
taosEncryptPass_c((uint8_t *)pCreate->pass, strlen(pCreate->pass), userObj.pass);
|
||||
}
|
||||
} else {
|
||||
// mInfo("pCreate->pass:%s", pCreate->eass)
|
||||
if (pCreate->passIsMd5 == 1) {
|
||||
memcpy(userObj.pass, pCreate->pass, TSDB_PASSWORD_LEN);
|
||||
} else {
|
||||
taosEncryptPass_c((uint8_t *)pCreate->pass, strlen(pCreate->pass), userObj.pass);
|
||||
}
|
||||
|
||||
tstrncpy(userObj.user, pCreate->user, TSDB_USER_LEN);
|
||||
|
|
|
@ -254,7 +254,7 @@ SNode* createShowDnodeVariablesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SN
|
|||
SNode* createShowVnodesStmt(SAstCreateContext* pCxt, SNode* pDnodeId, SNode* pDnodeEndpoint);
|
||||
SNode* createShowTableTagsStmt(SAstCreateContext* pCxt, SNode* pTbName, SNode* pDbName, SNodeList* pTags);
|
||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo,
|
||||
int8_t createdb, int8_t is_import);
|
||||
int8_t is_import, int8_t createdb);
|
||||
SNode* addCreateUserStmtWhiteList(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pIpRangesNodeList);
|
||||
SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, void* pAlterInfo);
|
||||
SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName);
|
||||
|
|
|
@ -164,6 +164,21 @@ static bool checkPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken,
|
|||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||
}
|
||||
|
||||
static bool checkImportPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken, char* pPassword) {
|
||||
if (NULL == pPasswordToken) {
|
||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||
} else if (pPasswordToken->n > (32 + 2)) {
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||
} else {
|
||||
strncpy(pPassword, pPasswordToken->z, pPasswordToken->n);
|
||||
(void)strdequote(pPassword);
|
||||
if (strtrim(pPassword) < 32) {
|
||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_PASSWD_TOO_SHORT_OR_EMPTY);
|
||||
}
|
||||
}
|
||||
return TSDB_CODE_SUCCESS == pCxt->errCode;
|
||||
}
|
||||
|
||||
static int32_t parsePort(SAstCreateContext* pCxt, const char* p, int32_t* pPort) {
|
||||
*pPort = taosStr2Int32(p, NULL, 10);
|
||||
if (*pPort >= UINT16_MAX || *pPort <= 0) {
|
||||
|
@ -3068,11 +3083,15 @@ _err:
|
|||
}
|
||||
|
||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo,
|
||||
int8_t createDb, int8_t is_import) {
|
||||
int8_t is_import, int8_t createDb) {
|
||||
CHECK_PARSER_STATUS(pCxt);
|
||||
char password[TSDB_USET_PASSWORD_LONGLEN + 3] = {0};
|
||||
CHECK_NAME(checkUserName(pCxt, pUserName));
|
||||
CHECK_NAME(checkPassword(pCxt, pPassword, password));
|
||||
if (is_import == 0) {
|
||||
CHECK_NAME(checkPassword(pCxt, pPassword, password));
|
||||
} else {
|
||||
CHECK_NAME(checkImportPassword(pCxt, pPassword, password));
|
||||
}
|
||||
SCreateUserStmt* pStmt = NULL;
|
||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_CREATE_USER_STMT, (SNode**)&pStmt);
|
||||
CHECK_MAKE_NODE(pStmt);
|
||||
|
|
|
@ -10048,8 +10048,13 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
|
|||
createReq.isImport = pStmt->isImport;
|
||||
createReq.createDb = pStmt->createDb;
|
||||
|
||||
taosEncryptPass_c((uint8_t*)pStmt->password, strlen(pStmt->password), createReq.pass);
|
||||
createReq.passIsMd5 = 1;
|
||||
if(pStmt->isImport == 1){
|
||||
tstrncpy(createReq.pass, pStmt->password, TSDB_USET_PASSWORD_LEN);
|
||||
}
|
||||
else{
|
||||
taosEncryptPass_c((uint8_t*)pStmt->password, strlen(pStmt->password), createReq.pass);
|
||||
createReq.passIsMd5 = 1;
|
||||
}
|
||||
|
||||
createReq.numIpRanges = pStmt->numIpRanges;
|
||||
if (pStmt->numIpRanges > 0) {
|
||||
|
|
|
@ -273,9 +273,9 @@ sql create user u27 pass 'taosdata1.'
|
|||
|
||||
sql CREATE USER `_xTest1` PASS '2729c41a99b2c5222aa7dd9fc1ce3de7' SYSINFO 1 CREATEDB 0 IS_IMPORT 1 HOST '127.0.0.1';
|
||||
sql_error CREATE USER `_xTest2` PASS '2729c41a99b2c5222aa7dd9fc1ce3de7' SYSINFO 1 CREATEDB 0 IS_IMPORT 0 HOST '127.0.0.1';
|
||||
sql CREATE USER `_xTest3` PASS '2729c41' SYSINFO 1 CREATEDB 0 IS_IMPORT 1 HOST '127.0.0.1';
|
||||
sql_error CREATE USER `_xTest3` PASS '2729c41' SYSINFO 1 CREATEDB 0 IS_IMPORT 1 HOST '127.0.0.1';
|
||||
sql_error CREATE USER `_xTest4` PASS '2729c417' SYSINFO 1 CREATEDB 0 IS_IMPORT 0 HOST '127.0.0.1';
|
||||
sql CREATE USER `_xTest5` PASS '2xF' SYSINFO 1 CREATEDB 0 IS_IMPORT 1 HOST '127.0.0.1';
|
||||
sql_error CREATE USER `_xTest5` PASS '2xF' SYSINFO 1 CREATEDB 0 IS_IMPORT 1 HOST '127.0.0.1';
|
||||
sql_error CREATE USER `_xTest6` PASS '2xF' SYSINFO 1 CREATEDB 0 IS_IMPORT 0 HOST '127.0.0.1';
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue