Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
85961d0d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
85961d0d
编写于
8月 08, 2021
作者:
sangshuduo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make taos shell and taosdump use mysql style password input.
上级
33ac1a92
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
73 addition
and
22 deletion
+73
-22
src/kit/shell/src/shellDarwin.c
src/kit/shell/src/shellDarwin.c
+17
-4
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+5
-9
src/kit/shell/src/shellLinux.c
src/kit/shell/src/shellLinux.c
+29
-4
src/kit/taosdump/taosdump.c
src/kit/taosdump/taosdump.c
+22
-5
未找到文件。
src/kit/shell/src/shellDarwin.c
浏览文件 @
85961d0d
...
...
@@ -64,6 +64,10 @@ void printHelp() {
exit
(
EXIT_SUCCESS
);
}
char
DARWINCLIENT_VERSION
[]
=
"Welcome to the TDengine shell from %s, Client Version:%s
\n
"
"Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
\n\n
"
;
char
g_password
[
MAX_PASSWORD_SIZE
];
void
shellParseArgument
(
int
argc
,
char
*
argv
[],
SShellArguments
*
arguments
)
{
wordexp_t
full_path
;
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
...
...
@@ -77,10 +81,19 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
}
}
// for password
else
if
(
strcmp
(
argv
[
i
],
"-p"
)
==
0
)
{
arguments
->
is_use_passwd
=
true
;
else
if
(
strncmp
(
argv
[
i
],
"-p"
,
2
)
==
0
)
{
strcpy
(
tsOsName
,
"Darwin"
);
printf
(
DARWINCLIENT_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
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
port
=
atoi
(
argv
[
++
i
]);
...
...
@@ -98,7 +111,7 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
if
(
i
<
argc
-
1
)
{
if
(
strlen
(
argv
[
++
i
])
>=
TSDB_FILENAME_LEN
)
{
fprintf
(
stderr
,
"config file path: %s overflow max len %d
\n
"
,
argv
[
i
],
TSDB_FILENAME_LEN
-
1
);
exit
(
EXIT_FAILURE
);
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
85961d0d
...
...
@@ -65,14 +65,14 @@ 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
)
{
#ifdef TD_WINDOWS
strcpy
(
tsOsName
,
"Windows"
);
#elif defined(TD_DARWIN)
strcpy
(
tsOsName
,
"Darwin"
);
#endif
printf
(
CLIENT_VERSION
,
tsOsName
,
taos_get_client_info
());
}
#endif
fflush
(
stdout
);
...
...
@@ -81,11 +81,7 @@ TAOS *shellInit(SShellArguments *_args) {
taos_options
(
TSDB_OPTION_TIMEZONE
,
_args
->
timezone
);
}
if
(
_args
->
is_use_passwd
)
{
#ifndef TD_WINDOWS
if
(
_args
->
password
==
NULL
)
_args
->
password
=
getpass
(
"Enter password: "
);
#endif
}
else
{
if
(
!
_args
->
is_use_passwd
)
{
_args
->
password
=
TSDB_DEFAULT_PASS
;
}
...
...
src/kit/shell/src/shellLinux.c
浏览文件 @
85961d0d
...
...
@@ -34,7 +34,7 @@ static char doc[] = "";
static
char
args_doc
[]
=
""
;
static
struct
argp_option
options
[]
=
{
{
"host"
,
'h'
,
"HOST"
,
0
,
"TDengine server FQDN to connect. The default host is localhost."
},
{
"password"
,
'p'
,
"PASSWORD"
,
OPTION_ARG_OPTIONAL
,
"The password to use when connecting to the server."
},
{
"password"
,
'p'
,
0
,
0
,
"The password to use when connecting to the server."
},
{
"port"
,
'P'
,
"PORT"
,
0
,
"The TCP/IP port number to use for the connection."
},
{
"user"
,
'u'
,
"USER"
,
0
,
"The user name to use when connecting to the server."
},
{
"auth"
,
'A'
,
"Auth"
,
0
,
"The auth string to use when connecting to the server."
},
...
...
@@ -63,8 +63,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
arguments
->
host
=
arg
;
break
;
case
'p'
:
arguments
->
is_use_passwd
=
true
;
if
(
arg
)
arguments
->
password
=
arg
;
break
;
case
'P'
:
if
(
arg
)
{
...
...
@@ -160,12 +158,39 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
/* Our argp parser. */
static
struct
argp
argp
=
{
options
,
parse_opt
,
args_doc
,
doc
};
char
LINUXCLIENT_VERSION
[]
=
"Welcome to the TDengine shell from %s, Client Version:%s
\n
"
"Copyright (c) 2020 by TAOS Data, Inc. All rights reserved.
\n\n
"
;
char
g_password
[
MAX_PASSWORD_SIZE
];
static
void
parse_password
(
int
argc
,
char
*
argv
[],
SShellArguments
*
arguments
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strncmp
(
argv
[
i
],
"-p"
,
2
)
==
0
)
{
strcpy
(
tsOsName
,
"Linux"
);
printf
(
LINUXCLIENT_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
;
arguments
->
is_use_passwd
=
true
;
}
}
}
void
shellParseArgument
(
int
argc
,
char
*
argv
[],
SShellArguments
*
arguments
)
{
static
char
verType
[
32
]
=
{
0
};
sprintf
(
verType
,
"version: %s
\n
"
,
version
);
argp_program_version
=
verType
;
if
(
argc
>
1
)
{
parse_password
(
argc
,
argv
,
arguments
);
}
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
arguments
);
if
(
arguments
->
abort
)
{
#ifndef _ALPINE
...
...
src/kit/taosdump/taosdump.c
浏览文件 @
85961d0d
...
...
@@ -206,9 +206,9 @@ static struct argp_option options[] = {
{
"host"
,
'h'
,
"HOST"
,
0
,
"Server host dumping data from. Default is localhost."
,
0
},
{
"user"
,
'u'
,
"USER"
,
0
,
"User name used to connect to server. Default is root."
,
0
},
#ifdef _TD_POWER_
{
"password"
,
'p'
,
"PASSWORD"
,
0
,
"User password to connect to server. Default is powerdb."
,
0
},
{
"password"
,
'p'
,
0
,
0
,
"User password to connect to server. Default is powerdb."
,
0
},
#else
{
"password"
,
'p'
,
"PASSWORD"
,
0
,
"User password to connect to server. Default is taosdata."
,
0
},
{
"password"
,
'p'
,
0
,
0
,
"User password to connect to server. Default is taosdata."
,
0
},
#endif
{
"port"
,
'P'
,
"PORT"
,
0
,
"Port to connect"
,
0
},
{
"cversion"
,
'v'
,
"CVERION"
,
0
,
"client version"
,
0
},
...
...
@@ -248,12 +248,14 @@ static struct argp_option options[] = {
{
0
}
};
#define MAX_PASSWORD_SIZE 20
/* Used by main to communicate with parse_opt. */
typedef
struct
arguments
{
// connection option
char
*
host
;
char
*
user
;
char
*
password
;
char
password
[
MAX_PASSWORD_SIZE
]
;
uint16_t
port
;
char
cversion
[
12
];
uint16_t
mysqlFlag
;
...
...
@@ -376,7 +378,6 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
g_args
.
user
=
arg
;
break
;
case
'p'
:
g_args
.
password
=
arg
;
break
;
case
'P'
:
g_args
.
port
=
atoi
(
arg
);
...
...
@@ -554,6 +555,21 @@ static void parse_precision_first(
}
}
static
void
parse_password
(
int
argc
,
char
*
argv
[],
SArguments
*
arguments
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
if
(
strncmp
(
argv
[
i
],
"-p"
,
2
)
==
0
)
{
if
(
strlen
(
argv
[
i
])
==
2
)
{
printf
(
"Enter password: "
);
scanf
(
"%s"
,
arguments
->
password
);
}
else
{
tstrncpy
(
arguments
->
password
,
(
char
*
)(
argv
[
i
]
+
2
),
MAX_PASSWORD_SIZE
);
}
argv
[
i
]
=
""
;
}
}
}
static
void
parse_timestamp
(
int
argc
,
char
*
argv
[],
SArguments
*
arguments
)
{
for
(
int
i
=
1
;
i
<
argc
;
i
++
)
{
...
...
@@ -616,9 +632,10 @@ int main(int argc, char *argv[]) {
int
ret
=
0
;
/* Parse our arguments; every option seen by parse_opt will be
reflected in arguments. */
if
(
argc
>
2
)
{
if
(
argc
>
1
)
{
parse_precision_first
(
argc
,
argv
,
&
g_args
);
parse_timestamp
(
argc
,
argv
,
&
g_args
);
parse_password
(
argc
,
argv
,
&
g_args
);
}
argp_parse
(
&
argp
,
argc
,
argv
,
0
,
0
,
&
g_args
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录