Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aa8faeba
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看板
未验证
提交
aa8faeba
编写于
6月 25, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
6月 25, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #14224 from taosdata/fix/mnode
refactor: rename auth to privilege
上级
f0b50add
09ce47ae
变更
23
隐藏空白更改
内联
并排
Showing
23 changed file
with
145 addition
and
170 deletion
+145
-170
source/dnode/mnode/impl/inc/mndPrivilege.h
source/dnode/mnode/impl/inc/mndPrivilege.h
+14
-9
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+13
-0
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+3
-3
source/dnode/mnode/impl/src/mndConsumer.c
source/dnode/mnode/impl/src/mndConsumer.c
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+8
-9
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+4
-4
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+3
-3
source/dnode/mnode/impl/src/mndMain.c
source/dnode/mnode/impl/src/mndMain.c
+2
-2
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+3
-3
source/dnode/mnode/impl/src/mndOffset.c
source/dnode/mnode/impl/src/mndOffset.c
+10
-8
source/dnode/mnode/impl/src/mndPrivilege.c
source/dnode/mnode/impl/src/mndPrivilege.c
+9
-59
source/dnode/mnode/impl/src/mndProfile.c
source/dnode/mnode/impl/src/mndProfile.c
+19
-31
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+3
-3
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+2
-2
source/dnode/mnode/impl/src/mndSma.c
source/dnode/mnode/impl/src/mndSma.c
+3
-3
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+3
-3
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+4
-4
source/dnode/mnode/impl/src/mndStream.c
source/dnode/mnode/impl/src/mndStream.c
+3
-3
source/dnode/mnode/impl/src/mndTopic.c
source/dnode/mnode/impl/src/mndTopic.c
+2
-2
source/dnode/mnode/impl/src/mndTrans.c
source/dnode/mnode/impl/src/mndTrans.c
+2
-3
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+9
-11
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+4
-4
tests/script/tsim/user/privilege_sysinfo.sim
tests/script/tsim/user/privilege_sysinfo.sim
+21
-0
未找到文件。
source/dnode/mnode/impl/inc/mnd
Auth
.h
→
source/dnode/mnode/impl/inc/mnd
Privilege
.h
浏览文件 @
aa8faeba
...
...
@@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_MND_
AUTH_H_
#define _TD_MND_
AUTH_H_
#ifndef _TD_MND_
PRIVILEGE_H
#define _TD_MND_
PRIVILEGE_H
#include "mndInt.h"
...
...
@@ -24,6 +24,9 @@ extern "C" {
typedef
enum
{
MND_OPER_CONNECT
=
1
,
MND_OPER_CREATE_ACCT
,
MND_OPER_DROP_ACCT
,
MND_OPER_ALTER_ACCT
,
MND_OPER_CREATE_USER
,
MND_OPER_DROP_USER
,
MND_OPER_ALTER_USER
,
...
...
@@ -45,6 +48,8 @@ typedef enum {
MND_OPER_CREATE_FUNC
,
MND_OPER_DROP_FUNC
,
MND_OPER_KILL_TRANS
,
MND_OPER_KILL_CONN
,
MND_OPER_KILL_QUERY
,
MND_OPER_CREATE_DB
,
MND_OPER_ALTER_DB
,
MND_OPER_DROP_DB
,
...
...
@@ -54,16 +59,16 @@ typedef enum {
MND_OPER_READ_DB
,
}
EOperType
;
int32_t
mndInit
Auth
(
SMnode
*
pMnode
);
void
mndCleanup
Auth
(
SMnode
*
pMnode
);
int32_t
mndInit
Privilege
(
SMnode
*
pMnode
);
void
mndCleanup
Privilege
(
SMnode
*
pMnode
);
int32_t
mndCheckOper
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
);
int32_t
mndCheckDb
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
);
int32_t
mndCheckShow
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
);
int32_t
mndCheckAlterUser
Auth
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
);
int32_t
mndCheckOper
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
);
int32_t
mndCheckDb
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
);
int32_t
mndCheckShow
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
);
int32_t
mndCheckAlterUser
Privilege
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
);
#ifdef __cplusplus
}
#endif
#endif
/*_TD_MND_
AUTH_H_
*/
#endif
/*_TD_MND_
PRIVILEGE_H
*/
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
aa8faeba
...
...
@@ -15,6 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndAcct.h"
#include "mndPrivilege.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -212,18 +213,30 @@ static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew) {
}
static
int32_t
mndProcessCreateAcctReq
(
SRpcMsg
*
pReq
)
{
if
(
mndCheckOperPrivilege
(
pReq
->
info
.
node
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_ACCT
)
!=
0
)
{
return
-
1
;
}
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
}
static
int32_t
mndProcessAlterAcctReq
(
SRpcMsg
*
pReq
)
{
if
(
mndCheckOperPrivilege
(
pReq
->
info
.
node
,
pReq
->
info
.
conn
.
user
,
MND_OPER_ALTER_ACCT
)
!=
0
)
{
return
-
1
;
}
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
}
static
int32_t
mndProcessDropAcctReq
(
SRpcMsg
*
pReq
)
{
if
(
mndCheckOperPrivilege
(
pReq
->
info
.
node
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_ACCT
)
!=
0
)
{
return
-
1
;
}
terrno
=
TSDB_CODE_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndBnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -277,7 +277,7 @@ static int32_t mndProcessCreateBnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"bnode:%d, start to create"
,
createReq
.
dnodeId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_BNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_BNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -382,7 +382,7 @@ static int32_t mndProcessDropBnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"bnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_BNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_BNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndConsumer.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndConsumer.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndDb.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndOffset.h"
#include "mndShow.h"
...
...
@@ -506,6 +506,9 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
}
mDebug
(
"db:%s, start to create, vgroups:%d"
,
createReq
.
db
,
createReq
.
numOfVgroups
);
if
(
mndCheckDbPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_DB
,
NULL
)
!=
0
)
{
goto
_OVER
;
}
pDb
=
mndAcquireDb
(
pMnode
,
createReq
.
db
);
if
(
pDb
!=
NULL
)
{
...
...
@@ -526,10 +529,6 @@ static int32_t mndProcessCreateDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDbAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_DB
,
NULL
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateDb
(
pMnode
,
pReq
,
&
createReq
,
pUser
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -700,7 +699,7 @@ static int32_t mndProcessAlterDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_ALTER_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_ALTER_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -980,7 +979,7 @@ static int32_t mndProcessDropDbReq(SRpcMsg *pReq) {
}
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1127,7 +1126,7 @@ static int32_t mndProcessUseDbReq(SRpcMsg *pReq) {
mError
(
"db:%s, failed to process use db req since %s"
,
usedbReq
.
db
,
terrstr
());
}
else
{
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_USE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_USE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1252,7 +1251,7 @@ static int32_t mndProcessCompactDbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_COMPACT_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_COMPACT_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndDnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndMnode.h"
#include "mndQnode.h"
#include "mndShow.h"
...
...
@@ -621,7 +621,7 @@ static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
}
mInfo
(
"dnode:%s:%d, start to create"
,
createReq
.
fqdn
,
createReq
.
port
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_DNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_DNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -715,7 +715,7 @@ static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq) {
}
mInfo
(
"dnode:%d, start to drop, ep:%s:%d"
,
dropReq
.
dnodeId
,
dropReq
.
fqdn
,
dropReq
.
port
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -779,7 +779,7 @@ static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
}
mInfo
(
"dnode:%d, start to config, option:%s, value:%s"
,
cfgReq
.
dnodeId
,
cfgReq
.
config
,
cfgReq
.
value
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CONFIG_DNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CONFIG_DNODE
)
!=
0
)
{
return
-
1
;
}
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndFunc.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndShow.h"
#include "mndSync.h"
#include "mndTrans.h"
...
...
@@ -283,7 +283,7 @@ static int32_t mndProcessCreateFuncReq(SRpcMsg *pReq) {
}
mDebug
(
"func:%s, start to create"
,
createReq
.
name
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_FUNC
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_FUNC
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -346,7 +346,7 @@ static int32_t mndProcessDropFuncReq(SRpcMsg *pReq) {
}
mDebug
(
"func:%s, start to drop"
,
dropReq
.
name
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_FUNC
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_FUNC
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndMain.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndAcct.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndBnode.h"
#include "mndCluster.h"
#include "mndConsumer.h"
...
...
@@ -239,7 +239,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
if
(
mndAllocStep
(
pMnode
,
"mnode-dnode"
,
mndInitDnode
,
mndCleanupDnode
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-user"
,
mndInitUser
,
mndCleanupUser
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-grant"
,
mndInitGrant
,
mndCleanupGrant
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
auth"
,
mndInitAuth
,
mndCleanupAuth
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-
privilege"
,
mndInitPrivilege
,
mndCleanupPrivilege
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-acct"
,
mndInitAcct
,
mndCleanupAcct
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-stream"
,
mndInitStream
,
mndCleanupStream
)
!=
0
)
return
-
1
;
if
(
mndAllocStep
(
pMnode
,
"mnode-topic"
,
mndInitTopic
,
mndCleanupTopic
)
!=
0
)
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndMnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndSync.h"
...
...
@@ -389,7 +389,7 @@ static int32_t mndProcessCreateMnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"mnode:%d, start to create"
,
createReq
.
dnodeId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_MNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_MNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -594,7 +594,7 @@ static int32_t mndProcessDropMnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"mnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_MNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndOffset.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndOffset.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -36,13 +36,15 @@ static int32_t mndOffsetActionUpdate(SSdb *pSdb, SMqOffsetObj *pOffset, SMqOffse
static
int32_t
mndProcessCommitOffsetReq
(
SRpcMsg
*
pReq
);
int32_t
mndInitOffset
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_OFFSET
,
.
keyType
=
SDB_KEY_BINARY
,
.
encodeFp
=
(
SdbEncodeFp
)
mndOffsetActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndOffsetActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndOffsetActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndOffsetActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndOffsetActionDelete
};
SSdbTable
table
=
{
.
sdbType
=
SDB_OFFSET
,
.
keyType
=
SDB_KEY_BINARY
,
.
encodeFp
=
(
SdbEncodeFp
)
mndOffsetActionEncode
,
.
decodeFp
=
(
SdbDecodeFp
)
mndOffsetActionDecode
,
.
insertFp
=
(
SdbInsertFp
)
mndOffsetActionInsert
,
.
updateFp
=
(
SdbUpdateFp
)
mndOffsetActionUpdate
,
.
deleteFp
=
(
SdbDeleteFp
)
mndOffsetActionDelete
,
};
mndSetMsgHandle
(
pMnode
,
TDMT_MND_MQ_COMMIT_OFFSET
,
mndProcessCommitOffsetReq
);
...
...
source/dnode/mnode/impl/src/mnd
Auth
.c
→
source/dnode/mnode/impl/src/mnd
Privilege
.c
浏览文件 @
aa8faeba
...
...
@@ -14,66 +14,14 @@
*/
#define _DEFAULT_SOURCE
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndUser.h"
static
int32_t
mndProcessAuthReq
(
SRpcMsg
*
pReq
);
int32_t
mndInitPrivilege
(
SMnode
*
pMnode
)
{
return
0
;
}
int32_t
mndInitAuth
(
SMnode
*
pMnode
)
{
mndSetMsgHandle
(
pMnode
,
TDMT_MND_AUTH
,
mndProcessAuthReq
);
return
0
;
}
void
mndCleanupAuth
(
SMnode
*
pMnode
)
{}
static
int32_t
mndRetriveAuth
(
SMnode
*
pMnode
,
SAuthRsp
*
pRsp
)
{
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pRsp
->
user
);
if
(
pUser
==
NULL
)
{
*
pRsp
->
secret
=
0
;
mError
(
"user:%s, failed to auth user since %s"
,
pRsp
->
user
,
terrstr
());
return
-
1
;
}
pRsp
->
spi
=
1
;
pRsp
->
encrypt
=
0
;
*
pRsp
->
ckey
=
0
;
memcpy
(
pRsp
->
secret
,
pUser
->
pass
,
TSDB_PASSWORD_LEN
);
mndReleaseUser
(
pMnode
,
pUser
);
mDebug
(
"user:%s, auth info is returned"
,
pRsp
->
user
);
return
0
;
}
static
int32_t
mndProcessAuthReq
(
SRpcMsg
*
pReq
)
{
SAuthReq
authReq
=
{
0
};
if
(
tDeserializeSAuthReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
authReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
SAuthReq
authRsp
=
{
0
};
memcpy
(
authRsp
.
user
,
authReq
.
user
,
TSDB_USER_LEN
);
int32_t
code
=
mndRetriveAuth
(
pReq
->
info
.
node
,
&
authRsp
);
mTrace
(
"user:%s, auth req received, spi:%d encrypt:%d ruser:%s"
,
pReq
->
info
.
conn
.
user
,
authRsp
.
spi
,
authRsp
.
encrypt
,
authRsp
.
user
);
int32_t
contLen
=
tSerializeSAuthReq
(
NULL
,
0
,
&
authRsp
);
void
*
pRsp
=
rpcMallocCont
(
contLen
);
if
(
pRsp
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
tSerializeSAuthReq
(
pRsp
,
contLen
,
&
authRsp
);
pReq
->
info
.
rsp
=
pRsp
;
pReq
->
info
.
rspLen
=
contLen
;
return
code
;
}
void
mndCleanupPrivilege
(
SMnode
*
pMnode
)
{}
int32_t
mndCheckOper
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
)
{
int32_t
mndCheckOper
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
...
...
@@ -95,6 +43,8 @@ int32_t mndCheckOperAuth(SMnode *pMnode, const char *user, EOperType operType) {
switch
(
operType
)
{
case
MND_OPER_CONNECT
:
case
MND_OPER_CREATE_FUNC
:
case
MND_OPER_DROP_FUNC
:
break
;
default:
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
...
...
@@ -106,7 +56,7 @@ _OVER:
return
code
;
}
int32_t
mndCheckAlterUser
Auth
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
)
{
int32_t
mndCheckAlterUser
Privilege
(
SUserObj
*
pOperUser
,
SUserObj
*
pUser
,
SAlterUserReq
*
pAlter
)
{
if
(
pUser
->
superUser
&&
pAlter
->
alterType
!=
TSDB_ALTER_USER_PASSWD
)
{
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
...
...
@@ -129,7 +79,7 @@ int32_t mndCheckAlterUserAuth(SUserObj *pOperUser, SUserObj *pUser, SAlterUserRe
return
-
1
;
}
int32_t
mndCheckShow
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
)
{
int32_t
mndCheckShow
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
int32_t
showType
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
...
...
@@ -162,7 +112,7 @@ _OVER:
return
code
;
}
int32_t
mndCheckDb
Auth
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
)
{
int32_t
mndCheckDb
Privilege
(
SMnode
*
pMnode
,
const
char
*
user
,
EOperType
operType
,
SDbObj
*
pDb
)
{
int32_t
code
=
0
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
user
);
...
...
source/dnode/mnode/impl/src/mndProfile.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndProfile.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -227,6 +227,10 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
}
taosIp2String
(
pReq
->
info
.
conn
.
clientIp
,
ip
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CONNECT
)
!=
0
)
{
mGError
(
"user:%s, failed to login from %s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
_OVER
;
}
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
info
.
conn
.
user
);
if
(
pUser
==
NULL
)
{
...
...
@@ -240,11 +244,6 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CONNECT
)
!=
0
)
{
mGError
(
"user:%s, failed to login from %s since %s"
,
pReq
->
info
.
conn
.
user
,
ip
,
terrstr
());
goto
_OVER
;
}
if
(
connReq
.
db
[
0
])
{
char
db
[
TSDB_DB_FNAME_LEN
]
=
{
0
};
snprintf
(
db
,
TSDB_DB_FNAME_LEN
,
"%d%s%s"
,
pUser
->
acctId
,
TS_PATH_DELIMITER
,
connReq
.
db
);
...
...
@@ -271,7 +270,7 @@ static int32_t mndProcessConnectReq(SRpcMsg *pReq) {
connectRsp
.
connId
=
pConn
->
id
;
connectRsp
.
connType
=
connReq
.
connType
;
connectRsp
.
dnodeNum
=
mndGetDnodeSize
(
pMnode
);
strcpy
(
connectRsp
.
sVer
,
version
);
snprintf
(
connectRsp
.
sDetailVer
,
sizeof
(
connectRsp
.
sDetailVer
),
"ver:%s
\n
build:%s
\n
gitinfo:%s"
,
version
,
buildinfo
,
gitinfo
);
...
...
@@ -475,16 +474,16 @@ static int32_t mndGetOnlineDnodeNum(SMnode *pMnode, int32_t *num) {
SDnodeObj
*
pDnode
=
NULL
;
int64_t
curMs
=
taosGetTimestampMs
();
void
*
pIter
=
NULL
;
while
(
true
)
{
pIter
=
sdbFetch
(
pSdb
,
SDB_DNODE
,
pIter
,
(
void
**
)
&
pDnode
);
if
(
pIter
==
NULL
)
break
;
bool
online
=
mndIsDnodeOnline
(
pDnode
,
curMs
);
if
(
online
)
{
(
*
num
)
++
;
}
sdbRelease
(
pSdb
,
pDnode
);
}
...
...
@@ -652,15 +651,6 @@ static int32_t mndProcessKillQueryReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
info
.
conn
.
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
mndReleaseUser
(
pMnode
,
pUser
);
SKillQueryReq
killReq
=
{
0
};
if
(
tDeserializeSKillQueryReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
killReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
...
...
@@ -668,6 +658,10 @@ static int32_t mndProcessKillQueryReq(SRpcMsg *pReq) {
}
mInfo
(
"kill query msg is received, queryId:%s"
,
killReq
.
queryStrId
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_KILL_QUERY
)
!=
0
)
{
return
-
1
;
}
int32_t
connId
=
0
;
uint64_t
queryId
=
0
;
char
*
p
=
strchr
(
killReq
.
queryStrId
,
':'
);
...
...
@@ -697,21 +691,16 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) {
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SProfileMgmt
*
pMgmt
=
&
pMnode
->
profileMgmt
;
SUserObj
*
pUser
=
mndAcquireUser
(
pMnode
,
pReq
->
info
.
conn
.
user
);
if
(
pUser
==
NULL
)
return
0
;
if
(
!
pUser
->
superUser
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_RIGHTS
;
return
-
1
;
}
mndReleaseUser
(
pMnode
,
pUser
);
SKillConnReq
killReq
=
{
0
};
if
(
tDeserializeSKillConnReq
(
pReq
->
pCont
,
pReq
->
contLen
,
&
killReq
)
!=
0
)
{
terrno
=
TSDB_CODE_INVALID_MSG
;
return
-
1
;
}
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_KILL_CONN
)
!=
0
)
{
return
-
1
;
}
SConnObj
*
pConn
=
taosCacheAcquireByKey
(
pMgmt
->
connCache
,
&
killReq
.
connId
,
sizeof
(
uint32_t
));
if
(
pConn
==
NULL
)
{
mError
(
"connId:%u, failed to kill connection, conn not exist"
,
killReq
.
connId
);
...
...
@@ -726,10 +715,10 @@ static int32_t mndProcessKillConnReq(SRpcMsg *pReq) {
}
static
int32_t
mndProcessSvrVerReq
(
SRpcMsg
*
pReq
)
{
int32_t
code
=
-
1
;
int32_t
code
=
-
1
;
SServerVerRsp
rsp
=
{
0
};
strcpy
(
rsp
.
ver
,
version
);
int32_t
contLen
=
tSerializeSServerVerRsp
(
NULL
,
0
,
&
rsp
);
if
(
contLen
<
0
)
goto
_over
;
void
*
pRsp
=
rpcMallocCont
(
contLen
);
...
...
@@ -746,7 +735,6 @@ _over:
return
code
;
}
static
int32_t
mndRetrieveConns
(
SRpcMsg
*
pReq
,
SShowObj
*
pShow
,
SSDataBlock
*
pBlock
,
int32_t
rows
)
{
SMnode
*
pMnode
=
pReq
->
info
.
node
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndQnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -279,7 +279,7 @@ static int32_t mndProcessCreateQnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"qnode:%d, start to create"
,
createReq
.
dnodeId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_QNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_QNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -390,7 +390,7 @@ static int32_t mndProcessDropQnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"qnode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_QNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_QNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
aa8faeba
...
...
@@ -16,7 +16,7 @@
#define _DEFAULT_SOURCE
#include "mndShow.h"
#include "systable.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#define SHOW_STEP_SIZE 100
...
...
@@ -231,7 +231,7 @@ static int32_t mndProcessRetrieveSysTableReq(SRpcMsg *pReq) {
mDebug
(
"show:0x%"
PRIx64
", start retrieve data, type:%d"
,
pShow
->
id
,
pShow
->
type
);
// if (mndCheckShow
Auth
(pMnode, pReq->info.conn.user, pShow->type) != 0) return -1;
// if (mndCheckShow
Privilege
(pMnode, pReq->info.conn.user, pShow->type) != 0) return -1;
int32_t
numOfCols
=
pShow
->
pMeta
->
numOfColumns
;
SSDataBlock
*
pBlock
=
taosMemoryCalloc
(
1
,
sizeof
(
SSDataBlock
));
...
...
source/dnode/mnode/impl/src/mndSma.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndSma.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndInfoSchema.h"
...
...
@@ -713,7 +713,7 @@ static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -974,7 +974,7 @@ static int32_t mndProcessDropSmaReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndSnode.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDnode.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -285,7 +285,7 @@ static int32_t mndProcessCreateSnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"snode:%d, start to create"
,
createReq
.
dnodeId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_SNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_SNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -397,7 +397,7 @@ static int32_t mndProcessDropSnodeReq(SRpcMsg *pReq) {
}
mDebug
(
"snode:%d, start to drop"
,
dropReq
.
dnodeId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_SNODE
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_SNODE
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndStb.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndInfoSchema.h"
...
...
@@ -876,7 +876,7 @@ static int32_t mndProcessCreateStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1607,7 +1607,7 @@ static int32_t mndProcessAlterStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1737,7 +1737,7 @@ static int32_t mndProcessDropStbReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndStream.c
浏览文件 @
aa8faeba
...
...
@@ -14,7 +14,7 @@
*/
#include "mndStream.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -437,7 +437,7 @@ static int32_t mndCreateStbForStream(SMnode *pMnode, STrans *pTrans, const SStre
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -550,7 +550,7 @@ static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq) {
goto _OVER;
}
if (mndCheckDb
Auth
(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
if (mndCheckDb
Privilege
(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pDb) != 0) {
goto _OVER;
}
#endif
...
...
source/dnode/mnode/impl/src/mndTopic.c
浏览文件 @
aa8faeba
...
...
@@ -14,7 +14,7 @@
*/
#include "mndTopic.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndConsumer.h"
#include "mndDb.h"
#include "mndDnode.h"
...
...
@@ -480,7 +480,7 @@ static int32_t mndProcessCreateTopicReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckDb
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
if
(
mndCheckDb
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_WRITE_DB
,
pDb
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndTrans.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndTrans.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndConsumer.h"
#include "mndDb.h"
#include "mndShow.h"
...
...
@@ -1384,8 +1384,7 @@ static int32_t mndProcessKillTransReq(SRpcMsg *pReq) {
}
mInfo
(
"trans:%d, start to kill"
,
killReq
.
transId
);
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_KILL_TRANS
)
!=
0
)
{
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_KILL_TRANS
)
!=
0
)
{
goto
_OVER
;
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndUser.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndShow.h"
#include "mndTrans.h"
...
...
@@ -295,7 +295,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, SCreateUserReq *pCreate
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
userObj
.
createdTime
=
taosGetTimestampMs
();
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
superUser
=
0
;
//
pCreate->superUser;
userObj
.
superUser
=
0
;
//
pCreate->superUser;
userObj
.
sysInfo
=
pCreate
->
sysInfo
;
userObj
.
enable
=
pCreate
->
enable
;
...
...
@@ -337,6 +337,9 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
}
mDebug
(
"user:%s, start to create"
,
createReq
.
user
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_USER
)
!=
0
)
{
goto
_OVER
;
}
if
(
createReq
.
user
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_USER_FORMAT
;
...
...
@@ -360,10 +363,6 @@ static int32_t mndProcessCreateUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_CREATE_USER
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndCreateUser
(
pMnode
,
pOperUser
->
acct
,
&
createReq
,
pReq
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
@@ -466,7 +465,7 @@ static int32_t mndProcessAlterUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckAlterUser
Auth
(
pOperUser
,
pUser
,
&
alterReq
)
!=
0
)
{
if
(
mndCheckAlterUser
Privilege
(
pOperUser
,
pUser
,
&
alterReq
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -631,6 +630,9 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
}
mDebug
(
"user:%s, start to drop"
,
dropReq
.
user
);
if
(
mndCheckOperPrivilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_USER
)
!=
0
)
{
goto
_OVER
;
}
if
(
dropReq
.
user
[
0
]
==
0
)
{
terrno
=
TSDB_CODE_MND_INVALID_USER_FORMAT
;
...
...
@@ -643,10 +645,6 @@ static int32_t mndProcessDropUserReq(SRpcMsg *pReq) {
goto
_OVER
;
}
if
(
mndCheckOperAuth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_DROP_USER
)
!=
0
)
{
goto
_OVER
;
}
code
=
mndDropUser
(
pMnode
,
pReq
,
pUser
);
if
(
code
==
0
)
code
=
TSDB_CODE_ACTION_IN_PROGRESS
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
aa8faeba
...
...
@@ -15,7 +15,7 @@
#define _DEFAULT_SOURCE
#include "mndVgroup.h"
#include "mnd
Auth
.h"
#include "mnd
Privilege
.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndMnode.h"
...
...
@@ -1212,7 +1212,7 @@ static int32_t mndProcessRedistributeVgroupMsg(SRpcMsg *pReq) {
}
mInfo
(
"vgId:%d, start to redistribute vgroup to dnode %d:%d:%d"
,
req
.
vgId
,
req
.
dnodeId1
,
req
.
dnodeId2
,
req
.
dnodeId3
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_REDISTRIBUTE_VGROUP
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_REDISTRIBUTE_VGROUP
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1507,7 +1507,7 @@ static int32_t mndProcessSplitVgroupMsg(SRpcMsg *pReq) {
SDbObj
*
pDb
=
NULL
;
mDebug
(
"vgId:%d, start to split"
,
vgId
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_SPLIT_VGROUP
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_SPLIT_VGROUP
)
!=
0
)
{
goto
_OVER
;
}
...
...
@@ -1657,7 +1657,7 @@ static int32_t mndProcessBalanceVgroupMsg(SRpcMsg *pReq) {
}
mInfo
(
"start to balance vgroup"
);
if
(
mndCheckOper
Auth
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_BALANCE_VGROUP
)
!=
0
)
{
if
(
mndCheckOper
Privilege
(
pMnode
,
pReq
->
info
.
conn
.
user
,
MND_OPER_BALANCE_VGROUP
)
!=
0
)
{
goto
_OVER
;
}
...
...
tests/script/tsim/user/privilege_sysinfo.sim
浏览文件 @
aa8faeba
...
...
@@ -22,5 +22,26 @@ sql_error drop user sysinfo1
sql_error alter user sysinfo1 pass '1'
sql_error alter user sysinfo0 pass '1'
sql_error create dnode $hostname port 7200
sql_error drop dnode 1
sql_error create qnode on dnode 1
sql_error drop qnode on dnode 1
sql_error create mnode on dnode 1
sql_error drop mnode on dnode 1
sql_error create snode on dnode 1
sql_error drop snode on dnode 1
sql_error redistribute vgroup 2 dnode 1 dnode 2
sql_error balance vgroup
sql_error kill transaction 1
sql_error kill connection 1
sql_error kill query 1
print =============== check db
sql_error create database db
system sh/exec.sh -n dnode1 -s stop -x SIGINT
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录