Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9bcc8648
T
TDengine
项目概览
taosdata
/
TDengine
11 个月 前同步成功
通知
1179
Star
22014
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
9bcc8648
编写于
1月 06, 2023
作者:
S
Shengliang Guan
提交者:
GitHub
1月 06, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #19411 from taosdata/fix/TS-2382_2
fix: remove privilege info on drop db / topic
上级
602338b6
5e9a90ef
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
109 addition
and
40 deletion
+109
-40
source/dnode/mnode/impl/inc/mndUser.h
source/dnode/mnode/impl/inc/mndUser.h
+2
-0
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+1
-11
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+10
-11
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+96
-18
未找到文件。
source/dnode/mnode/impl/inc/mndUser.h
浏览文件 @
9bcc8648
...
...
@@ -34,6 +34,8 @@ SHashObj *mndDupDbHash(SHashObj *pOld);
SHashObj
*
mndDupTopicHash
(
SHashObj
*
pOld
);
int32_t
mndValidateUserAuthInfo
(
SMnode
*
pMnode
,
SUserAuthVersion
*
pUsers
,
int32_t
numOfUses
,
void
**
ppRsp
,
int32_t
*
pRspLen
);
int32_t
mndUserRemoveDb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
char
*
db
);
int32_t
mndUserRemoveTopic
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
char
*
topic
);
#ifdef __cplusplus
}
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
9bcc8648
...
...
@@ -1051,17 +1051,7 @@ static int32_t mndDropDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb) {
if
(
mndDropStreamByDb
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndDropSmasByDb
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
if
(
mndSetDropDbRedoActions
(
pMnode
,
pTrans
,
pDb
)
!=
0
)
goto
_OVER
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pDb
->
createUser
);
if
(
pUser
!=
NULL
)
{
pUser
->
authVersion
++
;
SSdbRaw
*
pCommitRaw
=
mndUserActionEncode
(
pUser
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append redo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
_OVER
;
}
(
void
)
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
}
if
(
mndUserRemoveDb
(
pMnode
,
pTrans
,
pDb
->
name
)
!=
0
)
goto
_OVER
;
int32_t
rspLen
=
0
;
void
*
pRsp
=
NULL
;
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
9bcc8648
...
...
@@ -604,22 +604,19 @@ _OVER:
}
static
int32_t
mndDropTopic
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
SRpcMsg
*
pReq
,
SMqTopicObj
*
pTopic
)
{
int32_t
code
=
-
1
;
if
(
mndUserRemoveTopic
(
pMnode
,
pTrans
,
pTopic
->
name
)
!=
0
)
goto
_OVER
;
SSdbRaw
*
pCommitRaw
=
mndTopicActionEncode
(
pTopic
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
{
mError
(
"trans:%d, failed to append commit log since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
goto
_OVER
;
(
void
)
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_DROPPED
);
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
mndTransDrop
(
pTrans
);
return
-
1
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
_OVER
;
code
=
0
;
_OVER:
mndTransDrop
(
pTrans
);
return
0
;
return
code
;
}
static
int32_t
mndProcessDropTopicReq
(
SRpcMsg
*
pReq
)
{
...
...
@@ -890,6 +887,7 @@ int32_t mndCheckTopicExist(SMnode *pMnode, SDbObj *pDb) {
return
0
;
}
#if 0
int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
int32_t code = 0;
SSdb *pSdb = pMnode->pSdb;
...
...
@@ -917,3 +915,4 @@ int32_t mndDropTopicByDB(SMnode *pMnode, STrans *pTrans, SDbObj *pDb) {
return code;
}
#endif
\ No newline at end of file
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
9bcc8648
...
...
@@ -285,14 +285,35 @@ static int32_t mndUserActionInsert(SSdb *pSdb, SUserObj *pUser) {
return
0
;
}
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
)
{
mTrace
(
"user:%s, perform delete action, row:%p"
,
pUser
->
user
,
pUser
);
static
int32_t
mndUserDupObj
(
SUserObj
*
pUser
,
SUserObj
*
pNew
)
{
memcpy
(
pNew
,
pUser
,
sizeof
(
SUserObj
));
pNew
->
authVersion
++
;
pNew
->
updateTime
=
taosGetTimestampMs
();
taosRLockLatch
(
&
pUser
->
lock
);
pNew
->
readDbs
=
mndDupDbHash
(
pUser
->
readDbs
);
pNew
->
writeDbs
=
mndDupDbHash
(
pUser
->
writeDbs
);
pNew
->
topics
=
mndDupTopicHash
(
pUser
->
topics
);
taosRUnLockLatch
(
&
pUser
->
lock
);
if
(
pNew
->
readDbs
==
NULL
||
pNew
->
writeDbs
==
NULL
||
pNew
->
topics
==
NULL
)
{
return
-
1
;
}
return
0
;
}
static
void
mndUserFreeObj
(
SUserObj
*
pUser
)
{
taosHashCleanup
(
pUser
->
readDbs
);
taosHashCleanup
(
pUser
->
writeDbs
);
taosHashCleanup
(
pUser
->
topics
);
pUser
->
readDbs
=
NULL
;
pUser
->
writeDbs
=
NULL
;
pUser
->
topics
=
NULL
;
}
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
)
{
mTrace
(
"user:%s, perform delete action, row:%p"
,
pUser
->
user
,
pUser
);
mndUserFreeObj
(
pUser
);
return
0
;
}
...
...
@@ -516,19 +537,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
memcpy
(
&
newUser
,
pUser
,
sizeof
(
SUserObj
));
newUser
.
authVersion
++
;
newUser
.
updateTime
=
taosGetTimestampMs
();
taosRLockLatch
(
&
pUser
->
lock
);
newUser
.
readDbs
=
mndDupDbHash
(
pUser
->
readDbs
);
newUser
.
writeDbs
=
mndDupDbHash
(
pUser
->
writeDbs
);
newUser
.
topics
=
mndDupTopicHash
(
pUser
->
topics
);
taosRUnLockLatch
(
&
pUser
->
lock
);
if
(
newUser
.
readDbs
==
NULL
||
newUser
.
writeDbs
==
NULL
||
newUser
.
topics
==
NULL
)
{
goto
_OVER
;
}
if
(
mndUserDupObj
(
pUser
,
&
newUser
)
!=
0
)
goto
_OVER
;
if
(
alterReq
.
alterType
==
TSDB_ALTER_USER_PASSWD
)
{
char
pass
[
TSDB_PASSWORD_LEN
+
1
]
=
{
0
};
...
...
@@ -654,9 +663,7 @@ _OVER:
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
taosHashCleanup
(
newUser
.
writeDbs
);
taosHashCleanup
(
newUser
.
readDbs
);
taosHashCleanup
(
newUser
.
topics
);
mndUserFreeObj
(
&
newUser
);
return
code
;
}
...
...
@@ -1007,3 +1014,74 @@ _OVER:
tFreeSUserAuthBatchRsp
(
&
batchRsp
);
return
code
;
}
int32_t
mndUserRemoveDb
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
char
*
db
)
{
int32_t
code
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
len
=
strlen
(
db
)
+
1
;
void
*
pIter
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SUserObj
newUser
=
{
0
};
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_USER
,
pIter
,
(
void
**
)
&
pUser
);
if
(
pIter
==
NULL
)
break
;
code
=
-
1
;
if
(
mndUserDupObj
(
pUser
,
&
newUser
)
!=
0
)
break
;
bool
inRead
=
(
taosHashGet
(
newUser
.
readDbs
,
db
,
len
)
!=
NULL
);
bool
inWrite
=
(
taosHashGet
(
newUser
.
writeDbs
,
db
,
len
)
!=
NULL
);
if
(
inRead
||
inWrite
)
{
(
void
)
taosHashRemove
(
newUser
.
readDbs
,
db
,
len
);
(
void
)
taosHashRemove
(
newUser
.
writeDbs
,
db
,
len
);
SSdbRaw
*
pCommitRaw
=
mndUserActionEncode
(
&
newUser
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
break
;
(
void
)
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
}
mndUserFreeObj
(
&
newUser
);
sdbRelease
(
pSdb
,
pUser
);
code
=
0
;
}
if
(
pUser
!=
NULL
)
sdbRelease
(
pSdb
,
pUser
);
if
(
pIter
!=
NULL
)
sdbCancelFetch
(
pSdb
,
pIter
);
mndUserFreeObj
(
&
newUser
);
return
code
;
}
int32_t
mndUserRemoveTopic
(
SMnode
*
pMnode
,
STrans
*
pTrans
,
char
*
topic
)
{
int32_t
code
=
0
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
len
=
strlen
(
topic
)
+
1
;
void
*
pIter
=
NULL
;
SUserObj
*
pUser
=
NULL
;
SUserObj
newUser
=
{
0
};
while
(
1
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_USER
,
pIter
,
(
void
**
)
&
pUser
);
if
(
pIter
==
NULL
)
break
;
code
=
-
1
;
if
(
mndUserDupObj
(
pUser
,
&
newUser
)
!=
0
)
break
;
bool
inTopic
=
(
taosHashGet
(
newUser
.
topics
,
topic
,
len
)
!=
NULL
);
if
(
inTopic
)
{
(
void
)
taosHashRemove
(
newUser
.
topics
,
topic
,
len
);
SSdbRaw
*
pCommitRaw
=
mndUserActionEncode
(
&
newUser
);
if
(
pCommitRaw
==
NULL
||
mndTransAppendCommitlog
(
pTrans
,
pCommitRaw
)
!=
0
)
break
;
(
void
)
sdbSetRawStatus
(
pCommitRaw
,
SDB_STATUS_READY
);
}
mndUserFreeObj
(
&
newUser
);
sdbRelease
(
pSdb
,
pUser
);
code
=
0
;
}
if
(
pUser
!=
NULL
)
sdbRelease
(
pSdb
,
pUser
);
if
(
pIter
!=
NULL
)
sdbCancelFetch
(
pSdb
,
pIter
);
mndUserFreeObj
(
&
newUser
);
return
code
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录