Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
3ed2cbef
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
3ed2cbef
编写于
4月 22, 2020
作者:
S
slguan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Modify the user code and pass the test case
上级
787f6387
变更
14
隐藏空白更改
内联
并排
Showing
14 changed file
with
66 addition
and
39 deletion
+66
-39
src/client/src/tscSystem.c
src/client/src/tscSystem.c
+9
-0
src/inc/taoserror.h
src/inc/taoserror.h
+9
-4
src/mnode/inc/mgmtUser.h
src/mnode/inc/mgmtUser.h
+1
-0
src/mnode/src/mgmtDnode.c
src/mnode/src/mgmtDnode.c
+1
-1
src/mnode/src/mgmtUser.c
src/mnode/src/mgmtUser.c
+37
-27
tests/script/basicSuite.sim
tests/script/basicSuite.sim
+1
-1
tests/script/general/user/basic1.sim
tests/script/general/user/basic1.sim
+1
-3
tests/script/general/user/basicSuite.sim
tests/script/general/user/basicSuite.sim
+1
-0
tests/script/general/user/monitor.sim
tests/script/general/user/monitor.sim
+0
-0
tests/script/general/user/pass_alter.sim
tests/script/general/user/pass_alter.sim
+0
-0
tests/script/general/user/pass_len.sim
tests/script/general/user/pass_len.sim
+0
-0
tests/script/general/user/testSuite.sim
tests/script/general/user/testSuite.sim
+6
-1
tests/script/general/user/user_create.sim
tests/script/general/user/user_create.sim
+0
-2
tests/script/general/user/user_len.sim
tests/script/general/user/user_len.sim
+0
-0
未找到文件。
src/client/src/tscSystem.c
浏览文件 @
3ed2cbef
...
...
@@ -42,6 +42,7 @@ void * tscTmr;
void
*
tscQhandle
;
void
*
tscCheckDiskUsageTmr
;
int
tsInsertHeadSize
;
char
tsLastUser
[
TSDB_USER_LEN
+
1
];
int
tscNumOfThreads
;
...
...
@@ -81,6 +82,13 @@ int32_t tscInitRpc(const char *user, const char *secret) {
}
}
// not stop service, switch users
if
(
strcmp
(
tsLastUser
,
user
)
!=
0
&&
pTscMgmtConn
!=
NULL
)
{
tscTrace
(
"switch user from %s to %s"
,
user
,
tsLastUser
);
rpcClose
(
pTscMgmtConn
);
pTscMgmtConn
=
NULL
;
}
if
(
pTscMgmtConn
==
NULL
)
{
memset
(
&
rpcInit
,
0
,
sizeof
(
rpcInit
));
rpcInit
.
localIp
=
tsLocalIp
;
...
...
@@ -94,6 +102,7 @@ int32_t tscInitRpc(const char *user, const char *secret) {
rpcInit
.
user
=
(
char
*
)
user
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
secret
=
secretEncrypt
;
strcpy
(
tsLastUser
,
user
);
pTscMgmtConn
=
rpcOpen
(
&
rpcInit
);
if
(
pTscMgmtConn
==
NULL
)
{
...
...
src/inc/taoserror.h
浏览文件 @
3ed2cbef
...
...
@@ -75,14 +75,19 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NOT_CONFIGURED, 0, 27, "not configured")
TAOS_DEFINE_ERROR
(
TSDB_CODE_NODE_OFFLINE
,
0
,
28
,
"node offline"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NETWORK_UNAVAIL
,
0
,
29
,
"network unavailable"
)
// db
& user
// db
TAOS_DEFINE_ERROR
(
TSDB_CODE_DB_NOT_SELECTED
,
0
,
100
,
"db not selected"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_DB_ALREADY_EXIST
,
0
,
101
,
"database aleady exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_DB
,
0
,
102
,
"invalid database"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_MONITOR_DB_FORBIDDEN
,
0
,
103
,
"monitor db forbidden"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_USER_ALREADY_EXIST
,
0
,
104
,
"user already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_USER
,
0
,
105
,
"invalid user"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_PASS
,
0
,
106
,
"invalid password"
)
// user
TAOS_DEFINE_ERROR
(
TSDB_CODE_USER_ALREADY_EXIST
,
0
,
150
,
"user already exist"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_USER
,
0
,
151
,
"invalid user"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_PASS
,
0
,
152
,
"invalid password"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_USER_FORMAT
,
0
,
153
,
"invalid user format"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_INVALID_PASS_FORMAT
,
0
,
154
,
"invalid password format"
)
TAOS_DEFINE_ERROR
(
TSDB_CODE_NO_USER_FROM_CONN
,
0
,
155
,
"can not get user from conn"
)
// table
TAOS_DEFINE_ERROR
(
TSDB_CODE_TABLE_ALREADY_EXIST
,
0
,
200
,
"table already exist"
)
...
...
src/mnode/inc/mgmtUser.h
浏览文件 @
3ed2cbef
...
...
@@ -24,6 +24,7 @@ extern "C" {
int32_t
mgmtInitUsers
();
void
mgmtCleanUpUsers
();
SUserObj
*
mgmtGetUser
(
char
*
name
);
void
*
mgmtGetNextUser
(
void
*
pNode
,
SUserObj
**
pUser
);
void
mgmtIncUserRef
(
SUserObj
*
pUser
);
void
mgmtDecUserRef
(
SUserObj
*
pUser
);
SUserObj
*
mgmtGetUserFromConn
(
void
*
pConn
,
bool
*
usePublicIp
);
...
...
src/mnode/src/mgmtDnode.c
浏览文件 @
3ed2cbef
...
...
@@ -336,7 +336,7 @@ void mgmtProcessDnodeStatusMsg(SRpcMsg *rpcMsg) {
if
(
pStatus
->
dnodeId
==
0
)
{
mTrace
(
"dnode:%d, first access, privateIp:%s, name:%s"
,
pDnode
->
dnodeId
,
taosIpStr
(
pDnode
->
privateIp
),
pDnode
->
dnodeName
);
}
else
{
mTrace
(
"dnode:%d, status received, access times %d"
,
pDnode
->
dnodeId
,
pDnode
->
lastAccess
);
//
mTrace("dnode:%d, status received, access times %d", pDnode->dnodeId, pDnode->lastAccess);
}
int32_t
openVnodes
=
htons
(
pStatus
->
openVnodes
);
...
...
src/mnode/src/mgmtUser.c
浏览文件 @
3ed2cbef
...
...
@@ -19,23 +19,23 @@
#include "ttime.h"
#include "tutil.h"
#include "tglobal.h"
#include "tgrant.h"
#include "dnode.h"
#include "mgmtDef.h"
#include "mgmtLog.h"
#include "mgmtAcct.h"
#include "tgrant.h"
#include "mgmtMnode.h"
#include "mgmtSdb.h"
#include "mgmtShell.h"
#include "mgmtUser.h"
void
*
tsUserSdb
=
NULL
;
static
void
*
tsUserSdb
=
NULL
;
static
int32_t
tsUserUpdateSize
=
0
;
static
int32_t
mgmtGetUserMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
);
static
int32_t
mgmtRetrieveUsers
(
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
,
void
*
pConn
);
static
void
mgmtProcessCreateUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessAlterUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessDropUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessCreateUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessAlterUserMsg
(
SQueuedMsg
*
pMsg
);
static
void
mgmtProcessDropUserMsg
(
SQueuedMsg
*
pMsg
);
static
int32_t
mgmtUserActionDestroy
(
SSdbOper
*
pOper
)
{
tfree
(
pOper
->
pObj
);
...
...
@@ -48,8 +48,8 @@ static int32_t mgmtUserActionInsert(SSdbOper *pOper) {
if
(
pAcct
!=
NULL
)
{
mgmtAddUserToAcct
(
pAcct
,
pUser
);
}
else
{
mgmtDecAcctRef
(
pAcct
);
}
else
{
mError
(
"user:%s, acct:%s info not exist in sdb"
,
pUser
->
user
,
pUser
->
acct
);
return
TSDB_CODE_INVALID_ACCT
;
}
...
...
@@ -86,7 +86,7 @@ static int32_t mgmtUserActionEncode(SSdbOper *pOper) {
}
static
int32_t
mgmtUserActionDecode
(
SSdbOper
*
pOper
)
{
SUserObj
*
pUser
=
(
SUserObj
*
)
calloc
(
1
,
sizeof
(
SUserObj
));
SUserObj
*
pUser
=
(
SUserObj
*
)
calloc
(
1
,
sizeof
(
SUserObj
));
if
(
pUser
==
NULL
)
return
TSDB_CODE_SERV_OUT_OF_MEMORY
;
memcpy
(
pUser
,
pOper
->
rowData
,
tsUserUpdateSize
);
...
...
@@ -103,7 +103,7 @@ static int32_t mgmtUserActionRestored() {
mgmtDecAcctRef
(
pAcct
);
}
return
0
;
return
TSDB_CODE_SUCCESS
;
}
int32_t
mgmtInitUsers
()
{
...
...
@@ -128,7 +128,7 @@ int32_t mgmtInitUsers() {
tsUserSdb
=
sdbOpenTable
(
&
tableDesc
);
if
(
tsUserSdb
==
NULL
)
{
mError
(
"
failed to init user data"
);
mError
(
"
table:%s, failed to create hash"
,
tableDesc
.
tableName
);
return
-
1
;
}
...
...
@@ -138,7 +138,7 @@ int32_t mgmtInitUsers() {
mgmtAddShellShowMetaHandle
(
TSDB_MGMT_TABLE_USER
,
mgmtGetUserMeta
);
mgmtAddShellShowRetrieveHandle
(
TSDB_MGMT_TABLE_USER
,
mgmtRetrieveUsers
);
mTrace
(
"table:
users table is created"
);
mTrace
(
"table:
%s, hash is created"
,
tableDesc
.
tableName
);
return
0
;
}
...
...
@@ -150,6 +150,10 @@ SUserObj *mgmtGetUser(char *name) {
return
(
SUserObj
*
)
sdbGetRow
(
tsUserSdb
,
name
);
}
void
*
mgmtGetNextUser
(
void
*
pNode
,
SUserObj
**
pUser
)
{
return
sdbFetchRow
(
tsUserSdb
,
pNode
,
(
void
**
)
pUser
);
}
void
mgmtIncUserRef
(
SUserObj
*
pUser
)
{
return
sdbIncRef
(
tsUserSdb
,
pUser
);
}
...
...
@@ -176,17 +180,21 @@ static int32_t mgmtUpdateUser(SUserObj *pUser) {
int32_t
mgmtCreateUser
(
SAcctObj
*
pAcct
,
char
*
name
,
char
*
pass
)
{
int32_t
code
=
acctCheck
(
pAcct
,
ACCT_GRANT_USER
);
if
(
code
!=
0
)
{
if
(
code
!=
TSDB_CODE_SUCCESS
)
{
return
code
;
}
if
(
name
[
0
]
==
0
||
pass
[
0
]
==
0
)
{
return
TSDB_CODE_INVALID_MSG_CONTENT
;
if
(
name
[
0
]
==
0
)
{
return
TSDB_CODE_INVALID_USER_FORMAT
;
}
if
(
pass
[
0
]
==
0
)
{
return
TSDB_CODE_INVALID_PASS_FORMAT
;
}
SUserObj
*
pUser
=
mgmtGetUser
(
name
);
if
(
pUser
!=
NULL
)
{
mTrace
(
"user:%s is already there"
,
name
);
mTrace
(
"user:%s
,
is already there"
,
name
);
mgmtDecUserRef
(
pUser
);
return
TSDB_CODE_USER_ALREADY_EXIST
;
}
...
...
@@ -241,10 +249,10 @@ static int32_t mgmtDropUser(SUserObj *pUser) {
static
int32_t
mgmtGetUserMeta
(
STableMetaMsg
*
pMeta
,
SShowObj
*
pShow
,
void
*
pConn
)
{
SUserObj
*
pUser
=
mgmtGetUserFromConn
(
pConn
,
NULL
);
if
(
pUser
==
NULL
)
{
return
TSDB_CODE_
INVALID_USER
;
return
TSDB_CODE_
NO_USER_FROM_CONN
;
}
int32_t
cols
=
0
;
int32_t
cols
=
0
;
SSchema
*
pSchema
=
pMeta
->
schema
;
pShow
->
bytes
[
cols
]
=
TSDB_USER_LEN
;
...
...
@@ -314,6 +322,7 @@ static int32_t mgmtRetrieveUsers(SShowObj *pShow, char *data, int32_t rows, void
numOfRows
++
;
mgmtDecUserRef
(
pUser
);
}
pShow
->
numOfReads
+=
numOfRows
;
return
numOfRows
;
}
...
...
@@ -325,20 +334,21 @@ SUserObj *mgmtGetUserFromConn(void *pConn, bool *usePublicIp) {
*
usePublicIp
=
(
connInfo
.
serverIp
==
tsPublicIpInt
);
}
return
mgmtGetUser
(
connInfo
.
user
);
}
else
{
mError
(
"can not get user from conn:%p"
,
pConn
);
return
NULL
;
}
return
NULL
;
}
static
void
mgmtProcessCreateUserMsg
(
SQueuedMsg
*
pMsg
)
{
int32_t
code
;
SUserObj
*
pUser
=
pMsg
->
pUser
;
SUserObj
*
p
Oper
User
=
pMsg
->
pUser
;
if
(
pUser
->
superAuth
)
{
if
(
p
Oper
User
->
superAuth
)
{
SCMCreateUserMsg
*
pCreate
=
pMsg
->
pCont
;
code
=
mgmtCreateUser
(
pUser
->
pAcct
,
pCreate
->
user
,
pCreate
->
pass
);
code
=
mgmtCreateUser
(
p
Oper
User
->
pAcct
,
pCreate
->
user
,
pCreate
->
pass
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"user:%s
is created by %s"
,
pCreate
->
user
,
p
User
->
user
);
mLPrint
(
"user:%s
, is created by %s"
,
pCreate
->
user
,
pOper
User
->
user
);
}
}
else
{
code
=
TSDB_CODE_NO_RIGHTS
;
...
...
@@ -384,7 +394,7 @@ static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg) {
memset
(
pUser
->
pass
,
0
,
sizeof
(
pUser
->
pass
));
taosEncryptPass
((
uint8_t
*
)
pAlter
->
pass
,
strlen
(
pAlter
->
pass
),
pUser
->
pass
);
code
=
mgmtUpdateUser
(
pUser
);
mLPrint
(
"user:%s
password is altered by %s, result:%d
"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
mLPrint
(
"user:%s
, password is altered by %s, result:%s
"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
}
else
{
code
=
TSDB_CODE_NO_RIGHTS
;
}
...
...
@@ -426,7 +436,7 @@ static void mgmtProcessAlterUserMsg(SQueuedMsg *pMsg) {
}
code
=
mgmtUpdateUser
(
pUser
);
mLPrint
(
"user:%s
privilege is altered by %s, result:%d
"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
mLPrint
(
"user:%s
, privilege is altered by %s, result:%s
"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
}
else
{
code
=
TSDB_CODE_NO_RIGHTS
;
}
...
...
@@ -447,7 +457,7 @@ static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg) {
SUserObj
*
pUser
=
mgmtGetUser
(
pDrop
->
user
);
if
(
pUser
==
NULL
)
{
mgmtSendSimpleResp
(
pMsg
->
thandle
,
TSDB_CODE_INVALID_USER
);
return
;
return
;
}
if
(
strcmp
(
pUser
->
user
,
"monitor"
)
==
0
||
strcmp
(
pUser
->
user
,
pUser
->
acct
)
==
0
||
...
...
@@ -475,7 +485,7 @@ static void mgmtProcessDropUserMsg(SQueuedMsg *pMsg) {
if
(
hasRight
)
{
code
=
mgmtDropUser
(
pUser
);
if
(
code
==
TSDB_CODE_SUCCESS
)
{
mLPrint
(
"user:%s
is dropped by %s, result:%s"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
mLPrint
(
"user:%s,
is dropped by %s, result:%s"
,
pUser
->
user
,
pOperUser
->
user
,
tstrerror
(
code
));
}
}
else
{
code
=
TSDB_CODE_NO_RIGHTS
;
...
...
tests/script/basicSuite.sim
浏览文件 @
3ed2cbef
...
...
@@ -3,6 +3,6 @@
run general/db/testSuite.sim
run general/insert/testSuite.sim
run general/table/testSuite.sim
run general/user/
test
Suite.sim
run general/user/
basic
Suite.sim
##################################
tests/script/general/user/basic1.sim
浏览文件 @
3ed2cbef
...
...
@@ -66,6 +66,4 @@ print $data10 $data11 $data22
print $data20 $data11 $data22
print $data30 $data31 $data32
system sh/exec.sh -n dnode1 -s stop
\ No newline at end of file
tests/script/general/user/basicSuite.sim
0 → 100644
浏览文件 @
3ed2cbef
run general/user/basic1.sim
\ No newline at end of file
tests/script/general/
account
/monitor.sim
→
tests/script/general/
user
/monitor.sim
浏览文件 @
3ed2cbef
文件已移动
tests/script/general/
account
/pass_alter.sim
→
tests/script/general/
user
/pass_alter.sim
浏览文件 @
3ed2cbef
文件已移动
tests/script/general/
account
/pass_len.sim
→
tests/script/general/
user
/pass_len.sim
浏览文件 @
3ed2cbef
文件已移动
tests/script/general/user/testSuite.sim
浏览文件 @
3ed2cbef
run general/user/basic1.sim
\ No newline at end of file
run general/user/basic1.sim
run general/user/pass_alter.sim
run general/user/pass_len.sim
run general/user/user_create.sim
run general/user/user_len.sim
#run general/user/monitor.sim
\ No newline at end of file
tests/script/general/
account
/user_create.sim
→
tests/script/general/
user
/user_create.sim
浏览文件 @
3ed2cbef
...
...
@@ -4,8 +4,6 @@ system sh/ip.sh -i 1 -s up
system sh/deploy.sh -n dnode1 -m 192.168.0.1 -i 192.168.0.1
system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect
print =============== step1
...
...
tests/script/general/
account
/user_len.sim
→
tests/script/general/
user
/user_len.sim
浏览文件 @
3ed2cbef
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录