提交 56aafafc 编写于 作者: sangshuduo's avatar sangshuduo

make taos.exe use mysql style password input.

上级 cfd0f4c2
...@@ -65,7 +65,15 @@ extern TAOS *taos_connect_auth(const char *ip, const char *user, const char *aut ...@@ -65,7 +65,15 @@ extern TAOS *taos_connect_auth(const char *ip, const char *user, const char *aut
*/ */
TAOS *shellInit(SShellArguments *_args) { TAOS *shellInit(SShellArguments *_args) {
printf("\n"); 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()); printf(CLIENT_VERSION, tsOsName, taos_get_client_info());
}
#endif
fflush(stdout); fflush(stdout);
// set options before initializing // set options before initializing
...@@ -74,7 +82,9 @@ TAOS *shellInit(SShellArguments *_args) { ...@@ -74,7 +82,9 @@ TAOS *shellInit(SShellArguments *_args) {
} }
if (_args->is_use_passwd) { if (_args->is_use_passwd) {
#ifndef TD_WINDOWS
if (_args->password == NULL) _args->password = getpass("Enter password: "); if (_args->password == NULL) _args->password = getpass("Enter password: ");
#endif
} else { } else {
_args->password = TSDB_DEFAULT_PASS; _args->password = TSDB_DEFAULT_PASS;
} }
......
...@@ -71,7 +71,9 @@ int checkVersion() { ...@@ -71,7 +71,9 @@ int checkVersion() {
// Global configurations // Global configurations
SShellArguments args = { SShellArguments args = {
.host = NULL, .host = NULL,
#ifndef TD_WINDOWS
.password = NULL, .password = NULL,
#endif
.user = NULL, .user = NULL,
.database = NULL, .database = NULL,
.timezone = NULL, .timezone = NULL,
......
...@@ -19,6 +19,9 @@ ...@@ -19,6 +19,9 @@
extern char configDir[]; 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() { void printVersion() {
printf("version: %s\n", version); printf("version: %s\n", version);
} }
...@@ -61,6 +64,8 @@ void printHelp() { ...@@ -61,6 +64,8 @@ void printHelp() {
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);
} }
char g_password[MAX_PASSWORD_SIZE];
void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
for (int i = 1; i < argc; i++) { for (int i = 1; i < argc; i++) {
// for host // for host
...@@ -73,11 +78,18 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) { ...@@ -73,11 +78,18 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
} }
} }
// for password // for password
else if (strcmp(argv[i], "-p") == 0) { else if (strncmp(argv[i], "-p", 2) == 0) {
arguments->is_use_passwd = true; arguments->is_use_passwd = true;
if (i < argc - 1 && argv[i + 1][0] != '-') { strcpy(tsOsName, "Windows");
arguments->password = argv[++i]; 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 // for management port
else if (strcmp(argv[i], "-P") == 0) { else if (strcmp(argv[i], "-P") == 0) {
......
...@@ -76,7 +76,7 @@ extern char configDir[]; ...@@ -76,7 +76,7 @@ extern char configDir[];
#define COND_BUF_LEN (BUFFER_SIZE - 30) #define COND_BUF_LEN (BUFFER_SIZE - 30)
#define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS) #define COL_BUFFER_LEN ((TSDB_COL_NAME_LEN + 15) * TSDB_MAX_COLUMNS)
#define MAX_USERNAME_SIZE 64 #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_HOSTNAME_SIZE 253 // https://man7.org/linux/man-pages/man7/hostname.7.html
#define MAX_TB_NAME_SIZE 64 #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 #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.
先完成此消息的编辑!
想要评论请 注册