Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
920cfc59
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
920cfc59
编写于
8月 17, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-1154 #1112 How to modify root's password when I have forgot it?
上级
b9672029
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
137 addition
and
48 deletion
+137
-48
src/client/src/taos.def
src/client/src/taos.def
+1
-0
src/client/src/tscSql.c
src/client/src/tscSql.c
+62
-29
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+3
-5
src/common/inc/tglobal.h
src/common/inc/tglobal.h
+1
-0
src/common/src/tglobal.c
src/common/src/tglobal.c
+1
-0
src/dnode/src/dnodeSystem.c
src/dnode/src/dnodeSystem.c
+2
-0
src/kit/shell/inc/shell.h
src/kit/shell/inc/shell.h
+1
-0
src/kit/shell/src/shellDarwin.c
src/kit/shell/src/shellDarwin.c
+3
-3
src/kit/shell/src/shellEngine.c
src/kit/shell/src/shellEngine.c
+8
-1
src/kit/shell/src/shellLinux.c
src/kit/shell/src/shellLinux.c
+7
-3
src/kit/shell/src/shellWindows.c
src/kit/shell/src/shellWindows.c
+12
-3
src/kit/taosdemo/taosdemo.c
src/kit/taosdemo/taosdemo.c
+4
-4
src/mnode/src/mnodeUser.c
src/mnode/src/mnodeUser.c
+32
-0
未找到文件。
src/client/src/taos.def
浏览文件 @
920cfc59
...
@@ -3,6 +3,7 @@ taos_init
...
@@ -3,6 +3,7 @@ taos_init
taos_cleanup
taos_cleanup
taos_options
taos_options
taos_connect
taos_connect
taos_connect_auth
taos_close
taos_close
taos_stmt_init
taos_stmt_init
taos_stmt_prepare
taos_stmt_prepare
...
...
src/client/src/tscSql.c
浏览文件 @
920cfc59
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
#include "hash.h"
#include "hash.h"
#include "os.h"
#include "os.h"
#include "qAst.h"
#include "qAst.h"
#include "tkey.h"
#include "tcache.h"
#include "tcache.h"
#include "tnote.h"
#include "tnote.h"
#include "trpc.h"
#include "trpc.h"
...
@@ -47,18 +48,37 @@ static bool validPassword(const char* passwd) {
...
@@ -47,18 +48,37 @@ static bool validPassword(const char* passwd) {
return
validImpl
(
passwd
,
TSDB_PASSWORD_LEN
-
1
);
return
validImpl
(
passwd
,
TSDB_PASSWORD_LEN
-
1
);
}
}
SSqlObj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
,
SSqlObj
*
taosConnectImpl
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
)
{
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
)
{
taos_init
();
taos_init
();
if
(
!
validUserName
(
user
))
{
if
(
!
validUserName
(
user
))
{
terrno
=
TSDB_CODE_TSC_INVALID_USER_LENGTH
;
terrno
=
TSDB_CODE_TSC_INVALID_USER_LENGTH
;
return
NULL
;
return
NULL
;
}
}
if
(
!
validPassword
(
pass
))
{
char
secretEncrypt
[
32
]
=
{
0
};
terrno
=
TSDB_CODE_TSC_INVALID_PASS_LENGTH
;
int
secretEncryptLen
=
0
;
return
NULL
;
if
(
auth
==
NULL
)
{
if
(
!
validPassword
(
pass
))
{
terrno
=
TSDB_CODE_TSC_INVALID_PASS_LENGTH
;
return
NULL
;
}
taosEncryptPass
((
uint8_t
*
)
pass
,
strlen
(
pass
),
secretEncrypt
);
}
else
{
int
outlen
=
0
;
int
len
=
strlen
(
auth
);
char
*
base64
=
(
char
*
)
base64_decode
(
auth
,
len
,
&
outlen
);
if
(
base64
==
NULL
||
outlen
==
0
)
{
tscError
(
"invalid auth info:%s"
,
auth
);
free
(
base64
);
terrno
=
TSDB_CODE_TSC_INVALID_PASS_LENGTH
;
return
NULL
;
}
else
{
memcpy
(
secretEncrypt
,
base64
,
outlen
);
free
(
base64
);
}
secretEncryptLen
=
outlen
;
}
}
if
(
ip
)
{
if
(
ip
)
{
...
@@ -67,7 +87,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
...
@@ -67,7 +87,7 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
}
}
void
*
pDnodeConn
=
NULL
;
void
*
pDnodeConn
=
NULL
;
if
(
tscInitRpc
(
user
,
pass
,
&
pDnodeConn
)
!=
0
)
{
if
(
tscInitRpc
(
user
,
secretEncrypt
,
&
pDnodeConn
)
!=
0
)
{
terrno
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
terrno
=
TSDB_CODE_RPC_NETWORK_UNAVAIL
;
return
NULL
;
return
NULL
;
}
}
...
@@ -82,7 +102,8 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
...
@@ -82,7 +102,8 @@ SSqlObj *taosConnectImpl(const char *ip, const char *user, const char *pass, con
pObj
->
signature
=
pObj
;
pObj
->
signature
=
pObj
;
tstrncpy
(
pObj
->
user
,
user
,
sizeof
(
pObj
->
user
));
tstrncpy
(
pObj
->
user
,
user
,
sizeof
(
pObj
->
user
));
taosEncryptPass
((
uint8_t
*
)
pass
,
strlen
(
pass
),
pObj
->
pass
);
secretEncryptLen
=
MIN
(
secretEncryptLen
,
sizeof
(
pObj
->
pass
));
memcpy
(
pObj
->
pass
,
secretEncrypt
,
secretEncryptLen
);
if
(
db
)
{
if
(
db
)
{
int32_t
len
=
(
int32_t
)
strlen
(
db
);
int32_t
len
=
(
int32_t
)
strlen
(
db
);
...
@@ -144,20 +165,17 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
...
@@ -144,20 +165,17 @@ static void syncConnCallback(void *param, TAOS_RES *tres, int code) {
tsem_post
(
&
pSql
->
rspSem
);
tsem_post
(
&
pSql
->
rspSem
);
}
}
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
)
{
TAOS
*
taos_connect_internal
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
auth
,
const
char
*
db
,
tscDebug
(
"try to create a connection to %s:%u, user:%s db:%s"
,
ip
,
port
,
user
,
db
);
uint16_t
port
)
{
if
(
user
==
NULL
)
user
=
TSDB_DEFAULT_USER
;
STscObj
*
pObj
=
NULL
;
if
(
pass
==
NULL
)
pass
=
TSDB_DEFAULT_PASS
;
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
auth
,
db
,
port
,
syncConnCallback
,
NULL
,
(
void
**
)
&
pObj
);
STscObj
*
pObj
=
NULL
;
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
db
,
port
,
syncConnCallback
,
NULL
,
(
void
**
)
&
pObj
);
if
(
pSql
!=
NULL
)
{
if
(
pSql
!=
NULL
)
{
pSql
->
fp
=
syncConnCallback
;
pSql
->
fp
=
syncConnCallback
;
pSql
->
param
=
pSql
;
pSql
->
param
=
pSql
;
tscProcessSql
(
pSql
);
tscProcessSql
(
pSql
);
tsem_wait
(
&
pSql
->
rspSem
);
tsem_wait
(
&
pSql
->
rspSem
);
if
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
if
(
pSql
->
res
.
code
!=
TSDB_CODE_SUCCESS
)
{
terrno
=
pSql
->
res
.
code
;
terrno
=
pSql
->
res
.
code
;
taos_free_result
(
pSql
);
taos_free_result
(
pSql
);
...
@@ -182,23 +200,38 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
...
@@ -182,23 +200,38 @@ TAOS *taos_connect(const char *ip, const char *user, const char *pass, const cha
return
NULL
;
return
NULL
;
}
}
TAOS
*
taos_connect_c
(
const
char
*
ip
,
uint8_t
ipLen
,
const
char
*
user
,
uint8_t
userLen
,
TAOS
*
taos_connect
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
pass
,
const
char
*
db
,
uint16_t
port
)
{
const
char
*
pass
,
uint8_t
passLen
,
const
char
*
db
,
uint8_t
dbLen
,
uint16_t
port
)
{
tscDebug
(
"try to create a connection to %s:%u, user:%s db:%s"
,
ip
,
port
,
user
,
db
);
char
ipBuf
[
TSDB_EP_LEN
]
=
{
0
};
if
(
user
==
NULL
)
user
=
TSDB_DEFAULT_USER
;
char
userBuf
[
TSDB_USER_LEN
]
=
{
0
};
if
(
pass
==
NULL
)
pass
=
TSDB_DEFAULT_PASS
;
char
passBuf
[
TSDB_PASSWORD_LEN
]
=
{
0
};
char
dbBuf
[
TSDB_DB_NAME_LEN
]
=
{
0
};
return
taos_connect_internal
(
ip
,
user
,
pass
,
NULL
,
db
,
port
);
strncpy
(
ipBuf
,
ip
,
MIN
(
TSDB_EP_LEN
-
1
,
ipLen
));
}
strncpy
(
userBuf
,
user
,
MIN
(
TSDB_USER_LEN
-
1
,
userLen
));
strncpy
(
passBuf
,
pass
,
MIN
(
TSDB_PASSWORD_LEN
-
1
,
passLen
));
TAOS
*
taos_connect_auth
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
)
{
strncpy
(
dbBuf
,
db
,
MIN
(
TSDB_DB_NAME_LEN
-
1
,
dbLen
));
tscDebug
(
"try to create a connection to %s:%u by auth, user:%s db:%s"
,
ip
,
port
,
user
,
db
);
return
taos_connect
(
ipBuf
,
userBuf
,
passBuf
,
dbBuf
,
port
);
if
(
user
==
NULL
)
user
=
TSDB_DEFAULT_USER
;
if
(
auth
==
NULL
)
return
NULL
;
return
taos_connect_internal
(
ip
,
user
,
NULL
,
auth
,
db
,
port
);
}
}
TAOS
*
taos_connect_c
(
const
char
*
ip
,
uint8_t
ipLen
,
const
char
*
user
,
uint8_t
userLen
,
const
char
*
pass
,
uint8_t
passLen
,
const
char
*
db
,
uint8_t
dbLen
,
uint16_t
port
)
{
char
ipBuf
[
TSDB_EP_LEN
]
=
{
0
};
char
userBuf
[
TSDB_USER_LEN
]
=
{
0
};
char
passBuf
[
TSDB_PASSWORD_LEN
]
=
{
0
};
char
dbBuf
[
TSDB_DB_NAME_LEN
]
=
{
0
};
strncpy
(
ipBuf
,
ip
,
MIN
(
TSDB_EP_LEN
-
1
,
ipLen
));
strncpy
(
userBuf
,
user
,
MIN
(
TSDB_USER_LEN
-
1
,
userLen
));
strncpy
(
passBuf
,
pass
,
MIN
(
TSDB_PASSWORD_LEN
-
1
,
passLen
));
strncpy
(
dbBuf
,
db
,
MIN
(
TSDB_DB_NAME_LEN
-
1
,
dbLen
));
return
taos_connect
(
ipBuf
,
userBuf
,
passBuf
,
dbBuf
,
port
);
}
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
TAOS
*
taos_connect_a
(
char
*
ip
,
char
*
user
,
char
*
pass
,
char
*
db
,
uint16_t
port
,
void
(
*
fp
)(
void
*
,
TAOS_RES
*
,
int
),
void
*
param
,
void
**
taos
)
{
void
*
param
,
void
**
taos
)
{
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
db
,
port
,
fp
,
param
,
taos
);
SSqlObj
*
pSql
=
taosConnectImpl
(
ip
,
user
,
pass
,
NULL
,
db
,
port
,
fp
,
param
,
taos
);
if
(
pSql
==
NULL
)
{
if
(
pSql
==
NULL
)
{
return
NULL
;
return
NULL
;
}
}
...
...
src/client/src/tscSystem.c
浏览文件 @
920cfc59
...
@@ -47,10 +47,8 @@ void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
...
@@ -47,10 +47,8 @@ void tscCheckDiskUsage(void *UNUSED_PARAM(para), void* UNUSED_PARAM(param)) {
taosTmrReset
(
tscCheckDiskUsage
,
1000
,
NULL
,
tscTmr
,
&
tscCheckDiskUsageTmr
);
taosTmrReset
(
tscCheckDiskUsage
,
1000
,
NULL
,
tscTmr
,
&
tscCheckDiskUsageTmr
);
}
}
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
,
void
**
pDnodeConn
)
{
int32_t
tscInitRpc
(
const
char
*
user
,
const
char
*
secret
Encrypt
,
void
**
pDnodeConn
)
{
SRpcInit
rpcInit
;
SRpcInit
rpcInit
;
char
secretEncrypt
[
32
]
=
{
0
};
taosEncryptPass
((
uint8_t
*
)
secret
,
strlen
(
secret
),
secretEncrypt
);
if
(
*
pDnodeConn
==
NULL
)
{
if
(
*
pDnodeConn
==
NULL
)
{
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
...
@@ -60,11 +58,11 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
...
@@ -60,11 +58,11 @@ int32_t tscInitRpc(const char *user, const char *secret, void** pDnodeConn) {
rpcInit
.
cfp
=
tscProcessMsgFromServer
;
rpcInit
.
cfp
=
tscProcessMsgFromServer
;
rpcInit
.
sessions
=
tsMaxConnections
;
rpcInit
.
sessions
=
tsMaxConnections
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
connType
=
TAOS_CONN_CLIENT
;
rpcInit
.
user
=
(
char
*
)
user
;
rpcInit
.
user
=
(
char
*
)
user
;
rpcInit
.
idleTime
=
2000
;
rpcInit
.
idleTime
=
2000
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
spi
=
1
;
rpcInit
.
spi
=
1
;
rpcInit
.
secret
=
secretEncrypt
;
rpcInit
.
secret
=
(
char
*
)
secretEncrypt
;
*
pDnodeConn
=
rpcOpen
(
&
rpcInit
);
*
pDnodeConn
=
rpcOpen
(
&
rpcInit
);
if
(
*
pDnodeConn
==
NULL
)
{
if
(
*
pDnodeConn
==
NULL
)
{
...
...
src/common/inc/tglobal.h
浏览文件 @
920cfc59
...
@@ -113,6 +113,7 @@ extern char tsInternalPass[];
...
@@ -113,6 +113,7 @@ extern char tsInternalPass[];
extern
int32_t
tsMonitorInterval
;
extern
int32_t
tsMonitorInterval
;
// internal
// internal
extern
int32_t
tsPrintAuth
;
extern
int32_t
tscEmbedded
;
extern
int32_t
tscEmbedded
;
extern
char
configDir
[];
extern
char
configDir
[];
extern
char
tsVnodeDir
[];
extern
char
tsVnodeDir
[];
...
...
src/common/src/tglobal.c
浏览文件 @
920cfc59
...
@@ -146,6 +146,7 @@ char tsInternalPass[] = "secretkey";
...
@@ -146,6 +146,7 @@ char tsInternalPass[] = "secretkey";
int32_t
tsMonitorInterval
=
30
;
// seconds
int32_t
tsMonitorInterval
=
30
;
// seconds
// internal
// internal
int32_t
tsPrintAuth
=
0
;
int32_t
tscEmbedded
=
0
;
int32_t
tscEmbedded
=
0
;
char
configDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
configDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsVnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
char
tsVnodeDir
[
TSDB_FILENAME_LEN
]
=
{
0
};
...
...
src/dnode/src/dnodeSystem.c
浏览文件 @
920cfc59
...
@@ -52,6 +52,8 @@ int32_t main(int32_t argc, char *argv[]) {
...
@@ -52,6 +52,8 @@ int32_t main(int32_t argc, char *argv[]) {
}
else
if
(
strcmp
(
argv
[
i
],
"-k"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-k"
)
==
0
)
{
grantParseParameter
();
grantParseParameter
();
exit
(
EXIT_SUCCESS
);
exit
(
EXIT_SUCCESS
);
}
else
if
(
strcmp
(
argv
[
i
],
"-A"
)
==
0
)
{
tsPrintAuth
=
1
;
}
}
#ifdef TAOS_MEM_CHECK
#ifdef TAOS_MEM_CHECK
else
if
(
strcmp
(
argv
[
i
],
"--alloc-random-fail"
)
==
0
)
{
else
if
(
strcmp
(
argv
[
i
],
"--alloc-random-fail"
)
==
0
)
{
...
...
src/kit/shell/inc/shell.h
浏览文件 @
920cfc59
...
@@ -39,6 +39,7 @@ typedef struct SShellArguments {
...
@@ -39,6 +39,7 @@ typedef struct SShellArguments {
char
*
host
;
char
*
host
;
char
*
password
;
char
*
password
;
char
*
user
;
char
*
user
;
char
*
auth
;
char
*
database
;
char
*
database
;
char
*
timezone
;
char
*
timezone
;
bool
is_raw_time
;
bool
is_raw_time
;
...
...
src/kit/shell/src/shellDarwin.c
浏览文件 @
920cfc59
...
@@ -32,16 +32,16 @@ void insertChar(Command *cmd, char *c, int size);
...
@@ -32,16 +32,16 @@ void insertChar(Command *cmd, char *c, int size);
void
printHelp
()
{
void
printHelp
()
{
char
indent
[
10
]
=
" "
;
char
indent
[
10
]
=
" "
;
printf
(
"taos shell is used to test the TD
E
ngine database
\n
"
);
printf
(
"taos shell is used to test the TD
e
ngine database
\n
"
);
printf
(
"%s%s
\n
"
,
indent
,
"-h"
);
printf
(
"%s%s
\n
"
,
indent
,
"-h"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"TD
E
ngine server IP address to connect. The default host is localhost."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"TD
e
ngine server IP address to connect. The default host is localhost."
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The password to use when connecting to the server."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The password to use when connecting to the server."
);
printf
(
"%s%s
\n
"
,
indent
,
"-P"
);
printf
(
"%s%s
\n
"
,
indent
,
"-P"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The TCP/IP port number to use for the connection"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The TCP/IP port number to use for the connection"
);
printf
(
"%s%s
\n
"
,
indent
,
"-u"
);
printf
(
"%s%s
\n
"
,
indent
,
"-u"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The
TDEngine
user name to use when connecting to the server."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The user name to use when connecting to the server."
);
printf
(
"%s%s
\n
"
,
indent
,
"-c"
);
printf
(
"%s%s
\n
"
,
indent
,
"-c"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Configuration directory."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Configuration directory."
);
printf
(
"%s%s
\n
"
,
indent
,
"-s"
);
printf
(
"%s%s
\n
"
,
indent
,
"-s"
);
...
...
src/kit/shell/src/shellEngine.c
浏览文件 @
920cfc59
...
@@ -38,6 +38,7 @@ SShellHistory history;
...
@@ -38,6 +38,7 @@ SShellHistory history;
#define DEFAULT_MAX_BINARY_DISPLAY_WIDTH 30
#define DEFAULT_MAX_BINARY_DISPLAY_WIDTH 30
extern
int32_t
tsMaxBinaryDisplayWidth
;
extern
int32_t
tsMaxBinaryDisplayWidth
;
extern
TAOS
*
taos_connect_auth
(
const
char
*
ip
,
const
char
*
user
,
const
char
*
auth
,
const
char
*
db
,
uint16_t
port
);
/*
/*
* FUNCTION: Initialize the shell.
* FUNCTION: Initialize the shell.
...
@@ -70,7 +71,13 @@ TAOS *shellInit(SShellArguments *args) {
...
@@ -70,7 +71,13 @@ TAOS *shellInit(SShellArguments *args) {
tsTableMetaKeepTimer
=
3000
;
tsTableMetaKeepTimer
=
3000
;
// Connect to the database.
// Connect to the database.
TAOS
*
con
=
taos_connect
(
args
->
host
,
args
->
user
,
args
->
password
,
args
->
database
,
args
->
port
);
TAOS
*
con
=
NULL
;
if
(
args
->
auth
==
NULL
)
{
con
=
taos_connect
(
args
->
host
,
args
->
user
,
args
->
password
,
args
->
database
,
args
->
port
);
}
else
{
con
=
taos_connect_auth
(
args
->
host
,
args
->
user
,
args
->
auth
,
args
->
database
,
args
->
port
);
}
if
(
con
==
NULL
)
{
if
(
con
==
NULL
)
{
printf
(
"taos connect failed, reason: %s.
\n\n
"
,
tstrerror
(
terrno
));
printf
(
"taos connect failed, reason: %s.
\n\n
"
,
tstrerror
(
terrno
));
fflush
(
stdout
);
fflush
(
stdout
);
...
...
src/kit/shell/src/shellLinux.c
浏览文件 @
920cfc59
...
@@ -33,10 +33,11 @@ const char *argp_program_bug_address = "<support@taosdata.com>";
...
@@ -33,10 +33,11 @@ const char *argp_program_bug_address = "<support@taosdata.com>";
static
char
doc
[]
=
""
;
static
char
doc
[]
=
""
;
static
char
args_doc
[]
=
""
;
static
char
args_doc
[]
=
""
;
static
struct
argp_option
options
[]
=
{
static
struct
argp_option
options
[]
=
{
{
"host"
,
'h'
,
"HOST"
,
0
,
"TD
E
ngine server IP address to connect. The default host is localhost."
},
{
"host"
,
'h'
,
"HOST"
,
0
,
"TD
e
ngine server IP address to connect. The default host is localhost."
},
{
"password"
,
'p'
,
"PASSWORD"
,
OPTION_ARG_OPTIONAL
,
"The password to use when connecting to the server."
},
{
"password"
,
'p'
,
"PASSWORD"
,
OPTION_ARG_OPTIONAL
,
"The password to use when connecting to the server."
},
{
"port"
,
'P'
,
"PORT"
,
0
,
"The TCP/IP port number to use for the connection."
},
{
"port"
,
'P'
,
"PORT"
,
0
,
"The TCP/IP port number to use for the connection."
},
{
"user"
,
'u'
,
"USER"
,
0
,
"The TDEngine user name to use when connecting to the server."
},
{
"user"
,
'u'
,
"USER"
,
0
,
"The user name to use when connecting to the server."
},
{
"user"
,
'A'
,
"Auth"
,
0
,
"The user auth to use when connecting to the server."
},
{
"config-dir"
,
'c'
,
"CONFIG_DIR"
,
0
,
"Configuration directory."
},
{
"config-dir"
,
'c'
,
"CONFIG_DIR"
,
0
,
"Configuration directory."
},
{
"commands"
,
's'
,
"COMMANDS"
,
0
,
"Commands to run without enter the shell."
},
{
"commands"
,
's'
,
"COMMANDS"
,
0
,
"Commands to run without enter the shell."
},
{
"raw-time"
,
'r'
,
0
,
0
,
"Output time as uint64_t."
},
{
"raw-time"
,
'r'
,
0
,
0
,
"Output time as uint64_t."
},
...
@@ -76,11 +77,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
...
@@ -76,11 +77,14 @@ static error_t parse_opt(int key, char *arg, struct argp_state *state) {
case
'u'
:
case
'u'
:
arguments
->
user
=
arg
;
arguments
->
user
=
arg
;
break
;
break
;
case
'A'
:
arguments
->
auth
=
arg
;
break
;
case
'c'
:
case
'c'
:
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
if
(
wordexp
(
arg
,
&
full_path
,
0
)
!=
0
)
{
fprintf
(
stderr
,
"Invalid path %s
\n
"
,
arg
);
fprintf
(
stderr
,
"Invalid path %s
\n
"
,
arg
);
return
-
1
;
return
-
1
;
}
}
if
(
strlen
(
full_path
.
we_wordv
[
0
])
>=
TSDB_FILENAME_LEN
)
{
if
(
strlen
(
full_path
.
we_wordv
[
0
])
>=
TSDB_FILENAME_LEN
)
{
fprintf
(
stderr
,
"config file path: %s overflow max len %d
\n
"
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
-
1
);
fprintf
(
stderr
,
"config file path: %s overflow max len %d
\n
"
,
full_path
.
we_wordv
[
0
],
TSDB_FILENAME_LEN
-
1
);
wordfree
(
&
full_path
);
wordfree
(
&
full_path
);
...
...
src/kit/shell/src/shellWindows.c
浏览文件 @
920cfc59
...
@@ -21,16 +21,18 @@ extern char configDir[];
...
@@ -21,16 +21,18 @@ extern char configDir[];
void
printHelp
()
{
void
printHelp
()
{
char
indent
[
10
]
=
" "
;
char
indent
[
10
]
=
" "
;
printf
(
"taos shell is used to test the TD
E
ngine database
\n
"
);
printf
(
"taos shell is used to test the TD
e
ngine database
\n
"
);
printf
(
"%s%s
\n
"
,
indent
,
"-h"
);
printf
(
"%s%s
\n
"
,
indent
,
"-h"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"TD
E
ngine server IP address to connect. The default host is localhost."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"TD
e
ngine server IP address to connect. The default host is localhost."
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The password to use when connecting to the server."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The password to use when connecting to the server."
);
printf
(
"%s%s
\n
"
,
indent
,
"-P"
);
printf
(
"%s%s
\n
"
,
indent
,
"-P"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The TCP/IP port number to use for the connection"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The TCP/IP port number to use for the connection"
);
printf
(
"%s%s
\n
"
,
indent
,
"-u"
);
printf
(
"%s%s
\n
"
,
indent
,
"-u"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The TDEngine user name to use when connecting to the server."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The user name to use when connecting to the server."
);
printf
(
"%s%s
\n
"
,
indent
,
"-A"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"The user auth to use when connecting to the server."
);
printf
(
"%s%s
\n
"
,
indent
,
"-c"
);
printf
(
"%s%s
\n
"
,
indent
,
"-c"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Configuration directory."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"Configuration directory."
);
printf
(
"%s%s
\n
"
,
indent
,
"-s"
);
printf
(
"%s%s
\n
"
,
indent
,
"-s"
);
...
@@ -79,6 +81,13 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
...
@@ -79,6 +81,13 @@ void shellParseArgument(int argc, char *argv[], SShellArguments *arguments) {
fprintf
(
stderr
,
"option -u requires an argument
\n
"
);
fprintf
(
stderr
,
"option -u requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
}
else
if
(
strcmp
(
argv
[
i
],
"-A"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
arguments
->
auth
=
argv
[
++
i
];
}
else
{
fprintf
(
stderr
,
"option -A requires an argument
\n
"
);
exit
(
EXIT_FAILURE
);
}
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
}
else
if
(
strcmp
(
argv
[
i
],
"-c"
)
==
0
)
{
if
(
i
<
argc
-
1
)
{
if
(
i
<
argc
-
1
)
{
if
(
strlen
(
argv
[
++
i
])
>=
TSDB_FILENAME_LEN
)
{
if
(
strlen
(
argv
[
++
i
])
>=
TSDB_FILENAME_LEN
)
{
...
...
src/kit/taosdemo/taosdemo.c
浏览文件 @
920cfc59
...
@@ -85,9 +85,9 @@ typedef struct DemoArguments {
...
@@ -85,9 +85,9 @@ typedef struct DemoArguments {
#ifdef LINUX
#ifdef LINUX
/* The options we understand. */
/* The options we understand. */
static
struct
argp_option
options
[]
=
{
static
struct
argp_option
options
[]
=
{
{
0
,
'h'
,
"host"
,
0
,
"The host to connect to TD
E
ngine. Default is localhost."
,
0
},
{
0
,
'h'
,
"host"
,
0
,
"The host to connect to TD
e
ngine. Default is localhost."
,
0
},
{
0
,
'p'
,
"port"
,
0
,
"The TCP/IP port number to use for the connection. Default is 0."
,
1
},
{
0
,
'p'
,
"port"
,
0
,
"The TCP/IP port number to use for the connection. Default is 0."
,
1
},
{
0
,
'u'
,
"user"
,
0
,
"The TD
E
ngine user name to use when connecting to the server. Default is 'root'."
,
2
},
{
0
,
'u'
,
"user"
,
0
,
"The TD
e
ngine user name to use when connecting to the server. Default is 'root'."
,
2
},
{
0
,
'P'
,
"password"
,
0
,
"The password to use when connecting to the server. Default is 'taosdata'."
,
3
},
{
0
,
'P'
,
"password"
,
0
,
"The password to use when connecting to the server. Default is 'taosdata'."
,
3
},
{
0
,
'd'
,
"database"
,
0
,
"Destination database. Default is 'test'."
,
3
},
{
0
,
'd'
,
"database"
,
0
,
"Destination database. Default is 'test'."
,
3
},
{
0
,
'm'
,
"table_prefix"
,
0
,
"Table prefix name. Default is 't'."
,
3
},
{
0
,
'm'
,
"table_prefix"
,
0
,
"Table prefix name. Default is 't'."
,
3
},
...
@@ -264,11 +264,11 @@ typedef struct DemoArguments {
...
@@ -264,11 +264,11 @@ typedef struct DemoArguments {
void
printHelp
()
{
void
printHelp
()
{
char
indent
[
10
]
=
" "
;
char
indent
[
10
]
=
" "
;
printf
(
"%s%s
\n
"
,
indent
,
"-h"
);
printf
(
"%s%s
\n
"
,
indent
,
"-h"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"host, The host to connect to TD
E
ngine. Default is localhost."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"host, The host to connect to TD
e
ngine. Default is localhost."
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"port, The TCP/IP port number to use for the connection. Default is 0."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"port, The TCP/IP port number to use for the connection. Default is 0."
);
printf
(
"%s%s
\n
"
,
indent
,
"-u"
);
printf
(
"%s%s
\n
"
,
indent
,
"-u"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"user, The
TDEngine
user name to use when connecting to the server. Default is 'root'."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"user, The user name to use when connecting to the server. Default is 'root'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s
\n
"
,
indent
,
"-p"
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"password, The password to use when connecting to the server. Default is 'taosdata'."
);
printf
(
"%s%s%s
\n
"
,
indent
,
indent
,
"password, The password to use when connecting to the server. Default is 'taosdata'."
);
printf
(
"%s%s
\n
"
,
indent
,
"-d"
);
printf
(
"%s%s
\n
"
,
indent
,
"-d"
);
...
...
src/mnode/src/mnodeUser.c
浏览文件 @
920cfc59
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include "tglobal.h"
#include "tglobal.h"
#include "tgrant.h"
#include "tgrant.h"
#include "tdataformat.h"
#include "tdataformat.h"
#include "tkey.h"
#include "mnode.h"
#include "mnode.h"
#include "dnode.h"
#include "dnode.h"
#include "mnodeDef.h"
#include "mnodeDef.h"
...
@@ -100,6 +101,32 @@ static int32_t mnodeUserActionDecode(SSdbOper *pOper) {
...
@@ -100,6 +101,32 @@ static int32_t mnodeUserActionDecode(SSdbOper *pOper) {
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
static
void
mnodePrintUserAuth
()
{
FILE
*
fp
=
fopen
(
"auth.txt"
,
"w"
);
if
(
!
fp
)
{
mDebug
(
"failed to auth.txt for write"
);
return
;
}
void
*
pIter
=
NULL
;
SUserObj
*
pUser
=
NULL
;
while
(
1
)
{
pIter
=
mnodeGetNextUser
(
pIter
,
&
pUser
);
if
(
pUser
==
NULL
)
break
;
char
*
base64
=
base64_encode
((
const
unsigned
char
*
)
pUser
->
pass
,
TSDB_KEY_LEN
*
2
);
fprintf
(
fp
,
"user:%24s auth:%s
\n
"
,
pUser
->
user
,
base64
);
free
(
base64
);
mnodeDecUserRef
(
pUser
);
}
fflush
(
fp
);
sdbFreeIter
(
pIter
);
fclose
(
fp
);
}
static
int32_t
mnodeUserActionRestored
()
{
static
int32_t
mnodeUserActionRestored
()
{
int32_t
numOfRows
=
sdbGetNumOfRows
(
tsUserSdb
);
int32_t
numOfRows
=
sdbGetNumOfRows
(
tsUserSdb
);
if
(
numOfRows
<=
0
&&
dnodeIsFirstDeploy
())
{
if
(
numOfRows
<=
0
&&
dnodeIsFirstDeploy
())
{
...
@@ -111,6 +138,11 @@ static int32_t mnodeUserActionRestored() {
...
@@ -111,6 +138,11 @@ static int32_t mnodeUserActionRestored() {
mnodeDecAcctRef
(
pAcct
);
mnodeDecAcctRef
(
pAcct
);
}
}
if
(
tsPrintAuth
!=
0
)
{
mInfo
(
"print user auth, for -A parameter is set"
);
mnodePrintUserAuth
();
}
return
TSDB_CODE_SUCCESS
;
return
TSDB_CODE_SUCCESS
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录