提交 33ac1a92 编写于 作者: sangshuduo's avatar sangshuduo

make taos.exe use mysql style password input.

上级 efe96a31
......@@ -65,7 +65,15 @@ extern TAOS *taos_connect_auth(const char *ip, const char *user, const char *aut
*/
TAOS *shellInit(SShellArguments *_args) {
printf("\n");
#ifndef WINDOWS
printf(CLIENT_VERSION, tsOsName, taos_get_client_info());
#else
if (!_args->is_use_passwd) {
strcpy(tsOsName, "Windows");
printf(CLIENT_VERSION, tsOsName, taos_get_client_info());
}
#endif
fflush(stdout);
// set options before initializing
......@@ -74,7 +82,9 @@ TAOS *shellInit(SShellArguments *_args) {
}
if (_args->is_use_passwd) {
#ifndef TD_WINDOWS
if (_args->password == NULL) _args->password = getpass("Enter password: ");
#endif
} else {
_args->password = TSDB_DEFAULT_PASS;
}
......
......@@ -71,7 +71,9 @@ int checkVersion() {
// Global configurations
SShellArguments args = {
.host = NULL,
#ifndef TD_WINDOWS
.password = NULL,
#endif
.user = NULL,
.database = NULL,
.timezone = NULL,
......
......@@ -19,6 +19,9 @@
extern char configDir[];
char WINCLIENT_VERSION[] = "Welcome to the TDengine shell from %s, Client Version:%s\n"
"Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.\n\n";
void printVersion() {
printf("version: %s\n", version);
}
......@@ -61,6 +64,8 @@ void printHelp() {
exit(EXIT_SUCCESS);
}
char g_password[MAX_PASSWORD_SIZE];
void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
for (int i = 1; i < argc; i++) {
// for host
......@@ -73,11 +78,18 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
}
// for password
else if (strcmp(argv[i], "-p") == 0) {
else if (strncmp(argv[i], "-p", 2) == 0) {
arguments->is_use_passwd = true;
if (i < argc - 1 && argv[i + 1][0] != '-') {
arguments->password = argv[++i];
strcpy(tsOsName, "Windows");
printf(WINCLIENT_VERSION, tsOsName, taos_get_client_info());
if (strlen(argv[i]) == 2) {
printf("Enter password: ");
scanf("%s", g_password);
getchar();
} else {
tstrncpy(g_password, (char *)(argv[i] + 2), MAX_PASSWORD_SIZE);
}
arguments->password = g_password;
}
// for management port
else if (strcmp(argv[i], "-P") == 0) {
......
......@@ -77,7 +77,7 @@ extern char configDir[];
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
#define MAX_USERNAME_SIZE 64
#define MAX_PASSWORD_SIZE 16
#define MAX_PASSWORD_SIZE 20
#define MAX_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html
#define MAX_TB_NAME_SIZE 64
#define MAX_DATA_SIZE (16*TSDB_MAX_COLUMNS)+20 // max record len: 16*MAX_COLUMNS, timestamp string and ,('') need extra space
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册