feat/TS-5927-long-password-length
This commit is contained in:
parent
2fd8792c7a
commit
36caaf7aab
|
@ -299,7 +299,7 @@ typedef struct SAlterTableMultiStmt {
|
||||||
typedef struct SCreateUserStmt {
|
typedef struct SCreateUserStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char userName[TSDB_USER_LEN];
|
char userName[TSDB_USER_LEN];
|
||||||
char password[TSDB_USET_PASSWORD_LEN];
|
char password[TSDB_USET_PASSWORD_LONGLEN];
|
||||||
int8_t sysinfo;
|
int8_t sysinfo;
|
||||||
int8_t createDb;
|
int8_t createDb;
|
||||||
int8_t isImport;
|
int8_t isImport;
|
||||||
|
@ -313,7 +313,7 @@ typedef struct SAlterUserStmt {
|
||||||
ENodeType type;
|
ENodeType type;
|
||||||
char userName[TSDB_USER_LEN];
|
char userName[TSDB_USER_LEN];
|
||||||
int8_t alterType;
|
int8_t alterType;
|
||||||
char password[TSDB_USET_PASSWORD_LEN];
|
char password[TSDB_USET_PASSWORD_LONGLEN];
|
||||||
int8_t enable;
|
int8_t enable;
|
||||||
int8_t sysinfo;
|
int8_t sysinfo;
|
||||||
int8_t createdb;
|
int8_t createdb;
|
||||||
|
|
|
@ -110,7 +110,7 @@ static bool invalidPassword(const char* pPassword) {
|
||||||
static bool checkPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken, char* pPassword) {
|
static bool checkPassword(SAstCreateContext* pCxt, const SToken* pPasswordToken, char* pPassword) {
|
||||||
if (NULL == pPasswordToken) {
|
if (NULL == pPasswordToken) {
|
||||||
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR;
|
||||||
} else if (pPasswordToken->n >= (TSDB_USET_PASSWORD_LEN + 2)) {
|
} else if (pPasswordToken->n >= (TSDB_USET_PASSWORD_LONGLEN + 2)) {
|
||||||
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NAME_OR_PASSWD_TOO_LONG);
|
||||||
} else {
|
} else {
|
||||||
strncpy(pPassword, pPasswordToken->z, pPasswordToken->n);
|
strncpy(pPassword, pPasswordToken->z, pPasswordToken->n);
|
||||||
|
@ -3030,14 +3030,14 @@ _err:
|
||||||
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo,
|
SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword, int8_t sysinfo,
|
||||||
int8_t createDb, int8_t is_import) {
|
int8_t createDb, int8_t is_import) {
|
||||||
CHECK_PARSER_STATUS(pCxt);
|
CHECK_PARSER_STATUS(pCxt);
|
||||||
char password[TSDB_USET_PASSWORD_LEN + 3] = {0};
|
char password[TSDB_USET_PASSWORD_LONGLEN + 3] = {0};
|
||||||
CHECK_NAME(checkUserName(pCxt, pUserName));
|
CHECK_NAME(checkUserName(pCxt, pUserName));
|
||||||
CHECK_NAME(checkPassword(pCxt, pPassword, password));
|
CHECK_NAME(checkPassword(pCxt, pPassword, password));
|
||||||
SCreateUserStmt* pStmt = NULL;
|
SCreateUserStmt* pStmt = NULL;
|
||||||
pCxt->errCode = nodesMakeNode(QUERY_NODE_CREATE_USER_STMT, (SNode**)&pStmt);
|
pCxt->errCode = nodesMakeNode(QUERY_NODE_CREATE_USER_STMT, (SNode**)&pStmt);
|
||||||
CHECK_MAKE_NODE(pStmt);
|
CHECK_MAKE_NODE(pStmt);
|
||||||
COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName);
|
COPY_STRING_FORM_ID_TOKEN(pStmt->userName, pUserName);
|
||||||
tstrncpy(pStmt->password, password, TSDB_USET_PASSWORD_LEN);
|
tstrncpy(pStmt->password, password, TSDB_USET_PASSWORD_LONGLEN);
|
||||||
pStmt->sysinfo = sysinfo;
|
pStmt->sysinfo = sysinfo;
|
||||||
pStmt->createDb = createDb;
|
pStmt->createDb = createDb;
|
||||||
pStmt->isImport = is_import;
|
pStmt->isImport = is_import;
|
||||||
|
@ -3056,10 +3056,10 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t al
|
||||||
pStmt->alterType = alterType;
|
pStmt->alterType = alterType;
|
||||||
switch (alterType) {
|
switch (alterType) {
|
||||||
case TSDB_ALTER_USER_PASSWD: {
|
case TSDB_ALTER_USER_PASSWD: {
|
||||||
char password[TSDB_USET_PASSWORD_LEN] = {0};
|
char password[TSDB_USET_PASSWORD_LONGLEN] = {0};
|
||||||
SToken* pVal = pAlterInfo;
|
SToken* pVal = pAlterInfo;
|
||||||
CHECK_NAME(checkPassword(pCxt, pVal, password));
|
CHECK_NAME(checkPassword(pCxt, pVal, password));
|
||||||
tstrncpy(pStmt->password, password, TSDB_USET_PASSWORD_LEN);
|
tstrncpy(pStmt->password, password, TSDB_USET_PASSWORD_LONGLEN);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TSDB_ALTER_USER_ENABLE: {
|
case TSDB_ALTER_USER_ENABLE: {
|
||||||
|
|
|
@ -10045,7 +10045,7 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt
|
||||||
createReq.superUser = 0;
|
createReq.superUser = 0;
|
||||||
createReq.sysInfo = pStmt->sysinfo;
|
createReq.sysInfo = pStmt->sysinfo;
|
||||||
createReq.enable = 1;
|
createReq.enable = 1;
|
||||||
tstrncpy(createReq.pass, pStmt->password, TSDB_USET_PASSWORD_LEN);
|
tstrncpy(createReq.longPass, pStmt->password, TSDB_USET_PASSWORD_LONGLEN);
|
||||||
createReq.isImport = pStmt->isImport;
|
createReq.isImport = pStmt->isImport;
|
||||||
createReq.createDb = pStmt->createDb;
|
createReq.createDb = pStmt->createDb;
|
||||||
|
|
||||||
|
@ -10090,7 +10090,7 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt
|
||||||
alterReq.enable = pStmt->enable;
|
alterReq.enable = pStmt->enable;
|
||||||
alterReq.sysInfo = pStmt->sysinfo;
|
alterReq.sysInfo = pStmt->sysinfo;
|
||||||
alterReq.createdb = pStmt->createdb ? 1 : 0;
|
alterReq.createdb = pStmt->createdb ? 1 : 0;
|
||||||
snprintf(alterReq.pass, sizeof(alterReq.pass), "%s", pStmt->password);
|
snprintf(alterReq.longPass, sizeof(alterReq.pass), "%s", pStmt->password);
|
||||||
if (NULL != pCxt->pParseCxt->db) {
|
if (NULL != pCxt->pParseCxt->db) {
|
||||||
snprintf(alterReq.objname, sizeof(alterReq.objname), "%s", pCxt->pParseCxt->db);
|
snprintf(alterReq.objname, sizeof(alterReq.objname), "%s", pCxt->pParseCxt->db);
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,7 +86,7 @@ sql create user user_p6 pass 'abcd!@123456'
|
||||||
sql create user user_p7 pass 'abcd!@1234567'
|
sql create user user_p7 pass 'abcd!@1234567'
|
||||||
sql create user user_p8 pass 'abcd!@123456789'
|
sql create user user_p8 pass 'abcd!@123456789'
|
||||||
sql create user user_p9 pass 'abcd!@1234567890'
|
sql create user user_p9 pass 'abcd!@1234567890'
|
||||||
sql_error create user user_p10 pass 'abcd!@1234567890T'
|
sql_error create user user_p10 pass 'abcd!@123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345T'
|
||||||
sql drop user user_p2
|
sql drop user user_p2
|
||||||
sql drop user user_p3
|
sql drop user user_p3
|
||||||
sql drop user user_p4
|
sql drop user user_p4
|
||||||
|
|
|
@ -33,7 +33,7 @@ class TDTestCase:
|
||||||
self.colname_length_boundary = self.boundary.COL_KEY_MAX_LENGTH
|
self.colname_length_boundary = self.boundary.COL_KEY_MAX_LENGTH
|
||||||
self.tagname_length_boundary = self.boundary.TAG_KEY_MAX_LENGTH
|
self.tagname_length_boundary = self.boundary.TAG_KEY_MAX_LENGTH
|
||||||
self.username_length_boundary = 23
|
self.username_length_boundary = 23
|
||||||
self.password_length_boundary = 14
|
self.password_length_boundary = 253
|
||||||
def dbname_length_check(self):
|
def dbname_length_check(self):
|
||||||
dbname_length = randint(1,self.dbname_length_boundary-1)
|
dbname_length = randint(1,self.dbname_length_boundary-1)
|
||||||
for dbname in [tdCom.get_long_name(self.dbname_length_boundary),tdCom.get_long_name(dbname_length)]:
|
for dbname in [tdCom.get_long_name(self.dbname_length_boundary),tdCom.get_long_name(dbname_length)]:
|
||||||
|
|
Loading…
Reference in New Issue