Merge pull request #30091 from taosdata/enh/TS-6003-3.0

enh: password extend length 255 for taos taosdump taosBenchmark
This commit is contained in:
Linhe Huo 2025-03-14 16:54:23 +08:00 committed by GitHub
commit 73d4e5f850
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 68 additions and 18 deletions

2
.gitignore vendored
View File

@ -51,7 +51,6 @@ pysim/
tests/script/api/batchprepare
taosadapter
taosadapter-debug
tools/taos-tools/*
tools/taosws-rs/*
tools/taosadapter/*
tools/upx*
@ -140,7 +139,6 @@ tags
*CMakeCache*
*CMakeFiles*
.history/
*.txt
*.tcl
*.pc
contrib/geos

View File

@ -0,0 +1 @@
abcdefghigklmnopqrstuvwxyz@ABCDEFGHIGKLMNOPQRSTUVWXYZ123456789!@#$%^&*()-_+=[]{}:;><?|~,.AAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABBBBBBBBBBCCCCCCCCCCDDDDDDDDDEEEEEEEEEAAAAAAAAAAAABEND

View File

@ -213,6 +213,27 @@ class TDTestCase(TBase):
rlist = self.taos(arg[0])
if arg[1] != None:
self.checkListString(rlist, arg[1])
# password
def checkPassword(self):
# 255 char max password
user = "test_user"
pwd = ""
pwdFile = "cmdline/data/pwdMax.txt"
with open(pwdFile) as file:
pwd = file.readline()
sql = f"create user {user} pass '{pwd}' "
tdSql.execute(sql)
cmds = [
f"-u{user} -p'{pwd}' -s 'show databases;'", # command pass
f"-u{user} -p < {pwdFile} -s 'show databases;'" # input pass
]
for cmd in cmds:
rlist = self.taos(cmd)
self.checkListString(rlist, "Query OK,")
# run
def run(self):
@ -236,6 +257,9 @@ class TDTestCase(TBase):
# check data in/out
self.checkDumpInOut()
# max password
self.checkPassword()
tdLog.success(f"{__file__} successfully executed")

View File

@ -177,14 +177,12 @@ class TDTestCase(TBase):
# executes
for item in checkItems:
self.clearPath(tmpdir)
self.clearPath(tmpdir) # clear tmp
command = item[0]
results = item[1]
rlist = self.taosdump(command)
for result in results:
self.checkListString(rlist, result)
# clear tmp
# check except
def checkExcept(self, command):
@ -214,6 +212,31 @@ 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
user = "test_user"
pwd = ""
pwdFile = "cmdline/data/pwdMax.txt"
with open(pwdFile) as file:
pwd = file.readline()
sql = f"create user {user} pass '{pwd}' "
tdSql.execute(sql)
# enterprise must set
sql = f"grant read on test to {user}"
tdSql.execute(sql)
cmds = [
f"-u{user} -p'{pwd}' -D test -o {tmpdir}", # command pass
f"-u{user} -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):
@ -224,20 +247,26 @@ class TDTestCase(TBase):
# insert data with taosBenchmark
db, stb, childCount, insertRows = self.insertData(json)
#
# long password
#
self.checkPassword(tmpdir)
tdLog.info("1. check long password ................................. [Passed]")
# dumpInOut
modes = ["", "-R" , "--cloud=http://localhost:6041"]
for mode in modes:
self.dumpInOutMode(mode, db , json, tmpdir)
tdLog.info("1. native rest ws dumpIn Out .......................... [Passed]")
tdLog.info("2. native rest ws dumpIn Out .......................... [Passed]")
# basic commandline
self.basicCommandLine(tmpdir)
tdLog.info("2. basic command line .................................. [Passed]")
tdLog.info("3. basic command line .................................. [Passed]")
# except commandline
self.exceptCommandLine(taosdump, db, stb, tmpdir)
tdLog.info("3. except command line ................................. [Passed]")
tdLog.info("4. except command line ................................. [Passed]")
#
# varbinary and geometry for native
@ -247,7 +276,8 @@ class TDTestCase(TBase):
db, stb, childCount, insertRows = self.insertData(json)
# dump in/out
self.dumpInOutMode("", db , json, tmpdir)
tdLog.info("4. native varbinary geometry ........................... [Passed]")
tdLog.info("5. native varbinary geometry ........................... [Passed]")
def stop(self):

View File

@ -337,7 +337,7 @@ static void shellInitArgs(int argc, char *argv[]) {
if (strlen(argv[i]) == 2) {
printf("Enter password: ");
taosSetConsoleEcho(false);
if (scanf("%128s", shell.args.password) > 1) {
if (scanf("%255s", shell.args.password) > 1) {
fprintf(stderr, "password reading error\n");
}
taosSetConsoleEcho(true);

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

@ -58,6 +58,7 @@
#define NEED_CALC_COUNT UINT64_MAX
#define HUMAN_TIME_LEN 28
#define DUMP_DIR_LEN (MAX_DIR_LEN - (TSDB_DB_NAME_LEN + 10))
#define TSDB_USET_PASSWORD_LONGLEN 256 // come from tdef.h
#define debugPrint(fmt, ...) \
@ -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

@ -76,9 +76,6 @@ extern "C" {
#define TSDB_DEFAULT_USER "root"
#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
#define TSDB_TIME_PRECISION_NANO 2

View File

@ -778,14 +778,13 @@ static void parse_args(
|| (strncmp(argv[i], "--password", 10) == 0)) {
printf("Enter password: ");
setConsoleEcho(false);
if (scanf("%20s", arguments->password) > 1) {
if (scanf("%255s", arguments->password) > 1) {
errorPrint("%s() LN%d, password read error!\n",
__func__, __LINE__);
}
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) {