enh: taosdump extend password length from 128 to 255

This commit is contained in:
Alex Duan 2025-03-10 14:15:08 +08:00
parent 6c25d88f14
commit 7c13d742c6
5 changed files with 32 additions and 5 deletions

View File

@ -214,6 +214,27 @@ class TDTestCase(TBase):
self.checkExcept(taosdump + f" -t 2 -k 2 -z 1 -C https://not-exist.com:80/cloud -D test -o {tmpdir}")
self.checkExcept(taosdump + f" -P 65536")
# password
def checkPassword(self, tmpdir):
# 255 char max password
pwd = ""
pwdFile = "cmdline/data/pwdMax.txt"
with open(pwdFile) as file:
pwd = file.readline()
sql = f"create user dkj pass '{pwd}' "
tdSql.execute(sql)
cmds = [
f"-udkj -p{pwd} -D test -o {tmpdir}", # command pass
f"-udkj -p < {pwdFile} -D test -o {tmpdir}" # input pass
]
for cmd in cmds:
self.clearPath(tmpdir)
rlist = self.taosdump(cmd)
self.checkListString(rlist, "OK: Database test dumped")
# run
def run(self):
@ -249,6 +270,12 @@ class TDTestCase(TBase):
self.dumpInOutMode("", db , json, tmpdir)
tdLog.info("4. native varbinary geometry ........................... [Passed]")
#
# long password
#
self.checkPassword(tmpdir)
tdLog.info("5. check long password ................................. [Passed]")
def stop(self):
tdSql.close()

View File

@ -152,7 +152,7 @@ typedef unsigned __int32 uint32_t;
#define MAX_JSON_BUFF 6400000
#define INPUT_BUF_LEN 256
#define INPUT_BUF_LEN 512
#define EXTRA_SQL_LEN 256
#define DATATYPE_BUFF_LEN (TINY_BUFF_LEN * 3)
#define SML_MAX_BATCH 65536 * 32

View File

@ -39,6 +39,7 @@
#include <taos.h>
#include <taoserror.h>
#include <toolsdef.h>
#include <tdef.h>
#ifdef WEBSOCKET
#include <taosws.h>
@ -336,7 +337,7 @@ typedef struct arguments {
// connection option
char *host;
char *user;
char password[SHELL_MAX_PASSWORD_LEN];
char password[TSDB_USET_PASSWORD_LONGLEN];
uint16_t port;
// strlen(taosdump.) +1 is 10
char outpath[DUMP_DIR_LEN];

View File

@ -77,7 +77,7 @@ extern "C" {
#define TSDB_DEFAULT_PASS "taosdata"
#define TSDB_PASS_LEN 129
#define SHELL_MAX_PASSWORD_LEN TSDB_PASS_LEN
#define TSDB_TIME_PRECISION_MILLI 0
#define TSDB_TIME_PRECISION_MICRO 1

View File

@ -784,8 +784,7 @@ static void parse_args(
}
setConsoleEcho(true);
} else {
tstrncpy(arguments->password, (char *)(argv[i] + 2),
SHELL_MAX_PASSWORD_LEN);
strcpy(arguments->password, (char *)(argv[i] + 2));
strcpy(argv[i], "-p");
}
} else if (strcmp(argv[i], "-n") == 0) {