From fd2058d7081aae547c299650919445ce32b16d82 Mon Sep 17 00:00:00 2001 From: xywang Date: Tue, 22 Feb 2022 14:20:47 +0800 Subject: [PATCH] [TS-229]: removed config and set the max len for password to 128 --- src/client/src/tscSQLParser.c | 2 +- src/client/src/tscSql.c | 2 +- src/common/inc/tglobal.h | 3 --- src/common/src/tglobal.c | 13 ------------- src/inc/taosdef.h | 2 +- src/kit/shell/src/shellDarwin.c | 2 +- src/kit/shell/src/shellLinux.c | 2 +- src/kit/shell/src/shellWindows.c | 2 +- 8 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/client/src/tscSQLParser.c b/src/client/src/tscSQLParser.c index 55614f348d..851a87dfb6 100644 --- a/src/client/src/tscSQLParser.c +++ b/src/client/src/tscSQLParser.c @@ -366,7 +366,7 @@ static int32_t handlePassword(SSqlCmd* pCmd, SStrToken* pPwd) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg1); } - if (pPwd->n > tsPasswordLength) { + if (pPwd->n > TSDB_PASS_LEN - 1) { return invalidOperationMsg(tscGetErrorMsgPayload(pCmd), msg2); } diff --git a/src/client/src/tscSql.c b/src/client/src/tscSql.c index 4f2cb405ce..d736c322d2 100644 --- a/src/client/src/tscSql.c +++ b/src/client/src/tscSql.c @@ -49,7 +49,7 @@ static bool validUserName(const char* user) { } static bool validPassword(const char* passwd) { - return validImpl(passwd, tsPasswordLength); + return validImpl(passwd, TSDB_PASS_LEN - 1); } static SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, const char *auth, const char *db, diff --git a/src/common/inc/tglobal.h b/src/common/inc/tglobal.h index 234c254a80..06ed93b110 100644 --- a/src/common/inc/tglobal.h +++ b/src/common/inc/tglobal.h @@ -159,9 +159,6 @@ extern int32_t tsMonitorInterval; // stream extern int8_t tsEnableStream; -// password -extern int32_t tsPasswordLength; - // internal extern int8_t tsCompactMnodeWal; extern int8_t tsPrintAuth; diff --git a/src/common/src/tglobal.c b/src/common/src/tglobal.c index 33a16b0952..af92f264df 100644 --- a/src/common/src/tglobal.c +++ b/src/common/src/tglobal.c @@ -204,9 +204,6 @@ int32_t tsMonitorInterval = 30; // seconds // stream int8_t tsEnableStream = 1; -// password -int32_t tsPasswordLength = TSDB_PASS_LEN - 1; - // internal int8_t tsCompactMnodeWal = 0; int8_t tsPrintAuth = 0; @@ -1305,16 +1302,6 @@ static void doInitGlobalConfig(void) { cfg.unitType = TAOS_CFG_UTYPE_NONE; taosInitConfigOption(cfg); - cfg.option = "passwordLength"; - cfg.ptr = &tsPasswordLength; - cfg.valType = TAOS_CFG_VTYPE_INT32; - cfg.cfgType = TSDB_CFG_CTYPE_B_CONFIG | TSDB_CFG_CTYPE_B_SHOW; - cfg.minValue = 1; - cfg.maxValue = TSDB_PASS_LEN - 1; - cfg.ptrLength = 0; - cfg.unitType = TAOS_CFG_UTYPE_NONE; - taosInitConfigOption(cfg); - cfg.option = "topicBinaryLen"; cfg.ptr = &tsTopicBianryLen; cfg.valType = TAOS_CFG_VTYPE_INT32; diff --git a/src/inc/taosdef.h b/src/inc/taosdef.h index d2b1e794a4..e669ac900c 100644 --- a/src/inc/taosdef.h +++ b/src/inc/taosdef.h @@ -86,7 +86,7 @@ extern const int32_t TYPE_BYTES[16]; #define TSDB_DEFAULT_USER "root" #define TSDB_DEFAULT_PASS "taosdata" -#define TSDB_PASS_LEN 33 +#define TSDB_PASS_LEN 128 #define SHELL_MAX_PASSWORD_LEN TSDB_PASS_LEN #define TSDB_TRUE 1 diff --git a/src/kit/shell/src/shellDarwin.c b/src/kit/shell/src/shellDarwin.c index a1413be1ce..5a33e182c8 100644 --- a/src/kit/shell/src/shellDarwin.c +++ b/src/kit/shell/src/shellDarwin.c @@ -89,7 +89,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { || (strncmp(argv[i], "--password", 10) == 0)) { printf("Enter password: "); taosSetConsoleEcho(false); - if (scanf("%s", g_password) > 1) { + if (scanf("%128s", g_password) > 1) { fprintf(stderr, "password read error\n"); } taosSetConsoleEcho(true); diff --git a/src/kit/shell/src/shellLinux.c b/src/kit/shell/src/shellLinux.c index de906f32a3..a78590aab8 100644 --- a/src/kit/shell/src/shellLinux.c +++ b/src/kit/shell/src/shellLinux.c @@ -186,7 +186,7 @@ static void parse_args( || (strncmp(argv[i], "--password", 10) == 0)) { printf("Enter password: "); taosSetConsoleEcho(false); - if (scanf("%32s", g_password) > 1) { + if (scanf("%128s", g_password) > 1) { fprintf(stderr, "password reading error\n"); } taosSetConsoleEcho(true); diff --git a/src/kit/shell/src/shellWindows.c b/src/kit/shell/src/shellWindows.c index 131bce04a7..a685498617 100644 --- a/src/kit/shell/src/shellWindows.c +++ b/src/kit/shell/src/shellWindows.c @@ -93,7 +93,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { || (strncmp(argv[i], "--password", 10) == 0)) { printf("Enter password: "); taosSetConsoleEcho(false); - if (scanf("%s", g_password) > 1) { + if (scanf("%128s", g_password) > 1) { fprintf(stderr, "password read error!\n"); } taosSetConsoleEcho(true); -- GitLab