Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
1fb2c664
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看板
未验证
提交
1fb2c664
编写于
6月 25, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
6月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14223 from taosdata/fix/tsim
refactor: rename auth to privilege
上级
570b36cb
d08835d5
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
34 addition
and
37 deletion
+34
-37
source/dnode/mnode/impl/inc/mndPrivilege.h
source/dnode/mnode/impl/inc/mndPrivilege.h
+1
-0
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+4
-0
source/dnode/mnode/impl/src/mndPrivilege.c
source/dnode/mnode/impl/src/mndPrivilege.c
+11
-9
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+12
-23
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+6
-2
tests/script/tsim/user/privilege_sysinfo.sim
tests/script/tsim/user/privilege_sysinfo.sim
+0
-3
未找到文件。
source/dnode/mnode/impl/inc/mndPrivilege.h
浏览文件 @
1fb2c664
...
...
@@ -64,6 +64,7 @@ void mndCleanupPrivilege(SMnode *pMnode);
int32_t
mndCheckOperPrivilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
);
int32_t
mndCheckDbPrivilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
);
int32_t
mndCheckDbPrivilegeByName
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
const
char
*
name
);
int32_t
mndCheckShowPrivilege
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
);
int32_t
mndCheckAlterUserPrivilege
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
);
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
1fb2c664
...
...
@@ -431,6 +431,10 @@ static int32_t mndProcessSubscribeReq(SRpcMsg *pMsg) {
goto
SUBSCRIBE_OVER
;
}
if
(
mndCheckDbPrivilegeByName
(
pMnode
,
pMsg
->
info
.
conn
.
user
,
MND_OPER_READ_DB
,
pTopic
->
db
)
!=
0
)
{
goto
SUBSCRIBE_OVER
;
}
#if 0
// ref topic to prevent drop
// TODO make topic complete
...
...
source/dnode/mnode/impl/src/mndPrivilege.c
浏览文件 @
1fb2c664
...
...
@@ -16,6 +16,7 @@
#define _DEFAULT_SOURCE
#include "mndPrivilege.h"
#include "mndUser.h"
#include "mndDb.h"
int32_t
mndInitPrivilege
(
SMnode
*
pMnode
)
{
return
0
;
}
...
...
@@ -133,15 +134,7 @@ int32_t mndCheckDbPrivilege(SMnode *pMnode, const char *user, EOperType operType
if
(
pUser
->
sysInfo
)
goto
_OVER
;
}
if
(
operType
==
MND_OPER_ALTER_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
&&
pUser
->
sysInfo
)
goto
_OVER
;
}
if
(
operType
==
MND_OPER_DROP_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
&&
pUser
->
sysInfo
)
goto
_OVER
;
}
if
(
operType
==
MND_OPER_COMPACT_DB
)
{
if
(
operType
==
MND_OPER_ALTER_DB
||
operType
==
MND_OPER_DROP_DB
||
operType
==
MND_OPER_COMPACT_DB
)
{
if
(
strcmp
(
pUser
->
user
,
pDb
->
createUser
)
==
0
&&
pUser
->
sysInfo
)
goto
_OVER
;
}
...
...
@@ -168,3 +161,12 @@ _OVER:
mndReleaseUser
(
pMnode
,
pUser
);
return
code
;
}
int32_t
mndCheckDbPrivilegeByName
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
const
char
*
name
)
{
SDbObj
*
pDb
=
mndAcquireDb
(
pMnode
,
name
);
if
(
pDb
==
NULL
)
return
-
1
;
int32_t
code
=
mndCheckDbPrivilege
(
pMnode
,
user
,
operType
,
pDb
);
mndReleaseDb
(
pMnode
,
pDb
);
return
code
;
}
\ No newline at end of file
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
1fb2c664
...
...
@@ -437,10 +437,6 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
goto
_OVER
;
}
if
(
mndCheckDbPrivilege
(
pMnode
,
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
int32_t
numOfStbs
=
-
1
;
if
(
mndGetNumOfStbs
(
pMnode
,
pDb
->
name
,
&
numOfStbs
)
!=
0
)
{
goto
_OVER
;
...
...
@@ -542,19 +538,6 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
goto
_OVER
;
}
// TODO check read auth for source and write auth for target
#if 0
pDb = mndAcquireDb(pMnode, createStreamReq.sourceDB);
if (pDb == NULL) {
terrno = TSDB_CODE_MND_DB_NOT_SELECTED;
goto _OVER;
}
if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
goto _OVER;
}
#endif
// build stream obj from request
SStreamObj
streamObj
=
{
0
};
if
(
mndBuildStreamObjFromCreateReq
(
pMnode
,
&
streamObj
,
&
createStreamReq
)
<
0
)
{
...
...
@@ -592,6 +575,16 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDbPrivilegeByName
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_READ_DB
,
streamObj
.
sourceDb
)
!=
0
)
{
mndTransDrop
(
pTrans
);
goto
_OVER
;
}
if
(
mndCheckDbPrivilegeByName
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
streamObj
.
targetDb
)
!=
0
)
{
mndTransDrop
(
pTrans
);
goto
_OVER
;
}
// execute creation
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
...
...
@@ -641,13 +634,9 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) {
}
}
#if 0
// todo check auth
pUser = mndAcquireUser(pMnode, pReq->info.conn.user);
if (pUser == NULL) {
goto DROP_STREAM_OVER;
if
(
mndCheckDbPrivilegeByName
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pStream
->
targetDb
)
!=
0
)
{
return
-
1
;
}
#endif
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
TRN_CONFLICT_NOTHING
,
pReq
);
if
(
pTrans
==
NULL
)
{
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
1fb2c664
...
...
@@ -14,12 +14,12 @@
*/
#include "mndTopic.h"
#include "mndPrivilege.h"
#include "mndConsumer.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
#include "mndOffset.h"
#include "mndPrivilege.h"
#include "mndShow.h"
#include "mndStb.h"
#include "mndSubscribe.h"
...
...
@@ -480,7 +480,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDbPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_
WRITE
_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDbPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_
READ
_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -571,6 +571,10 @@ static int32_t mndProcessDropTopicReq(SRpcMsg *pReq) {
}
#endif
if
(
mndCheckDbPrivilegeByName
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_READ_DB
,
pTopic
->
db
)
!=
0
)
{
return
-
1
;
}
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
TRN_CONFLICT_DB_INSIDE
,
pReq
);
mndTransSetDbName
(
pTrans
,
pTopic
->
db
,
NULL
);
if
(
pTrans
==
NULL
)
{
...
...
tests/script/tsim/user/privilege_sysinfo.sim
浏览文件 @
1fb2c664
...
...
@@ -13,9 +13,6 @@ print user sysinfo0 login
sql close
sql connect sysinfo0
system sh/exec.sh -n dnode1 -s stop
return
print =============== check oper
sql_error create user u1 pass 'u1'
sql_error drop user sysinfo1
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录